[FIX] account: difference in account.bank.statement
Since balance_end and balance_end_real are floats, they cannot be compared without rounding. opw:660299
This commit is contained in:
@@ -78,6 +78,11 @@ class AccountBankStatement(models.Model):
|
||||
self.balance_end = self.balance_start + self.total_entry_encoding
|
||||
self.difference = self.balance_end_real - self.balance_end
|
||||
|
||||
@api.multi
|
||||
def _is_difference_zero(self):
|
||||
for bank_stmt in self:
|
||||
bank_stmt.is_difference_zero = float_is_zero(bank_stmt.difference, bank_stmt.currency_id.decimal_places)
|
||||
|
||||
@api.one
|
||||
@api.depends('journal_id')
|
||||
def _compute_currency(self):
|
||||
@@ -148,7 +153,7 @@ class AccountBankStatement(models.Model):
|
||||
user_id = fields.Many2one('res.users', string='Responsible', required=False, default=lambda self: self.env.user)
|
||||
cashbox_start_id = fields.Many2one('account.bank.statement.cashbox', string="Starting Cashbox")
|
||||
cashbox_end_id = fields.Many2one('account.bank.statement.cashbox', string="Ending Cashbox")
|
||||
|
||||
is_difference_zero = fields.Boolean(compute='_is_difference_zero', string='Is zero', help="Check if difference is zero.")
|
||||
|
||||
@api.onchange('journal_id')
|
||||
def onchange_journal_id(self):
|
||||
|
||||
@@ -449,7 +449,7 @@
|
||||
<field name="name">account.bank.statement.tree</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree decoration-danger="balance_end_real!=balance_end and state=='open'" decoration-info="state=='open' and (balance_end_real==balance_end)" string="Statements">
|
||||
<tree decoration-danger="not is_difference_zero and state=='open'" decoration-info="state=='open' and is_difference_zero" string="Statements">
|
||||
<field name="name"/>
|
||||
<field name="date"/>
|
||||
<field name="journal_id"/>
|
||||
@@ -458,6 +458,7 @@
|
||||
<field name="balance_end" invisible="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="state"/>
|
||||
<field name="is_difference_zero" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user