From 6a0952a5b1eaed69921749f8afd4e975393f966e Mon Sep 17 00:00:00 2001 From: Mathieu Walravens Date: Fri, 1 Sep 2023 18:01:28 +0200 Subject: [PATCH] [FIX] stock: clean-up sequences at uninstall When stock is uninstalled, the sequences used in the warehouses for the picking types are kept. However, since [1], picking types cannot be duplicated anymore. When the module is re-installed, the picking types are created with the same name, which is not allowed by [1]. [1]: https://github.com/odoo/odoo/commit/9034602a028fb22fbd139cf41a2f5c71d9d8d032 opw-3484352 closes odoo/odoo#135036 X-original-commit: 7b0f38fea8bc9a541972d29f289e6175ee15919b Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Walravens Mathieu (wama) --- addons/stock/__init__.py | 4 ++++ addons/stock/__manifest__.py | 1 + 2 files changed, 5 insertions(+) diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index 9ed46e242c5..5d92aa6951b 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -24,3 +24,7 @@ def _assign_default_mail_template_picking_id(env): company_ids_without_default_mail_template_id.write({ 'stock_mail_confirmation_template_id': default_mail_template_id.id, }) + +def uninstall_hook(env): + picking_type_ids = env["stock.picking.type"].with_context({"active_test": False}).search([]) + picking_type_ids.sequence_id.unlink() diff --git a/addons/stock/__manifest__.py b/addons/stock/__manifest__.py index e89b9472cc6..e4570054120 100644 --- a/addons/stock/__manifest__.py +++ b/addons/stock/__manifest__.py @@ -95,6 +95,7 @@ 'application': True, 'pre_init_hook': 'pre_init_hook', 'post_init_hook': '_assign_default_mail_template_picking_id', + 'uninstall_hook': 'uninstall_hook', 'assets': { 'web.report_assets_common': [ 'stock/static/src/scss/report_stock_reception.scss',