mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
The 'balance' rules must not match when we are in multicurrency
This commit is contained in:
@@ -54,22 +54,35 @@ class AccountStatementOperationRule(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _is_valid_balance(self, statement_line, move_lines, balance):
|
def _balance_in_range(self, balance, currency):
|
||||||
currency = (statement_line.currency_id or
|
|
||||||
statement_line.statement_id.currency)
|
|
||||||
# FIXME: is_valid_balance must not work with multicurrency
|
|
||||||
if currency.compare_amounts(balance, self.amount_min) == -1:
|
if currency.compare_amounts(balance, self.amount_min) == -1:
|
||||||
return False
|
return False
|
||||||
if currency.compare_amounts(balance, self.amount_max) == 1:
|
if currency.compare_amounts(balance, self.amount_max) == 1:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _is_multicurrency(self, statement_line):
|
||||||
|
currency = (statement_line.currency_id or
|
||||||
|
statement_line.statement_id.currency)
|
||||||
|
company_currency = statement_line.company_id.currency_id
|
||||||
|
return currency != company_currency
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
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)
|
||||||
|
return self._balance_in_range(balance, currency)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _is_valid_multicurrency(self, statement_line, move_lines, balance):
|
def _is_valid_multicurrency(self, statement_line, move_lines, balance):
|
||||||
# FIXME: surely wrong
|
# FIXME: surely wrong
|
||||||
if statement_line.currency_id == statement_line.company_id.currency_id:
|
if self._is_multicurrency(statement_line):
|
||||||
# not multicurrency
|
|
||||||
return False
|
return False
|
||||||
|
currency = (statement_line.currency_id or
|
||||||
|
statement_line.statement_id.currency)
|
||||||
amount_currency = statement_line.amount_currency
|
amount_currency = statement_line.amount_currency
|
||||||
for move_line in move_lines:
|
for move_line in move_lines:
|
||||||
if move_line.currency_id != statement_line.currency_id:
|
if move_line.currency_id != statement_line.currency_id:
|
||||||
@@ -80,8 +93,7 @@ class AccountStatementOperationRule(models.Model):
|
|||||||
# amount in currency is the same, so the balance is
|
# amount in currency is the same, so the balance is
|
||||||
# a difference due to currency rates
|
# a difference due to currency rates
|
||||||
if statement_line.currency_id.is_zero(amount_currency):
|
if statement_line.currency_id.is_zero(amount_currency):
|
||||||
# FIXME: is_valid_balance must not work with multicurrency
|
return self._balance_in_range(balance, currency)
|
||||||
return self._is_valid_balance(statement_line, move_lines, balance)
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
|
|||||||
Reference in New Issue
Block a user