From 45d2f1d971b29ac12f62f05a12ec3279e978c21c Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Tue, 18 Jul 2023 15:23:55 +0000 Subject: [PATCH] [FIX] product: archive pricelist when linked currency is archived X-original-commit: 643d63396026c53f30b819382d8b8c48899ef507 Part-of: odoo/odoo#128958 --- addons/product/models/res_currency.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/product/models/res_currency.py b/addons/product/models/res_currency.py index fe23deba606..584ad931b32 100644 --- a/addons/product/models/res_currency.py +++ b/addons/product/models/res_currency.py @@ -14,3 +14,12 @@ class ResCurrency(models.Model): group_user = self.env.ref('base.group_user').sudo() group_user._apply_group(self.env.ref('product.group_product_pricelist')) self.env['res.company']._activate_or_create_pricelists() + + def write(self, vals): + """ Archive pricelist when the linked currency is archived. """ + res = super().write(vals) + + if self and 'active' in vals and not vals['active']: + self.env['product.pricelist'].search([('currency_id', 'in', self.ids)]).action_archive() + + return res