From 081a0eda43f37dbb8f2e9ee3da20f4dad13ce17d Mon Sep 17 00:00:00 2001 From: docker-odoo Date: Tue, 6 Aug 2024 13:26:56 +0000 Subject: [PATCH] [FIX] l10n_ar_sale_order_type: Fix para que se setee correctamente la secuencia de la orden de venta Ticket: 78413 --- l10n_ar_sale/models/sale_order.py | 17 +++++++++++------ l10n_ar_sale_order_type/models/sale_order.py | 3 ++- 2 files changed, 13 insertions(+), 7 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. """ diff --git a/l10n_ar_sale_order_type/models/sale_order.py b/l10n_ar_sale_order_type/models/sale_order.py index 56bd7229..96382884 100644 --- a/l10n_ar_sale_order_type/models/sale_order.py +++ b/l10n_ar_sale_order_type/models/sale_order.py @@ -29,8 +29,9 @@ def write(self, vals): record.state in {"draft", "sent"} and record.type_id.sequence_id != sale_checkbook.sequence_id ): + number_next = sale_checkbook.sequence_id.number_next_actual new_vals = vals.copy() - new_vals["name"] = sale_checkbook.sequence_id._next() or _('New') + new_vals["name"] = sale_checkbook.sequence_id.get_next_char(number_next) super(SaleOrder, record).write(new_vals) else: super(SaleOrder, record).write(vals)