Skip to content

Commit

Permalink
[FIX] l10n_ar_sale_order_type: Fix para que se setee correctamente la…
Browse files Browse the repository at this point in the history
… secuencia de la orden de venta
  • Loading branch information
mem-adhoc committed Aug 28, 2024
1 parent f068874 commit d68f796
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions l10n_ar_sale_order_type/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,7 @@
class SaleOrder(models.Model):
_inherit = "sale.order"

def _compute_sale_checkbook(self):
super()._compute_sale_checkbook()
for order in self.filtered(lambda x: x.type_id and x.type_id.sale_checkbook_id):
order.sale_checkbook_id = order.type_id.sale_checkbook_id

@api.onchange('type_id')
def _onchange_sale_checkbook_id(self):
if self.type_id and self.type_id.sale_checkbook_id:
self.sale_checkbook_id = self.type_id.sale_checkbook_id

def write(self, vals):
"""A sale checkbook could have a different order sequence, so we could
need to change it accordingly"""
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and vals.get('sale_checkbook_id'):
sale_checkbook = self.env['sale.checkbook'].browse(vals['sale_checkbook_id'])
if sale_checkbook.sequence_id:
for record in self:
if record.sale_checkbook_id != sale_checkbook and (
record.state in {"draft", "sent"}
and record.type_id.sequence_id != sale_checkbook.sequence_id
):
new_vals = vals.copy()
new_vals["name"] = sale_checkbook.sequence_id._next() or _('New')
super(SaleOrder, record).write(new_vals)
else:
super(SaleOrder, record).write(vals)
return True
return super().write(vals)

0 comments on commit d68f796

Please sign in to comment.