From 160b404fa9c87315af5fa88c67128c064410e80e Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Tue, 10 Oct 2023 11:39:48 +0200 Subject: [PATCH] [FIX] point_of_sale: correctly delete sequences when uninstalling PoS Current behavior: After uninstalling the PoS module, if you try to install it again, you get a traceback because Odoo is trying to create a sequence that already exists. Steps to reproduce: - install PoS - uninstall PoS - install PoS - you get a traceback opw-3515647 closes odoo/odoo#139767 X-original-commit: c57bb574721a3610f66320dacdc703abc490d5d4 Signed-off-by: Vlad Stroia (vlst) Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/__init__.py | 7 +++++++ addons/point_of_sale/__manifest__.py | 1 + 2 files changed, 8 insertions(+) diff --git a/addons/point_of_sale/__init__.py b/addons/point_of_sale/__init__.py index ee87c280f2c..ee1ebcbaa51 100644 --- a/addons/point_of_sale/__init__.py +++ b/addons/point_of_sale/__init__.py @@ -5,3 +5,10 @@ from . import models from . import controllers from . import report from . import wizard + +from odoo import api, SUPERUSER_ID + +def uninstall_hook(cr, registry): + env = api.Environment(cr, SUPERUSER_ID, {}) + #The search domain is based on how the sequence is defined in the _get_sequence_values method in /addons/point_of_sale/models/stock_warehouse.py + env['ir.sequence'].search([('name', 'ilike', '%Picking POS%'), ('prefix', 'ilike', '%/POS/%')]).unlink() diff --git a/addons/point_of_sale/__manifest__.py b/addons/point_of_sale/__manifest__.py index fd2d5a9dd1c..901b6fa1896 100644 --- a/addons/point_of_sale/__manifest__.py +++ b/addons/point_of_sale/__manifest__.py @@ -8,6 +8,7 @@ 'sequence': 40, 'summary': 'User-friendly PoS interface for shops and restaurants', 'depends': ['stock_account', 'barcodes', 'web_editor', 'digest'], + 'uninstall_hook': 'uninstall_hook', 'data': [ 'security/point_of_sale_security.xml', 'security/ir.model.access.csv',