Browse Source

[IMP] account_financial_report_webkit: Allow to select account level on trial balance

pull/165/head
Pedro M. Baeza 9 years ago
parent
commit
bbfdc4429e
  1. 12
      account_financial_report_webkit/report/common_balance_reports.py
  2. 9
      account_financial_report_webkit/report/common_reports.py
  3. 7
      account_financial_report_webkit/wizard/balance_common.py
  4. 3
      account_financial_report_webkit/wizard/trial_balance_wizard_view.xml

12
account_financial_report_webkit/report/common_balance_reports.py

@ -230,8 +230,8 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
return start_period, stop_period, start, stop
def compute_balance_data(self, data, filter_report_type=None):
new_ids = data['form']['account_ids'] or data[
'form']['chart_account_id']
new_ids = (data['form']['account_ids'] or
[data['form']['chart_account_id']])
max_comparison = self._get_form_param(
'max_comparison', data, default=0)
main_filter = self._get_form_param('filter', data, default='filter_no')
@ -259,10 +259,14 @@ class CommonBalanceReportHeaderWebkit(CommonReportHeaderWebkit):
start) or False
# Retrieving accounts
ctx = {}
if data['form'].get('account_level'):
# Filter by account level
ctx['account_level'] = int(data['form']['account_level'])
account_ids = self.get_all_accounts(
new_ids, only_type=filter_report_type)
new_ids, only_type=filter_report_type, context=ctx)
# get details for each accounts, total of debit / credit / balance
# get details for each account, total of debit / credit / balance
accounts_by_ids = self._get_account_details(
account_ids, target_move, fiscalyear, main_filter, start, stop,
initial_balance_mode)

9
account_financial_report_webkit/report/common_reports.py

@ -195,8 +195,15 @@ class CommonReportHeaderWebkit(common_report_header):
acc_obj = self.pool.get('account.account')
for account_id in account_ids:
accounts.append(account_id)
accounts += acc_obj._get_children_and_consol(
children_acc_ids = acc_obj._get_children_and_consol(
self.cursor, self.uid, account_id, context=context)
if context.get('account_level'):
domain = [('level', '<=', context['account_level']),
('id', 'in', children_acc_ids)]
accounts += self.pool['account.account'].search(
self.cursor, self.uid, domain)
else:
accounts += children_acc_ids
res_ids = list(set(accounts))
res_ids = self.sort_accounts_with_structure(
account_ids, res_ids, context=context)

7
account_financial_report_webkit/wizard/balance_common.py

@ -96,6 +96,11 @@ class AccountBalanceCommonWizard(orm.TransientModel):
help='Filter by date: no opening balance will be displayed. '
'(opening balance can only be computed based on period to be \
correct).'),
# Set statically because of the impossibility of changing the selection
# field when changing chart_account_id
'account_level': fields.selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'),
('6', '6')], string="Account level"),
}
for index in range(COMPARISON_LEVEL):
@ -394,7 +399,7 @@ class AccountBalanceCommonWizard(orm.TransientModel):
# will be used to attach the report on the main account
data['ids'] = [data['form']['chart_account_id']]
fields_to_read = ['account_ids', ]
fields_to_read = ['account_ids', 'account_level']
fields_to_read += self.DYNAMIC_FIELDS
vals = self.read(cr, uid, ids, fields_to_read, context=context)[0]

3
account_financial_report_webkit/wizard/trial_balance_wizard_view.xml

@ -22,6 +22,9 @@
<page name="filters" position="after">
<page string="Accounts Filters" name="accounts">
<separator string="Print only" colspan="4"/>
<group>
<field name="account_level"/>
</group>
<field name="account_ids" colspan="4" nolabel="1" domain="[('type', '=', 'view')]">
<tree>
<field name="code"/>

Loading…
Cancel
Save