[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
This commit is contained in:
Denis Ledoux
2016-02-25 12:56:57 +01:00
parent b9f206953e
commit 4a65bc384e
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -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
+2
View File
@@ -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