You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

62 lines
2.6 KiB

# © 2015 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class AccountFinancialReport(models.Model):
_inherit = 'account.financial.report'
@api.multi
def _has_exclusively_report_types(self, report_types):
self.ensure_one()
if self.type == 'accounts':
for account in self.account_ids:
if account.user_type_id.type not in report_types:
return False
elif self.type == 'account_type':
for account_type in self.account_type_ids:
if account_type.type not in report_types:
return False
elif self.type == 'account_report':
# this will have mixed types usually, we rely upon this being
# filtered out by siblings of this report
return True
return all(
r._has_exclusively_report_types(report_types)
for r in self.children_ids)
@api.multi
def _get_children_by_order(self):
reports = super(AccountFinancialReport, self)._get_children_by_order()
if self.env.context.get('account_financial_report_horizontal_side'):
side = self.env.context['account_financial_report_horizontal_side']
report_types = {
'left': ['receivable', 'liquidity', 'other'],
'right': ['payable', 'other']
}[side]
last_good_report = self.browse([])
last_bad_report = self.browse([])
result = self.browse([])
for report in reports:
if not report.parent_id:
result += report
# special treatment for profit and loss if they have the
# standard configuration type='other'
elif side == 'right' and report == self.env.ref(
'account.account_financial_report_income0'
) or side == 'left' and report == self.env.ref(
'account.account_financial_report_expense0'
):
last_bad_report = report
# don't check children if we already checked the parent
elif report.parent_id == last_bad_report:
continue
elif report.parent_id == last_good_report\
or report._has_exclusively_report_types(report_types):
last_good_report = report
result += report
else:
last_bad_report = report
return result
else:
return reports