l10n-switzerland-flectra/l10n_ch_isr_payment_grouping/wizard/account_payment_register.py
Raphael Ritter 22ee40100d [FIX] Multiple modules which had wrong dependencies
[FIX] l10n_ch_zip
[ADD] Added latest OCA Modules
[REMOVE] Removed QR modules which are not required anymore
2021-11-17 14:48:42 +01:00

34 lines
1.2 KiB
Python

# Copyright 2020 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from flectra import api, models
class PaymentRegister(models.TransientModel):
_inherit = "account.payment.register"
@api.model
def _get_batch_communication(self, batch_result):
"""Return a single ISR reference
to avoid duplicate of the same number when multiple payments are done
on the same reference. As those payments are grouped by reference,
we want a unique reference in communication.
"""
# Only the first invoice needs to be tested as the grouping ensure
# invoice with same ISR are in the same group.
invoice = batch_result["lines"][0].move_id
if invoice._is_isr_supplier_invoice():
return invoice.payment_reference or invoice.ref
else:
return super()._get_batch_communication(batch_result)
def _get_line_batch_key(self, line):
move = line.move_id
result = super()._get_line_batch_key(line)
if move._is_isr_supplier_invoice():
result.update(
{
"payment_reference": move.payment_reference or line.ref,
}
)
return result