Skip to content

Commit

Permalink
[IMP] l10n_it_ricevute_bancarie: fall back on commercial partner's bank
Browse files Browse the repository at this point in the history
If creating an invoice with C/O for a contact without a bank,
fall back on the commercial partner's bank.
  • Loading branch information
aleuffre committed Aug 2, 2024
1 parent 1a3f1b5 commit e62fac0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions l10n_it_ricevute_bancarie/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,20 @@ def create(self, vals):

@api.onchange("partner_id", "invoice_payment_term_id", "move_type")
def _onchange_riba_partner_bank_id(self):
allowed_banks = (
self.partner_id.bank_ids or self.partner_id.commercial_partner_id.bank_ids
)
if (
not self.riba_partner_bank_id
or self.riba_partner_bank_id not in self.partner_id.bank_ids
or self.riba_partner_bank_id not in allowed_banks
):
bank_ids = self.env["res.partner.bank"]
if (
self.partner_id
and self.invoice_payment_term_id.riba
and self.is_riba_payment
and self.move_type in ["out_invoice", "out_refund"]
):
bank_ids = self.partner_id.bank_ids
bank_ids = allowed_banks
self.riba_partner_bank_id = bank_ids[0] if bank_ids else None

def month_check(self, invoice_date_due, all_date_due):
Expand Down

0 comments on commit e62fac0

Please sign in to comment.