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.

113 lines
3.4 KiB

  1. # -*- encoding: utf-8 -*-
  2. # © 2015 Yannick Vaucher
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import models, fields, api
  5. class FinancialReportLine(models.AbstractModel):
  6. """Rappresentation of a report line."""
  7. _name = 'financial.report.line'
  8. _description = "Financial report line"
  9. _order = 'account_id, date'
  10. # TODO order by account_id.code
  11. name = fields.Char()
  12. ref = fields.Char()
  13. date = fields.Date()
  14. month = fields.Char()
  15. partner_name = fields.Char()
  16. partner_ref = fields.Char()
  17. account_id = fields.Many2one('account.account')
  18. account_code = fields.Char()
  19. journal_id = fields.Many2one('account.journal')
  20. currency_id = fields.Many2one('res.currency')
  21. currency_code = fields.Char()
  22. init_credit = fields.Float()
  23. init_debit = fields.Float()
  24. debit = fields.Float()
  25. credit = fields.Float()
  26. balance = fields.Float()
  27. amount_currency = fields.Float()
  28. cumul_credit = fields.Float()
  29. cumul_debit = fields.Float()
  30. cumul_balance = fields.Float()
  31. cumul_balance_curr = fields.Float()
  32. init_credit = fields.Float()
  33. init_debit = fields.Float()
  34. init_balance = fields.Float()
  35. init_balance_curr = fields.Float()
  36. debit_centralized = fields.Float()
  37. credit_centralized = fields.Float()
  38. balance_centralized = fields.Float()
  39. balance_curr_centralized = fields.Float()
  40. init_credit_centralized = fields.Float()
  41. init_debit_centralized = fields.Float()
  42. init_balance_centralized = fields.Float()
  43. init_balance_curr_centralized = fields.Float()
  44. move_name = fields.Char()
  45. move_state = fields.Char()
  46. invoice_number = fields.Char()
  47. centralized = fields.Boolean()
  48. class CommonFinancialReport(models.AbstractModel):
  49. _name = 'account.report.common'
  50. start_date = fields.Date()
  51. end_date = fields.Date()
  52. fiscalyear = fields.Many2one('account.fiscalyear')
  53. centralize = fields.Boolean()
  54. target_move = fields.Char()
  55. filter = fields.Selection(
  56. [('filter_no', 'No Filters'),
  57. ('filter_date', 'Date'),
  58. ('filter_opening', 'Opening Only')],
  59. "Filter by",
  60. required=False,
  61. help='Filter by date: no opening balance will be displayed. '
  62. '(opening balance can only be computed based on period to be '
  63. 'correct).'
  64. )
  65. @api.multi
  66. def _get_moves_from_dates_domain(self):
  67. """ Prepare domain for `_get_moves_from_dates` """
  68. domain = []
  69. if self.centralize:
  70. domain = [('centralized', '=', False)]
  71. start_date = self.start_date
  72. end_date = self.end_date
  73. if self.fiscalyear:
  74. start_date = self.fiscalyear.start_date
  75. end_date = self.fiscalyear.end_date
  76. if start_date:
  77. domain += [('date', '>=', start_date)]
  78. if end_date:
  79. domain += [('date', '<=', end_date)]
  80. if self.target_move == 'posted':
  81. domain += [('move_state', '=', 'posted')]
  82. if self.account_ids:
  83. domain += [('account_id', 'in', self.account_ids.ids)]
  84. domain += [('journal_id', 'in', self.journal_ids.ids)]
  85. return domain
  86. @api.multi
  87. def _get_moves_from_fiscalyear(self, account, fiscalyear,
  88. target_move):
  89. return self._get_moves_from_dates(
  90. account, fiscalyear.date_start, fiscalyear.date_end, target_move)