From e52d8f6648556ca97e07769529779be048a96fb7 Mon Sep 17 00:00:00 2001 From: "Adrien Widart (awt)" Date: Thu, 12 Oct 2023 08:49:42 +0000 Subject: [PATCH] [FIX] stock: update picking type sequences Suppose a picking type in company C1 that uses a sequence in company C2. If a user then tries to install mrp/pos, it will lead to a Server Error because at some point, we write on the picking type: https://github.com/odoo/odoo/blob/c02df957d9f04c911f330aaaadd80fe97a601509/addons/stock/models/stock_warehouse.py#L332 It will trigger the company checking and lead to the error https://github.com/odoo/odoo/blob/a32c98beb5d57c3af481558c6db08767e9258959/odoo/models.py#L3548 When updating the picking types, we should also update the sequences to ensure the data consistency. OPW-3501199 closes odoo/odoo#138710 X-original-commit: 2ad97c6aeda86e4fed7573fb395b25adae935610 Signed-off-by: William Henrotin (whe) Signed-off-by: Adrien Widart (awt) --- addons/stock/models/stock_warehouse.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/stock/models/stock_warehouse.py b/addons/stock/models/stock_warehouse.py index dc2748a7ca8..5d73c443813 100644 --- a/addons/stock/models/stock_warehouse.py +++ b/addons/stock/models/stock_warehouse.py @@ -349,6 +349,7 @@ class Warehouse(models.Model): for picking_type, values in data.items(): if self[picking_type]: + self[picking_type].sudo().sequence_id.write(sequence_data[picking_type]) self[picking_type].write(values) else: data[picking_type].update(create_data[picking_type])