Skip to content

Commit

Permalink
[FIX] account_payment_group_document: Default receiptbook on payment …
Browse files Browse the repository at this point in the history
…groups

closes #372

Signed-off-by: pablohmontenegro <[email protected]>
  • Loading branch information
zaoral committed Jun 7, 2023
1 parent 546415c commit 4979b0b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions account_payment_group_document/models/account_payment_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,22 @@ def _get_receiptbook(self):
self.ensure_one()
partner_type = self.partner_type or self._context.get(
'partner_type', self._context.get('default_partner_type', False))
receiptbook = self.env[
'account.payment.receiptbook'].search([
('partner_type', '=', partner_type),
('company_id', '=', self.company_id.id),
], limit=1)

# Toma en cuenta si el usuario tiene definido o no un talonario por
# defecto, si es asi usa ese.
receiptbook = self.receiptbook_id
if not receiptbook:
receiptbook = self.default_get(['receiptbook_id']).get('receiptbook_id')

# Si no hay talonario por defecto, o si el talonario no coincide con el
# del tipo de grupo de pago (cobro/pago) obtenemos nuestro el primer
# elemento via un search
if not receiptbook or (receiptbook.partner_type != partner_type):
receiptbook = self.env[
'account.payment.receiptbook'].search([
('partner_type', '=', partner_type),
('company_id', '=', self.company_id.id),
], limit=1)
return receiptbook

def post(self):
Expand Down

0 comments on commit 4979b0b

Please sign in to comment.