From 4a65bc384e43ffd0ac50662ad4fde2ddffb4fd30 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 25 Feb 2016 12:56:57 +0100 Subject: [PATCH] [FIX] account: better error message when emptying journal account number The account number field on a journal is a related field to the number of the bank account associated to the journal. As the number of a bank account is a required field, any attempt to empty it from the journal fails. Besides, unlinking the bank account from the journal when emptying the account number on the journal form doesn't seem to be the appropriate behavior. Imagine you give an account number to the journal, then empty it, then re-fill it, you probably do not want the journal entries to be associated to a new bank account, you probably wanted the same bank account, but renamed, while it would be the case if we simply unlink it. If you would like to delete the bank account, you have to do it from the bank accounts list itself. opw-670472 --- addons/account/i18n/account.pot | 7 +++++++ addons/account/models/account.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 872507dc297..75326f9b110 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -8799,6 +8799,13 @@ msgid "You cannot do this modification on a reconciled entry. You can just chang "%s." msgstr "" +#. module: account +#: code:addons/account/models/account.py:329 +#, python-format +msgid "You cannot empty the account number once set.\n" +"If you would like to delete the account number, you can do it from the Bank Accounts list." +msgstr "" + #. module: account #: code:addons/account/models/account.py:96 #, python-format diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 36b0077a701..ef521dc7ea3 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -325,6 +325,8 @@ class AccountJournal(models.Model): self.default_debit_account_id.currency_id = vals['currency_id'] if not 'default_credit_account_id' in vals and self.default_credit_account_id: self.default_credit_account_id.currency_id = vals['currency_id'] + if 'bank_acc_number' in vals and not vals.get('bank_acc_number') and journal.bank_account_id: + raise UserError(_('You cannot empty the account number once set.\nIf you would like to delete the account number, you can do it from the Bank Accounts list.')) result = super(AccountJournal, self).write(vals) # Create the bank_account_id if necessary