From e38606992a01136cb437b983e9561960c20c386d Mon Sep 17 00:00:00 2001 From: "matthieu.saison" Date: Thu, 15 Feb 2024 18:08:46 +0100 Subject: [PATCH] apply code review --- .../models/account_journal.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/account_journal_display_type/models/account_journal.py b/account_journal_display_type/models/account_journal.py index 904e6ef..677ff2b 100644 --- a/account_journal_display_type/models/account_journal.py +++ b/account_journal_display_type/models/account_journal.py @@ -14,7 +14,6 @@ class AccountJournal(models.Model): ("general", "Miscellaneous"), ], required=True, - inverse="_inverse_type", help="Select 'Sale' for customer invoices journals.\n" "Select 'Purchase' for vendor bills journals.\n" "Select 'Cash' or 'Bank' for journals that are used in customer or vendor payments.\n" @@ -29,7 +28,13 @@ class AccountJournal(models.Model): ) payment_debit_account_id = fields.Many2one( comodel_name="account.account", - compute="_compute_payment_debit_account_id", + compute="_compute_payment_account_id", + readonly=False, + store=True, + ) + payment_credit_account_id = fields.Many2one( + comodel_name="account.account", + compute="_compute_payment_account_id", readonly=False, store=True, ) @@ -49,7 +54,7 @@ class AccountJournal(models.Model): record.default_account_id = record.payment_debit_account_id @api.depends("display_type", "default_account_id") - def _compute_payment_debit_account_id(self): + def _compute_payment_account_id(self): for record in self: if record.type == "cash": record.payment_debit_account_id = record.default_account_id @@ -61,7 +66,7 @@ class AccountJournal(models.Model): # this code bypass this behavior if vals.get("display_type") == "payment": vals["default_account_id"] = True - if vals.get("display_type") == "cash": + elif vals.get("display_type") == "cash": vals["payment_debit_account_id"] = True vals["payment_credit_account_id"] = True super()._fill_missing_values(vals) @@ -70,6 +75,6 @@ class AccountJournal(models.Model): # allow journal creation if display_type not define if not vals.get("display_type"): vals["display_type"] = vals["type"] - if vals.get("display_type") == "cash": + elif vals.get("display_type") == "cash": vals.pop("payment_debit_account_id") vals.pop("payment_credit_account_id")