[FIX] account_financial_report: 2 things:
* Fix account group level computation
Depends was not correct for recomputing when needed + better algorithm
* Make hide details on 0 work properly
* Passing values to general ledger was stripping some correct records
* Computed field for hiding lines doesn't have proper dependencies nor is not
taking into account float currency accuracy
This commit is contained in:
@@ -25,15 +25,13 @@ class AccountGroup(models.Model):
|
|||||||
string="Accounts", store=True)
|
string="Accounts", store=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('parent_id')
|
@api.depends('parent_id', 'parent_id.level')
|
||||||
def _compute_level(self):
|
def _compute_level(self):
|
||||||
for group in self:
|
for group in self:
|
||||||
level = 0
|
if not group.parent_id:
|
||||||
new_group = group
|
group.level = 0
|
||||||
while new_group.parent_id:
|
else:
|
||||||
level += 1
|
group.level = group.parent_id.level + 1
|
||||||
new_group = new_group.parent_id
|
|
||||||
group.level = level
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('code_prefix', 'account_ids', 'account_ids.code',
|
@api.depends('code_prefix', 'account_ids', 'account_ids.code',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
|
from odoo.tools import float_is_zero
|
||||||
|
|
||||||
|
|
||||||
class TrialBalanceReport(models.TransientModel):
|
class TrialBalanceReport(models.TransientModel):
|
||||||
@@ -114,16 +115,26 @@ class TrialBalanceReportAccount(models.TransientModel):
|
|||||||
inverse_name='report_account_id'
|
inverse_name='report_account_id'
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.depends(
|
||||||
|
'currency_id',
|
||||||
|
'report_id',
|
||||||
|
'report_id.hide_account_at_0',
|
||||||
|
'report_id.limit_hierarchy_level',
|
||||||
|
'report_id.show_hierarchy_level',
|
||||||
|
'initial_balance',
|
||||||
|
'final_balance',
|
||||||
|
'debit',
|
||||||
|
'credit',
|
||||||
|
)
|
||||||
def _compute_hide_line(self):
|
def _compute_hide_line(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
report = rec.report_id
|
report = rec.report_id
|
||||||
rec.hide_line = False
|
r = (rec.currency_id or report.company_id.currency_id).rounding
|
||||||
if report.hide_account_at_0 and (
|
if report.hide_account_at_0 and (
|
||||||
not rec.initial_balance and
|
float_is_zero(rec.initial_balance, precision_rounding=r)
|
||||||
not rec.final_balance and
|
and float_is_zero(rec.final_balance, precision_rounding=r)
|
||||||
not rec.debit and
|
and float_is_zero(rec.debit, precision_rounding=r)
|
||||||
not rec.credit):
|
and float_is_zero(rec.credit, precision_rounding=r)):
|
||||||
rec.hide_line = True
|
rec.hide_line = True
|
||||||
elif report.limit_hierarchy_level and \
|
elif report.limit_hierarchy_level and \
|
||||||
rec.level > report.show_hierarchy_level:
|
rec.level > report.show_hierarchy_level:
|
||||||
@@ -213,7 +224,8 @@ class TrialBalanceReportCompute(models.TransientModel):
|
|||||||
'date_from': self.date_from,
|
'date_from': self.date_from,
|
||||||
'date_to': self.date_to,
|
'date_to': self.date_to,
|
||||||
'only_posted_moves': self.only_posted_moves,
|
'only_posted_moves': self.only_posted_moves,
|
||||||
'hide_account_at_0': self.hide_account_at_0,
|
# This is postprocessed later with a computed field
|
||||||
|
'hide_account_at_0': False,
|
||||||
'foreign_currency': self.foreign_currency,
|
'foreign_currency': self.foreign_currency,
|
||||||
'company_id': self.company_id.id,
|
'company_id': self.company_id.id,
|
||||||
'filter_account_ids': [(6, 0, account_ids.ids)],
|
'filter_account_ids': [(6, 0, account_ids.ids)],
|
||||||
|
|||||||
Reference in New Issue
Block a user