From 158e7368d61aa66e9aad41aa42f3639a667e4ec2 Mon Sep 17 00:00:00 2001 From: Maximiliano Mezzavilla Date: Wed, 22 May 2024 11:01:47 -0300 Subject: [PATCH] [ADD] l10n_ar_sale: Tomamos la secuencia de los talonarios Task: 72835 --- l10n_ar_sale/models/sale_order.py | 18 +++++++++++------- l10n_ar_sale/views/sale_view.xml | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/l10n_ar_sale/models/sale_order.py b/l10n_ar_sale/models/sale_order.py index 1226a2bd..caf1b352 100644 --- a/l10n_ar_sale/models/sale_order.py +++ b/l10n_ar_sale/models/sale_order.py @@ -54,18 +54,22 @@ def _get_sale_checkbook(self): self.env['sale.checkbook'].search([('company_id', 'in', [self.company_id.id, False])], limit=1) ) - @api.model_create_multi 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/views/sale_view.xml b/l10n_ar_sale/views/sale_view.xml index 6fb9df65..31db1c10 100644 --- a/l10n_ar_sale/views/sale_view.xml +++ b/l10n_ar_sale/views/sale_view.xml @@ -17,7 +17,7 @@ - +