From 2cdfe17a5eb6966fb185c117af68c2612c7d2531 Mon Sep 17 00:00:00 2001 From: Matias Peralta Date: Tue, 13 Aug 2024 15:43:00 -0300 Subject: [PATCH] [FIX] l10n_ar_sale: compute of sale_checkbook_id fixed --- l10n_ar_sale/models/sale_order.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/l10n_ar_sale/models/sale_order.py b/l10n_ar_sale/models/sale_order.py index 227024b..71bc9a8 100644 --- a/l10n_ar_sale/models/sale_order.py +++ b/l10n_ar_sale/models/sale_order.py @@ -42,11 +42,18 @@ def _compute_vat_discriminated(self): @api.depends('company_id') def _compute_sale_checkbook(self): for rec in self: + if rec.sale_checkbook_id: + continue if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and rec.company_id: rec.sale_checkbook_id = rec._get_sale_checkbook() else: rec.sale_checkbook_id = False + @api.onchange("company_id") + def _onchange_sale_checkbook(self): + if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and self.company_id: + self.sale_checkbook_id = self._get_sale_checkbook() + def _get_sale_checkbook(self): return ( self.env['ir.default'].get('sale.order', 'sale_checkbook_id', company_id=self.company_id.id, user_id=self.env.user.id) or