summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMehul Patel <mep@odoo.com>2017-08-30 12:41:32 +0530
committerLaurent Smet <las@openerp.com>2017-08-30 09:11:32 +0200
commitd8970d05b5ae358161069caf0ebddd6e83ffc818 (patch)
tree9dbeb6c4dc33bc1f4496b153854c95d90e91c06b
parent52decc07fdfd811f68752cfab6be7c9c6ca09497 (diff)
[IMP] account : allow zero amount in bank statement line
task: https://www.odoo.com/web#id=33304&view_type=form&model=project.task&menu_id= PR: #17136
-rw-r--r--addons/account/models/account_bank_statement.py14
-rw-r--r--addons/account/models/account_journal_dashboard.py2
-rw-r--r--addons/account_bank_statement_import/account_bank_statement_import.py6
3 files changed, 9 insertions, 13 deletions
diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py
index 377a39222d6..cdf686b42b0 100644
--- a/addons/account/models/account_bank_statement.py
+++ b/addons/account/models/account_bank_statement.py
@@ -91,7 +91,7 @@ class AccountBankStatement(models.Model):
@api.one
@api.depends('line_ids.journal_entry_ids')
def _check_lines_reconciled(self):
- self.all_lines_reconciled = all([line.journal_entry_ids.ids or line.account_id.id for line in self.line_ids])
+ self.all_lines_reconciled = all([line.journal_entry_ids.ids or line.account_id.id for line in self.line_ids if not self.currency_id.is_zero(line.amount)])
@api.depends('move_line_ids')
def _get_move_line_count(self):
@@ -236,7 +236,7 @@ class AccountBankStatement(models.Model):
for st_line in statement.line_ids:
if st_line.account_id and not st_line.journal_entry_ids.ids:
st_line.fast_counterpart_creation()
- elif not st_line.journal_entry_ids.ids:
+ elif not st_line.journal_entry_ids.ids and not statement.currency_id.is_zero(st_line.amount):
raise UserError(_('All the account entries lines must be processed in order to close the statement.'))
for aml in st_line.journal_entry_ids:
moves |= aml.move_id
@@ -286,7 +286,7 @@ class AccountBankStatement(models.Model):
sql_query = """SELECT stl.id
FROM account_bank_statement_line stl
- WHERE account_id IS NULL AND not exists (select 1 from account_move_line aml where aml.statement_line_id = stl.id)
+ WHERE account_id IS NULL AND stl.amount != 0.0 AND not exists (select 1 from account_move_line aml where aml.statement_line_id = stl.id)
AND company_id = %s
"""
params = (self.env.user.company_id.id,)
@@ -377,10 +377,10 @@ class AccountBankStatementLine(models.Model):
@api.one
@api.constrains('amount')
def _check_amount(self):
- # This constraint could possibly underline flaws in bank statement import (eg. inability to
- # support hacks such as using dummy transactions to give additional informations)
- if self.amount == 0:
- raise ValidationError(_('A transaction can\'t have a 0 amount.'))
+ # 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):
+ raise ValidationError(_('A Cash transaction can\'t have a 0 amount.'))
@api.one
@api.constrains('amount', 'amount_currency')
diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py
index 663d7922236..0753765c4e9 100644
--- a/addons/account/models/account_journal_dashboard.py
+++ b/addons/account/models/account_journal_dashboard.py
@@ -166,7 +166,7 @@ class account_journal(models.Model):
FROM account_bank_statement_line AS line
LEFT JOIN account_bank_statement AS st
ON line.statement_id = st.id
- WHERE st.journal_id IN %s AND st.state = 'open'
+ WHERE st.journal_id IN %s AND st.state = 'open' AND line.amount != 0.0
AND not exists (select 1 from account_move_line aml where aml.statement_line_id = line.id)
""", (tuple(self.ids),))
number_to_reconcile = self.env.cr.fetchone()[0]
diff --git a/addons/account_bank_statement_import/account_bank_statement_import.py b/addons/account_bank_statement_import/account_bank_statement_import.py
index 9056b7af916..afd62cc359b 100644
--- a/addons/account_bank_statement_import/account_bank_statement_import.py
+++ b/addons/account_bank_statement_import/account_bank_statement_import.py
@@ -215,11 +215,7 @@ class AccountBankStatementImport(models.TransientModel):
if 'unique_import_id' not in line_vals \
or not line_vals['unique_import_id'] \
or not bool(BankStatementLine.sudo().search([('unique_import_id', '=', line_vals['unique_import_id'])], limit=1)):
- if line_vals['amount'] != 0:
- # Some banks, like ING, create a line for free charges.
- # We just skip those lines as there's a 'non-zero' constraint
- # on the amount of account.bank.statement.line
- filtered_st_lines.append(line_vals)
+ filtered_st_lines.append(line_vals)
else:
ignored_statement_lines_import_ids.append(line_vals['unique_import_id'])
if 'balance_start' in st_vals: