mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
Create a new method on statement lines to get the currency
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import account_statement_operation_rule
|
||||
from . import account_statement_line
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Author: Guewen Baconnier
|
||||
# Copyright 2014 Camptocamp SA
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
from openerp import models, api
|
||||
|
||||
|
||||
class AccountBankStatementLine(models.Model):
|
||||
_inherit = 'account.bank.statement.line'
|
||||
|
||||
@api.multi
|
||||
def currency_for_rules(self):
|
||||
return self.currency_id or self.statement_id.currency
|
||||
@@ -75,8 +75,7 @@ class AccountStatementOperationRule(models.Model):
|
||||
|
||||
@api.model
|
||||
def _is_multicurrency(self, statement_line):
|
||||
currency = (statement_line.currency_id or
|
||||
statement_line.statement_id.currency)
|
||||
currency = statement_line.currency_for_rules()
|
||||
company_currency = statement_line.company_id.currency_id
|
||||
return currency != company_currency
|
||||
|
||||
@@ -84,8 +83,7 @@ class AccountStatementOperationRule(models.Model):
|
||||
def _is_valid_balance(self, statement_line, move_lines, balance):
|
||||
if self._is_multicurrency(statement_line):
|
||||
return False
|
||||
currency = (statement_line.currency_id or
|
||||
statement_line.statement_id.currency)
|
||||
currency = statement_line.currency_for_rules()
|
||||
return self._balance_in_range(balance, currency)
|
||||
|
||||
@api.multi
|
||||
@@ -93,8 +91,7 @@ class AccountStatementOperationRule(models.Model):
|
||||
# FIXME: surely wrong
|
||||
if self._is_multicurrency(statement_line):
|
||||
return False
|
||||
currency = (statement_line.currency_id or
|
||||
statement_line.statement_id.currency)
|
||||
currency = statement_line.currency_for_rules()
|
||||
amount_currency = statement_line.amount_currency
|
||||
for move_line in move_lines:
|
||||
if move_line.currency_id != statement_line.currency_id:
|
||||
@@ -145,8 +142,7 @@ class AccountStatementOperationRule(models.Model):
|
||||
for move_line in move_lines:
|
||||
balance += move_line.credit - move_line.debit
|
||||
|
||||
currency = (statement_line.currency_id or
|
||||
statement_line.statement_id.currency)
|
||||
currency = statement_line.currency_for_rules()
|
||||
if currency.is_zero(balance):
|
||||
return self.browse()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user