minor fix

This commit is contained in:
wilson gomez 2022-02-02 10:22:28 -05:00
parent e4648498b5
commit d64e0913e2
2 changed files with 11 additions and 9 deletions

View File

@ -878,7 +878,7 @@ class IncomeStatement(Report):
context_fields = Context.fields_get(['start_period', 'fiscalyear'])
types = Type.search([
('income_statement', '=', True)
('statement', '=', 'income')
])
accounts_types = []
company_id = Transaction().context.get('company')
@ -909,29 +909,31 @@ class IncomeStatement(Report):
with Transaction().set_context(periods=periods_ids):
while types:
type_ = types.pop()
if type_.income_statement is False:
type_dict = {'type': type_, 'accounts': None}
if type_.statement == 'income':
accounts = Account.search([
('type', '=', type_.id),
])
if accounts:
setattr(type_, 'accounts', accounts)
accounts_types.append((type_.sequence, type_))
# setattr(type_, 'accounts', accounts)
type_dict = {'type': type_, 'accounts': accounts}
accounts_types.append((type_.sequence, type_dict))
if type_.childs:
types.extend(list(type_.childs))
if accounts_types:
od = OrderedDict(sorted(dict(accounts_types).items()))
types_added = []
filtered_records = []
for k, v in od.items():
childs = []
for c in v.childs:
for c in v['type'].childs:
if c.id not in types_added:
childs.append(c)
types_added.extend([v.id, c.id])
childs.append(od[c.sequence])
types_added.extend([v['type'].id, c.id])
setattr(v, 'childs', childs)
# setattr(v, 'childs', childs)
v['childs'] = childs
filtered_records.append(v)
report_context['start_period'] = start_period

Binary file not shown.