Skip to content

Commit

Permalink
[IMP] l10n_ar_sale: the checkbook is set by searching first for the p…
Browse files Browse the repository at this point in the history
…roperties

closes #153

Signed-off-by: matiasperalta1 <mnp@adhoc.com.ar>
  • Loading branch information
lef-adhoc committed Mar 6, 2024
1 parent 62320bb commit 85351fd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions l10n_ar_sale/models/sale_order.py
Expand Up @@ -41,11 +41,18 @@ def _compute_vat_discriminated(self):
def set_sale_checkbook(self):
if self.env.user.has_group('l10n_ar_sale.use_sale_checkbook') and \
self.company_id:
self.sale_checkbook_id = self.env['sale.checkbook'].search(
[('company_id', 'in', [self.company_id.id, False])], limit=1)
self.sale_checkbook_id = self._get_sale_checkbook()
else:
self.sale_checkbook_id = False

def _get_sale_checkbook(self):
return (
self.env['ir.default'].get('sale.order', 'sale_checkbook_id', company_id=self.company_id.id, user_id=self.env.user.id) or
self.env['ir.default'].get('sale.order', 'sale_checkbook_id', user_id=self.env.user.id) or
self.env['ir.default'].get('sale.order', 'sale_checkbook_id') or
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:
Expand Down

0 comments on commit 85351fd

Please sign in to comment.