Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] account_banking_mandate: Allow to set a specific mandate reference or sequence + multi-company compatibility #1190

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<field name="code">account.banking.mandate</field>
<field name="prefix">BM</field>
<field name="padding" eval="7" />
<field name="company_id" eval="False" />
</record>
</odoo>
6 changes: 3 additions & 3 deletions account_banking_mandate/models/account_banking_mandate.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _get_default_partner_bank_id_domain(self):
required=True,
default=lambda self: self.env.company,
)
unique_mandate_reference = fields.Char(tracking=10, copy=False)
unique_mandate_reference = fields.Char(tracking=10, copy=False, default="/")
signature_date = fields.Date(
string="Date of Signature of the Mandate",
tracking=50,
Expand Down Expand Up @@ -176,8 +176,8 @@ def _check_valid_state(self):
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
unique_mandate_reference = vals.get("unique_mandate_reference")
if not unique_mandate_reference or unique_mandate_reference == "New":
unique_mandate_reference = vals.get("unique_mandate_reference", "/")
if unique_mandate_reference == "/":
vals["unique_mandate_reference"] = (
self.env["ir.sequence"].next_by_code("account.banking.mandate")
or "New"
Expand Down
23 changes: 11 additions & 12 deletions account_banking_mandate/tests/test_mandate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,41 +124,41 @@ def test_mandate_reference_02(self):

def test_mandate_reference_03(self):
"""
Test case: create a mandate with "New" as reference
Expected result: the reference of the created mandate is not empty and
is not "New"
Test case: create a mandate with "TEST" as reference
Expected result: the reference of the created mandate is "TEST"
"""
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
mandate = 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": "New",
"unique_mandate_reference": "TEST",
}
)
self.assertTrue(mandate.unique_mandate_reference)
self.assertNotEqual(mandate.unique_mandate_reference, "New")
self.assertEqual(mandate.unique_mandate_reference, "TEST")

def test_mandate_reference_05(self):
def test_mandate_reference_04(self):
"""
Test case: create a mandate with False as reference
Expected result: the reference of the created mandate is not empty
Test case: create a mandate with "/" as reference
Expected result: the reference of the created mandate is not "/"
"""
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
mandate = 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,
"unique_mandate_reference": "/",
}
)
self.assertTrue(mandate.unique_mandate_reference)
self.assertNotEqual(mandate.unique_mandate_reference, "/")

def test_mandate_reference_06(self):
def test_mandate_reference_05(self):
"""
Test case: create a mandate with a empty string as reference
Test case: create a mandate without reference
Expected result: the reference of the created mandate is not empty
"""
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
Expand All @@ -167,7 +167,6 @@ def test_mandate_reference_06(self):
"partner_bank_id": bank_account.id,
"signature_date": "2015-01-01",
"company_id": self.company.id,
"unique_mandate_reference": "",
}
)
self.assertTrue(mandate.unique_mandate_reference)
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<field
name="unique_mandate_reference"
class="oe_inline"
readonly="1"
attrs="{'readonly': [('id', '!=', False)]}"
/>
</h1>
</div>
Expand Down
Loading