Store payable bank account number on SEPA payment
This allows the user to select the bank account to use for the payment instead of the first IBAN. Also it stores the bank account that was selected by default on processing. Closes #13938
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Store payable bank account number
|
||||
* Remove support for Python 3.8
|
||||
* Add support for Python 3.13
|
||||
* Allow messages to be downloaded at once
|
||||
|
||||
@@ -232,6 +232,12 @@ class Group(metaclass=PoolMeta):
|
||||
payment.sepa_mandate = mandate
|
||||
payment.sepa_mandate_sequence_type = sequence_type
|
||||
Payment.save(payments)
|
||||
elif self.kind == 'payable':
|
||||
for payment in self.payments:
|
||||
if not payment.sepa_payable_bank_account_number:
|
||||
payment.sepa_payable_bank_account_number = (
|
||||
payment.sepa_bank_account_number)
|
||||
Payment.save(self.payments)
|
||||
for payment in self.payments:
|
||||
if not payment.sepa_bank_account_number:
|
||||
raise ProcessError(
|
||||
@@ -329,6 +335,17 @@ class Group(metaclass=PoolMeta):
|
||||
class Payment(metaclass=PoolMeta):
|
||||
__name__ = 'account.payment'
|
||||
|
||||
sepa_payable_bank_account_number = fields.Many2One(
|
||||
'bank.account.number', "Bank Account Number",
|
||||
states={
|
||||
'invisible': (
|
||||
(Eval('process_method') != 'sepa')
|
||||
| (Eval('kind') != 'payable')),
|
||||
},
|
||||
domain=[
|
||||
('type', '=', 'iban'),
|
||||
('account.owners', '=', Eval('party', -1)),
|
||||
])
|
||||
sepa_mandate = fields.Many2One('account.payment.sepa.mandate', 'Mandate',
|
||||
ondelete='RESTRICT',
|
||||
states={
|
||||
@@ -427,6 +444,8 @@ class Payment(metaclass=PoolMeta):
|
||||
if self.kind == 'receivable':
|
||||
if self.sepa_mandate:
|
||||
return self.sepa_mandate.account_number
|
||||
elif self.sepa_payable_bank_account_number:
|
||||
return self.sepa_payable_bank_account_number
|
||||
else:
|
||||
for account in self.party.bank_accounts_used:
|
||||
for number in account.numbers:
|
||||
|
||||
@@ -275,11 +275,19 @@ class AccountPaymentSepaTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
numbers=[other_account_number, iban_account_number])
|
||||
party = Party(
|
||||
bank_accounts_used=[bank_account])
|
||||
payment = Payment(kind='payable', party=party)
|
||||
payment = Payment(
|
||||
kind='payable', party=party,
|
||||
sepa_payable_bank_account_number=None)
|
||||
|
||||
self.assertEqual(id(payment.sepa_bank_account_number),
|
||||
id(iban_account_number))
|
||||
|
||||
payment.sepa_payable_bank_account_number = iban_account_number
|
||||
party.bank_accounts_used = []
|
||||
self.assertEqual(
|
||||
payment.sepa_bank_account_number,
|
||||
iban_account_number)
|
||||
|
||||
@with_transaction()
|
||||
def test_payment_sequence_type(self):
|
||||
'Test payment sequence type'
|
||||
|
||||
@@ -6,8 +6,14 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<page id="sepa" string="SEPA">
|
||||
<label name="sepa_mandate"/>
|
||||
<field name="sepa_mandate"/>
|
||||
<newline/>
|
||||
|
||||
<label name="sepa_payable_bank_account_number"/>
|
||||
<field name="sepa_payable_bank_account_number"/>
|
||||
<newline/>
|
||||
|
||||
<label name="sepa_info_id"/>
|
||||
<field name="sepa_info_id"/>
|
||||
<field name="sepa_info_id" colspan="3"/>
|
||||
|
||||
<separator id="sepa_return_reason" string="Return Reason" colspan="4"/>
|
||||
<label name="sepa_return_reason_code" string="Code"/>
|
||||
|
||||
Reference in New Issue
Block a user