trytond-patches/issue9797.diff
Albert Cervera i Areny 91e1a8e791 Add patch for issue9797.
2020-11-06 10:41:23 +01:00

33 lines
1.6 KiB
Diff

index ac29d17..2b240c1 100644
--- a/trytond/trytond/modules/account_payment_sepa/payment.py
+++ b/trytond/trytond/modules/account_payment_sepa/payment.py
@@ -190,18 +190,23 @@ class Group(metaclass=PoolMeta):
Payment = pool.get('account.payment')
if self.kind == 'receivable':
mandates = Payment.get_sepa_mandates(self.payments)
+ sequence_types = {}
for payment, mandate in zip(self.payments, mandates):
if not mandate:
raise ProcessError(
gettext('account_payment_sepa'
'.msg_payment_process_no_mandate',
payment=payment.rec_name))
- # Write one by one because mandate.sequence_type must be
- # recomputed each time
- Payment.write([payment], {
- 'sepa_mandate': mandate,
- 'sepa_mandate_sequence_type': mandate.sequence_type,
- })
+ sequence_type = sequence_types.get(mandate)
+ if not sequence_type:
+ sequence_type = mandate.sequence_type
+ if sequence_type == 'FRST':
+ sequence_types[mandate] = 'RCUR'
+ else:
+ sequence_types[mandate] = sequence_type
+ payment.sepa_mandate = mandate
+ payment.sepa_mandate_sequence_type = sequence_type
+ Payment.save(self.payments)
else:
for payment in self.payments:
if not payment.sepa_bank_account_number: