[FIX] mrp, mrp_subcontracting: traceback during unistall

The unlink fail in __init__.py uninstall hook is managed, however
when it fail, the error is catch but the cursor is not rollback and
do not accept additional transaction. That result in a traceback at
uninstall.

opw-2453939

closes odoo/odoo#66309

X-original-commit: 66d9dce9b6e6e65000ba0b62efcb153f2d3eec15
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
Arnold Moyaux
2021-02-16 18:33:27 +00:00
parent 6cdcd9a3c0
commit c8c30b0743
2 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -31,12 +31,13 @@ def _create_warehouse_data(cr, registry):
def uninstall_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
warehouses = env["stock.warehouse"].search([])
subcontracting_routes = warehouses.mapped("pbm_route_id")
pbm_routes = warehouses.mapped("pbm_route_id")
warehouses.write({"pbm_route_id": False})
# Fail unlink means that the route is used somewhere (e.g. route_id on stock.rule). In this case
# we don't try to do anything.
try:
subcontracting_routes.unlink()
with env.cr.savepoint():
pbm_routes.unlink()
except:
pass
+2 -1
View File
@@ -14,6 +14,7 @@ def uninstall_hook(cr, registry):
# Fail unlink means that the route is used somewhere (e.g. route_id on stock.rule). In this case
# we don't try to do anything.
try:
subcontracting_routes.unlink()
with env.cr.savepoint():
subcontracting_routes.unlink()
except:
pass