Browse Source

[imp] DIPLAYING parent accounts

[imp] displaying parents for P&L
pull/605/head
Lorenzo Battistini 12 years ago
committed by mreficent
parent
commit
41d184761f
  1. 65
      account_financial_report_horizontal/report/account_balance_sheet.py
  2. 57
      account_financial_report_horizontal/report/account_profit_loss.py

65
account_financial_report_horizontal/report/account_balance_sheet.py

@ -83,6 +83,44 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header)
return self.res_bl
def get_data(self,data):
def _process_child(disp_acc, account_id, typ, context):
acc_obj = self.pool.get('account.account')
account = acc_obj.browse(cr, uid, account_id, context)
account_dict = {
'id': account.id,
'code': account.code,
'name': account.name,
'level': account.level,
'balance': (account.balance and typ == 'liability' and -1 or 1 ) * account.balance,
}
if not account.child_id:
if (account.user_type.report_type) and (account.user_type.report_type == typ):
currency = account.currency_id and account.currency_id or account.company_id.currency_id
if typ == 'liability' and account.type != 'view' and (account.debit != account.credit):
self.result_sum_dr += account_dict['balance']
if typ == 'asset' and account.type != 'view' and (account.debit != account.credit):
self.result_sum_cr += account_dict['balance']
if disp_acc == 'bal_movement':
if (not currency_pool.is_zero(self.cr, self.uid, currency, account.credit)
) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.debit)
) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.balance)):
return [account_dict]
elif disp_acc == 'bal_solde':
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
return [account_dict]
else:
return [account_dict]
else:
return []
children = []
for child in account.child_id:
children += _process_child(disp_acc, child.id, typ, context)
if children:
return [account_dict] + children
else:
return []
cr, uid = self.cr, self.uid
db_pool = pooler.get_pool(self.cr.dbname)
@ -115,8 +153,6 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header)
account_id = data['form'].get('chart_account_id', False)
if account_id:
account_id = account_id[0]
account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx)
accounts = account_pool.browse(cr, uid, account_ids, context=ctx)
if not self.res_bl:
self.res_bl['type'] = _('Net Profit')
@ -133,30 +169,7 @@ class report_balancesheet_horizontal(report_sxw.rml_parse, common_report_header)
'balance':self.res_bl['balance'],
}
for typ in types:
accounts_temp = []
for account in accounts:
if (account.user_type.report_type) and (account.user_type.report_type == typ):
account_dict = {
'id': account.id,
'code': account.code,
'name': account.name,
'level': account.level,
'balance': (account.balance and typ == 'liability' and -1 or 1 ) * account.balance,
}
currency = account.currency_id and account.currency_id or account.company_id.currency_id
if typ == 'liability' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_dr += account_dict['balance']
if typ == 'asset' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_cr += account_dict['balance']
if data['form']['display_account'] == 'bal_movement':
if (not currency_pool.is_zero(self.cr, self.uid, currency, account.credit)) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.debit)) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.balance)):
accounts_temp.append(account_dict)
elif data['form']['display_account'] == 'bal_solde':
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(account_dict)
else:
accounts_temp.append(account_dict)
accounts_temp = _process_child(data['form']['display_account'], account_id, typ, ctx)
self.result[typ] = accounts_temp
cal_list[typ]=self.result[typ]

57
account_financial_report_horizontal/report/account_profit_loss.py

@ -84,13 +84,43 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header):
return _(source)
def get_data(self, data):
def get_account_repr(account, account_type):
return {
def _process_child(disp_acc, account_id, typ, context):
acc_obj = self.pool.get('account.account')
account = acc_obj.browse(cr, uid, account_id, context)
account_dict = {
'id': account.id,
'code': account.code,
'name': account.name,
'level': account.level,
'balance': account.balance and (account_type == 'income' and -1 or 1) * account.balance,
}
'balance': account.balance and (typ == 'income' and -1 or 1) * account.balance,
}
if not account.child_id:
if (account.user_type.report_type) and (account.user_type.report_type == typ):
currency = account.currency_id and account.currency_id or account.company_id.currency_id
if typ == 'expense' and account.type != 'view' and (account.debit != account.credit):
self.result_sum_dr += account.debit - account.credit
if typ == 'income' and account.type != 'view' and (account.debit != account.credit):
self.result_sum_cr += account.credit - account.debit
if disp_acc == 'bal_movement':
if (not currency_pool.is_zero(self.cr, self.uid, currency, account.credit)
) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.debit)
) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.balance)):
return [account_dict]
elif disp_acc == 'bal_solde':
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
return [account_dict]
else:
return [account_dict]
else:
return []
children = []
for child in account.child_id:
children += _process_child(disp_acc, child.id, typ, context)
if children:
return [account_dict] + children
else:
return []
cr, uid = self.cr, self.uid
db_pool = pooler.get_pool(self.cr.dbname)
@ -118,26 +148,9 @@ class report_pl_account_horizontal(report_sxw.rml_parse, common_report_header):
account_id = data['form'].get('chart_account_id', False)
if account_id:
account_id = account_id[0]
account_ids = account_pool._get_children_and_consol(cr, uid, account_id, context=ctx)
accounts = account_pool.browse(cr, uid, account_ids, context=ctx)
for typ in types:
accounts_temp = []
for account in accounts:
if (account.user_type.report_type) and (account.user_type.report_type == typ):
currency = account.currency_id and account.currency_id or account.company_id.currency_id
if typ == 'expense' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_dr += account.debit - account.credit
if typ == 'income' and account.type <> 'view' and (account.debit <> account.credit):
self.result_sum_cr += account.credit - account.debit
if data['form']['display_account'] == 'bal_movement':
if (not currency_pool.is_zero(self.cr, self.uid, currency, account.credit)) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.debit)) or (not currency_pool.is_zero(self.cr, self.uid, currency, account.balance)):
accounts_temp.append(get_account_repr(account, typ))
elif data['form']['display_account'] == 'bal_solde':
if not currency_pool.is_zero(self.cr, self.uid, currency, account.balance):
accounts_temp.append(get_account_repr(account, typ))
else:
accounts_temp.append(get_account_repr(account, typ))
accounts_temp = _process_child(data['form']['display_account'], account_id, typ, ctx)
if self.result_sum_dr > self.result_sum_cr:
self.res_pl['type'] = _('Net Loss')
self.res_pl['balance'] = (self.result_sum_dr - self.result_sum_cr)

Loading…
Cancel
Save