From b4e80e9a350a76f8f51e88dbc5b84daca045ee0c Mon Sep 17 00:00:00 2001 From: Maximiliano Mezzavilla Date: Wed, 7 Aug 2024 17:16:26 -0300 Subject: [PATCH] [FIX] l10n_ar_sale_order: Fix para que se setee correctamente la secuencia de la orden de venta --- l10n_ar_sale/models/sale_order.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/l10n_ar_sale/models/sale_order.py b/l10n_ar_sale/models/sale_order.py index 227024ba..c294860b 100644 --- a/l10n_ar_sale/models/sale_order.py +++ b/l10n_ar_sale/models/sale_order.py @@ -59,14 +59,19 @@ def _get_sale_checkbook(self): def create(self, vals): for val in vals: if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and \ - val.get('name', _('New')) == _('New') and \ - val.get('sale_checkbook_id'): - sale_checkbook = self.env['sale.checkbook'].browse( - val.get('sale_checkbook_id')) - val['name'] = sale_checkbook.sequence_id and\ - sale_checkbook.sequence_id._next() or _('New') + val.get('sale_checkbook_id'): + sale_checkbook = self.env['sale.checkbook'].browse(val.get('sale_checkbook_id')) + number_next = sale_checkbook.sequence_id.number_next_actual + val['name'] = sale_checkbook.sequence_id.get_next_char(number_next) or _('New') return super(SaleOrder, self).create(vals) + def action_confirm(self): + #Consumimos un numero de la secuencia solamente cuando confirmamos la orden de venta + if self.sale_checkbook_id: + self.name = self.sale_checkbook_id.sequence_id._next() + + return super().action_confirm() + def _compute_tax_totals(self): """ Mandamos en contexto el invoice_date para calculo de impuesto con partner aliquot ver módulo l10n_ar_account_withholding. """