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>
21 lines
614 B
Python
21 lines
614 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import SUPERUSER_ID, api
|
|
|
|
from . import models
|
|
from . import wizard
|
|
|
|
|
|
def uninstall_hook(cr, registry):
|
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
|
warehouses = env["stock.warehouse"].search([])
|
|
subcontracting_routes = warehouses.mapped("subcontracting_route_id")
|
|
warehouses.write({"subcontracting_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:
|
|
with env.cr.savepoint():
|
|
subcontracting_routes.unlink()
|
|
except:
|
|
pass
|