Skip to content

Commit 158e736

Browse files
committed
[ADD] l10n_ar_sale: Tomamos la secuencia de los talonarios
Task: 72835
1 parent 8b68a57 commit 158e736

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

l10n_ar_sale/models/sale_order.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,22 @@ def _get_sale_checkbook(self):
5454
self.env['sale.checkbook'].search([('company_id', 'in', [self.company_id.id, False])], limit=1)
5555
)
5656

57-
@api.model_create_multi
5857
def create(self, vals):
5958
for val in vals:
6059
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and \
61-
val.get('name', _('New')) == _('New') and \
62-
val.get('sale_checkbook_id'):
63-
sale_checkbook = self.env['sale.checkbook'].browse(
64-
val.get('sale_checkbook_id'))
65-
val['name'] = sale_checkbook.sequence_id and\
66-
sale_checkbook.sequence_id._next() or _('New')
60+
val.get('sale_checkbook_id'):
61+
sale_checkbook = self.env['sale.checkbook'].browse(val.get('sale_checkbook_id'))
62+
number_next = sale_checkbook.sequence_id.number_next_actual
63+
val['name'] = sale_checkbook.sequence_id.get_next_char(number_next) or _('New')
6764
return super(SaleOrder, self).create(vals)
6865

66+
def action_confirm(self):
67+
#Consumimos un numero de la secuencia solamente cuando confirmamos la orden de venta
68+
if self.sale_checkbook_id:
69+
self.name = self.sale_checkbook_id.sequence_id._next()
70+
71+
return super().action_confirm()
72+
6973
def _compute_tax_totals(self):
7074
""" Mandamos en contexto el invoice_date para calculo de impuesto con partner aliquot
7175
ver módulo l10n_ar_account_withholding. """

l10n_ar_sale/views/sale_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<!-- <field name="currency_id" invisible="1"/> -->
1818
</xpath>
1919
<field name="payment_term_id" position="before">
20-
<field name="sale_checkbook_id" domain="[('company_id','in', [company_id, False])]" groups="l10n_ar_sale.use_sale_checkbook" readonly="state not in ['draft', 'sent']"/>
20+
<field name="sale_checkbook_id" domain="[('company_id','in', [company_id, False])]" groups="l10n_ar_sale.use_sale_checkbook" readonly="state not in ['draft', 'sent']" force_save="1"/>
2121
</field>
2222
</field>
2323
</record>

0 commit comments

Comments
 (0)