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.

137 lines
5.0 KiB

  1. # Author: Damien Crier
  2. # Author: Julien Coux
  3. # Copyright 2016 Camptocamp SA
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import _, models
  6. class GeneralLedgerXslx(models.AbstractModel):
  7. _name = 'report.a_f_r.report_general_ledger_xlsx'
  8. _inherit = 'report.account_financial_report.abstract_report_xlsx'
  9. def _get_report_name(self):
  10. return _('General Ledger')
  11. def _get_report_columns(self, report):
  12. return {
  13. 0: {'header': _('Date'), 'field': 'date', 'width': 11},
  14. 1: {'header': _('Entry'), 'field': 'entry', 'width': 18},
  15. 2: {'header': _('Journal'), 'field': 'journal', 'width': 8},
  16. 3: {'header': _('Account'), 'field': 'account', 'width': 9},
  17. 4: {'header': _('Partner'), 'field': 'partner', 'width': 25},
  18. 5: {'header': _('Ref - Label'), 'field': 'label', 'width': 40},
  19. 6: {'header': _('Cost center'),
  20. 'field': 'cost_center',
  21. 'width': 15},
  22. 7: {'header': _('Rec.'), 'field': 'matching_number', 'width': 5},
  23. 8: {'header': _('Debit'),
  24. 'field': 'debit',
  25. 'field_initial_balance': 'initial_debit',
  26. 'field_final_balance': 'final_debit',
  27. 'type': 'amount',
  28. 'width': 14},
  29. 9: {'header': _('Credit'),
  30. 'field': 'credit',
  31. 'field_initial_balance': 'initial_credit',
  32. 'field_final_balance': 'final_credit',
  33. 'type': 'amount',
  34. 'width': 14},
  35. 10: {'header': _('Cumul. Bal.'),
  36. 'field': 'cumul_balance',
  37. 'field_initial_balance': 'initial_balance',
  38. 'field_final_balance': 'final_balance',
  39. 'type': 'amount',
  40. 'width': 14},
  41. 11: {'header': _('Cur.'), 'field': 'currency_name', 'width': 7},
  42. 12: {'header': _('Amount cur.'),
  43. 'field': 'amount_currency',
  44. 'type': 'amount',
  45. 'width': 14},
  46. }
  47. def _get_report_filters(self, report):
  48. return [
  49. [_('Date range filter'),
  50. _('From: %s To: %s') % (report.date_from, report.date_to)],
  51. [_('Target moves filter'),
  52. _('All posted entries') if report.only_posted_moves
  53. else _('All entries')],
  54. [_('Account balance at 0 filter'),
  55. _('Hide') if report.hide_account_balance_at_0 else _('Show')],
  56. [_('Centralize filter'),
  57. _('Yes') if report.centralize else _('No')],
  58. ]
  59. def _get_col_count_filter_name(self):
  60. return 2
  61. def _get_col_count_filter_value(self):
  62. return 2
  63. def _get_col_pos_initial_balance_label(self):
  64. return 5
  65. def _get_col_count_final_balance_name(self):
  66. return 5
  67. def _get_col_pos_final_balance_label(self):
  68. return 5
  69. def _generate_report_content(self, workbook, report):
  70. # For each account
  71. for account in report.account_ids:
  72. # Write account title
  73. self.write_array_title(account.code + ' - ' + account.name)
  74. if not account.partner_ids:
  75. # Display array header for move lines
  76. self.write_array_header()
  77. # Display initial balance line for account
  78. self.write_initial_balance(account, _('Initial balance'))
  79. # Display account move lines
  80. for line in account.move_line_ids:
  81. self.write_line(line)
  82. else:
  83. # For each partner
  84. for partner in account.partner_ids:
  85. # Write partner title
  86. self.write_array_title(partner.name)
  87. # Display array header for move lines
  88. self.write_array_header()
  89. # Display initial balance line for partner
  90. self.write_initial_balance(partner, _('Initial balance'))
  91. # Display account move lines
  92. for line in partner.move_line_ids:
  93. self.write_line(line)
  94. # Display ending balance line for partner
  95. self.write_ending_balance(partner, 'partner')
  96. # Line break
  97. self.row_pos += 1
  98. # Display ending balance line for account
  99. self.write_ending_balance(account, 'account')
  100. # 2 lines break
  101. self.row_pos += 2
  102. def write_ending_balance(self, my_object, type_object):
  103. """Specific function to write ending balance for General Ledger"""
  104. if type_object == 'partner':
  105. name = my_object.name
  106. label = _('Partner ending balance')
  107. elif type_object == 'account':
  108. name = my_object.code + ' - ' + my_object.name
  109. label = _('Ending balance')
  110. super(GeneralLedgerXslx, self).write_ending_balance(
  111. my_object, name, label
  112. )