mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[IMP] account_banking_mandate: Set sequence when creating a mandate with empty mandate reference
TT50317
This commit is contained in:
@@ -176,8 +176,7 @@ class AccountBankingMandate(models.Model):
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
for vals in vals_list:
|
||||
unique_mandate_reference = vals.get("unique_mandate_reference", "/")
|
||||
if unique_mandate_reference == "/":
|
||||
if (vals.get("unique_mandate_reference") or "/") == "/":
|
||||
vals["unique_mandate_reference"] = (
|
||||
self.env["ir.sequence"].next_by_code("account.banking.mandate")
|
||||
or "New"
|
||||
|
||||
@@ -170,3 +170,28 @@ class TestMandate(TransactionCase):
|
||||
}
|
||||
)
|
||||
self.assertTrue(mandate.unique_mandate_reference)
|
||||
|
||||
def test_mandate_reference_06(self):
|
||||
"""
|
||||
Test case: create a mandate with False as reference (empty with UX)
|
||||
Expected result: the reference of the created mandate is not False
|
||||
"""
|
||||
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
|
||||
mandate_1 = self.env["account.banking.mandate"].create(
|
||||
{
|
||||
"partner_bank_id": bank_account.id,
|
||||
"signature_date": "2015-01-01",
|
||||
"company_id": self.company.id,
|
||||
"unique_mandate_reference": False,
|
||||
}
|
||||
)
|
||||
self.assertTrue(mandate_1.unique_mandate_reference)
|
||||
mandate_2 = self.env["account.banking.mandate"].create(
|
||||
{
|
||||
"partner_bank_id": bank_account.id,
|
||||
"signature_date": "2015-01-01",
|
||||
"company_id": self.company.id,
|
||||
"unique_mandate_reference": "",
|
||||
}
|
||||
)
|
||||
self.assertTrue(mandate_2.unique_mandate_reference)
|
||||
|
||||
Reference in New Issue
Block a user