Permalink
Browse files

[FIX] account: Validation error not raising.

In an account_bank_statement, when the type of the journal wasn't bank
and the currency was not defined (the currency in account_bank_statement
is optional) and the amount was zero.

Before this commit, the validation error that raise when the amount is
zero, wasn't working. This because, self.currency_id.is_zero is always
False, when currency is not defined.

Now, we take into account if currency is defined.
  • Loading branch information...
jpp-odoo committed Jan 31, 2019
1 parent 026e5f2 commit a49e11c36bdd4f209e465861df3605fed7c44f40
Showing with 4 additions and 1 deletion.
  1. +4 −1 addons/account/models/account_bank_statement.py
@@ -315,7 +315,10 @@ class AccountBankStatementLine(models.Model):
def _check_amount(self):
# Allow to enter bank statement line with an amount of 0,
# so that user can enter/import the exact bank statement they have received from their bank in Odoo
if self.journal_id.type != 'bank' and self.currency_id.is_zero(self.amount):
if self.journal_id.type != 'bank' and (
(self.currency_id and self.currency_id.is_zero(self.amount))
or self.amount == 0
):
raise ValidationError(_('The amount of a cash transaction cannot be 0.'))

@api.one

0 comments on commit a49e11c

Please sign in to comment.