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 May 24, 2024
1 parent 6865227 commit 457e218
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
2 changes: 1 addition & 1 deletion l10n_ar_sale/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
'name': 'Argentinian Sale Total Fields',
'version': "17.0.1.1.0",
'version': "17.0.1.2.0",
'category': 'Localization/Argentina',
'sequence': 14,
'author': 'ADHOC SA',
Expand Down
42 changes: 32 additions & 10 deletions l10n_ar_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,38 @@ def _get_sale_checkbook(self):
)

@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')
return super(SaleOrder, self).create(vals)
def create(self, vals_list):
for value in vals_list:
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and value.get("sale_checkbook_id"):
sale_checkbook = self.env["sale.checkbook"].browse(value["sale_checkbook_id"])
if sale_checkbook.sequence_id:
value["name"] = sale_checkbook.sequence_id.next_by_id() or _('New')
return super(SaleOrder, self).create(vals_list)

@api.onchange('partner_id', 'sale_checkbook_id')
def set_order_sequence(self):
"""
Este metodo muestra en el momento de crear la OV la secuencia del talonario
"""
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and self.sale_checkbook_id:
number_next = self.sale_checkbook_id.sequence_id.number_next_actual
self.name = self.sale_checkbook_id.sequence_id.get_next_char(number_next)

def write(self, vals):
"""
Un talonario de ventas podría tener una secuencia de orden diferente, por lo que podríamos
necesitar cambiarlo en consecuencia
"""
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and self.sale_checkbook_id:
sale_checkbook = self.sale_checkbook_id
if sale_checkbook.sequence_id:
for record in self:
if record.state in {"draft", "sent"}:
number_next = sale_checkbook.sequence_id.number_next_actual
new_vals = vals.copy()
new_vals["name"] = sale_checkbook.sequence_id.get_next_char(number_next) or _('New')
return super(SaleOrder, record).write(new_vals)
return super(SaleOrder, self).write(vals)

def _compute_tax_totals(self):
""" Mandamos en contexto el invoice_date para calculo de impuesto con partner aliquot
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 457e218

Please sign in to comment.