Skip to content

Commit

Permalink
[ADD] l10n_ar_sale: Tomamos la secuencia de los talonarios
Browse files Browse the repository at this point in the history
Task: 72835
  • Loading branch information
mem-adhoc committed Aug 8, 2024
1 parent 8b68a57 commit 158e736
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions l10n_ar_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """
Expand Down
2 changes: 1 addition & 1 deletion l10n_ar_sale/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- <field name="currency_id" invisible="1"/> -->
</xpath>
<field name="payment_term_id" position="before">
<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']"/>
<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"/>
</field>
</field>
</record>
Expand Down

0 comments on commit 158e736

Please sign in to comment.