[FIX] product: archive pricelist when linked currency is archived

X-original-commit: 643d63396026c53f30b819382d8b8c48899ef507
Part-of: odoo/odoo#128958
This commit is contained in:
Victor Feyens
2023-07-18 21:48:39 +02:00
parent c6fb5793c5
commit 45d2f1d971
+9
View File
@@ -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