[IMP] mrp_subcontracting: improve uninstall hook
Clean/remove subcontracting operation type when we uninstall subcontracting. task-2633558 closes odoo/odoo#76612 X-original-commit: 3452e821feca3622457eeb919bca2f0821214a71 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com> Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
from . import models
|
||||
from . import wizard
|
||||
from . import report
|
||||
from . import wizard
|
||||
|
||||
from odoo import SUPERUSER_ID, api
|
||||
|
||||
|
||||
def uninstall_hook(cr, registry):
|
||||
@@ -12,10 +12,13 @@ def uninstall_hook(cr, registry):
|
||||
warehouses = env["stock.warehouse"].search([])
|
||||
subcontracting_routes = warehouses.mapped("subcontracting_route_id")
|
||||
warehouses.write({"subcontracting_route_id": False})
|
||||
operations_type_to_remove = (warehouses.subcontracting_resupply_type_id | warehouses.subcontracting_type_id)
|
||||
operations_type_to_remove.active = 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()
|
||||
operations_type_to_remove.unlink()
|
||||
except:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user