Skip to content

Commit e386069

Browse files
author
matthieu.saison
committed
apply code review
1 parent c89f1b7 commit e386069

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

account_journal_display_type/models/account_journal.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class AccountJournal(models.Model):
1414
("general", "Miscellaneous"),
1515
],
1616
required=True,
17-
inverse="_inverse_type",
1817
help="Select 'Sale' for customer invoices journals.\n"
1918
"Select 'Purchase' for vendor bills journals.\n"
2019
"Select 'Cash' or 'Bank' for journals that are used in customer or vendor payments.\n"
@@ -29,7 +28,13 @@ class AccountJournal(models.Model):
2928
)
3029
payment_debit_account_id = fields.Many2one(
3130
comodel_name="account.account",
32-
compute="_compute_payment_debit_account_id",
31+
compute="_compute_payment_account_id",
32+
readonly=False,
33+
store=True,
34+
)
35+
payment_credit_account_id = fields.Many2one(
36+
comodel_name="account.account",
37+
compute="_compute_payment_account_id",
3338
readonly=False,
3439
store=True,
3540
)
@@ -49,7 +54,7 @@ def _compute_default_account_id(self):
4954
record.default_account_id = record.payment_debit_account_id
5055

5156
@api.depends("display_type", "default_account_id")
52-
def _compute_payment_debit_account_id(self):
57+
def _compute_payment_account_id(self):
5358
for record in self:
5459
if record.type == "cash":
5560
record.payment_debit_account_id = record.default_account_id
@@ -61,7 +66,7 @@ def _fill_missing_values(self, vals):
6166
# this code bypass this behavior
6267
if vals.get("display_type") == "payment":
6368
vals["default_account_id"] = True
64-
if vals.get("display_type") == "cash":
69+
elif vals.get("display_type") == "cash":
6570
vals["payment_debit_account_id"] = True
6671
vals["payment_credit_account_id"] = True
6772
super()._fill_missing_values(vals)
@@ -70,6 +75,6 @@ def _fill_missing_values(self, vals):
7075
# allow journal creation if display_type not define
7176
if not vals.get("display_type"):
7277
vals["display_type"] = vals["type"]
73-
if vals.get("display_type") == "cash":
78+
elif vals.get("display_type") == "cash":
7479
vals.pop("payment_debit_account_id")
7580
vals.pop("payment_credit_account_id")

0 commit comments

Comments
 (0)