Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. def get_account_lines(self, data):
  2. lines = []
  3. account_report = self.env['account.financial.report'].search([('id', '=', data['account_report_id'][0])])
  4. child_reports = account_report._get_children_by_order()
  5. res = self.with_context(data.get('used_context'))._compute_report_balance(child_reports)
  6. if data['enable_filter']:
  7. comparison_res = self.with_context(data.get('comparison_context'))._compute_report_balance(child_reports)
  8. for report_id, value in comparison_res.items():
  9. res[report_id]['comp_bal'] = value['balance']
  10. report_acc = res[report_id].get('account')
  11. if report_acc:
  12. for account_id, val in comparison_res[report_id].get('account').items():
  13. report_acc[account_id]['comp_bal'] = val['balance']
  14.  
  15. for report in child_reports:
  16. vals = {
  17. 'name': report.name,
  18. 'balance': res[report.id]['balance'] * report.sign,
  19. 'type': 'report',
  20. 'level': bool(report.style_overwrite) and report.style_overwrite or report.level,
  21. 'account_type': report.type or False, #used to underline the financial report balances
  22. }
  23. if data['debit_credit']:
  24. vals['debit'] = res[report.id]['debit']
  25. vals['credit'] = res[report.id]['credit']
  26.  
  27. if data['enable_filter']:
  28. vals['balance_cmp'] = res[report.id]['comp_bal'] * report.sign
  29.  
  30. lines.append(vals)
  31. if report.display_detail == 'no_detail':
  32. #the rest of the loop is used to display the details of the financial report, so it's not needed here.
  33. continue
  34.  
  35. if res[report.id].get('account'):
  36. sub_lines = []
  37. for account_id, value in res[report.id]['account'].items():
  38. #if there are accounts to display, we add them to the lines with a level equals to their level in
  39. #the COA + 1 (to avoid having them with a too low level that would conflicts with the level of data
  40. #financial reports for Assets, liabilities...)
  41. flag = False
  42. account = self.env['account.account'].browse(account_id)
  43. vals = {
  44. 'name': account.code + ' ' + account.name,
  45. 'group_id': account.code + ' ' + account.'aca necesito concatenar el group_id',
  46. 'balance': value['balance'] * report.sign or 0.0,
  47. 'type': 'account',
  48. 'level': report.display_detail == 'detail_with_hierarchy' and 4,
  49. 'account_type': account.internal_type,
  50. }
  51. if data['debit_credit']:
  52. vals['debit'] = value['debit']
  53. vals['credit'] = value['credit']
  54. if not account.company_id.currency_id.is_zero(vals['debit']) or not account.company_id.currency_id.is_zero(vals['credit']):
  55. flag = True
  56. if not account.company_id.currency_id.is_zero(vals['balance']):
  57. flag = True
  58. if data['enable_filter']:
  59. vals['balance_cmp'] = value['comp_bal'] * report.sign
  60. if not account.company_id.currency_id.is_zero(vals['balance_cmp']):
  61. flag = True
  62. if flag:
  63. sub_lines.append(vals)
  64. lines += sorted(sub_lines, key=lambda sub_line: sub_line['name'])
  65. return lines
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement