Skip to content

Commit

Permalink
[FIX] l10n_ar_sale: Sale sequence
Browse files Browse the repository at this point in the history
Depending on both sale checkbook and sale order type

Ticket 85984 and 86018

X-original-commit: d8c7a4d
  • Loading branch information
zaoral committed Jan 17, 2025
1 parent 02f9d81 commit c454b8e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions l10n_ar_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,52 @@ def _get_sale_checkbook(self):
@api.model_create_multi
def create(self, vals):
for val in vals:
<<<<<<< HEAD
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')
||||||| parent of 00bcf47 (temp)
sale_checkbook_id = val.get('sale_checkbook_id')
sale_checkbook_type = val.get('type_id')
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and \
val.get('name', _('New')) == _('New') and \
sale_checkbook_id:
sale_checkbook = self.env['sale.checkbook'].browse(
sale_checkbook_id)
val['name'] = sale_checkbook.sequence_id and\
sale_checkbook.sequence_id._next() or _('New')
elif sale_checkbook_type and not sale_checkbook_id:
sale_checkbook_from_type = self.env['sale.order.type'].browse(sale_checkbook_type).sale_checkbook_id
# Obtenemos el talonario asociado al tipo de venta, esto lo utilizamos si la venta viene de website
# O el usuario no tiene acceso a los talonarios de venta
val['name'] = sale_checkbook_from_type and sale_checkbook_from_type.sequence_id and\
sale_checkbook_from_type.sequence_id._next() or _('New')
=======
if val.get('name', _('New')) == _('New'):
sale_checkbook_id = val.get('sale_checkbook_id')
sale_order_type = val.get('type_id')

use_checkbook = self.sudo().env.ref('l10n_ar_sale.use_sale_checkbook').users
object_model = False
object_id = False
if use_checkbook and sale_checkbook_id:
object_model = 'sale.checkbook'
object_id = sale_checkbook_id
elif (use_checkbook and not sale_checkbook_id and sale_order_type) and \
(not use_checkbook and sale_order_type):
object_model = 'sale.order.type'
object_id = sale_order_type

if object_model and object_id:
object_record = self.env[object_model].browse(object_id)
val['name'] = object_record.sequence_id and \
object_record.sequence_id._next() or _('New')

>>>>>>> 00bcf47 (temp)
return super(SaleOrder, self).create(vals)

def write(self, vals):
Expand Down

0 comments on commit c454b8e

Please sign in to comment.