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.

101 lines
2.9 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. centralize = fields.Boolean()
  53. target_move = fields.Char()
  54. filter = fields.Selection(
  55. [('filter_no', 'No Filters'),
  56. ('filter_date', 'Date'),
  57. ('filter_opening', 'Opening Only')],
  58. "Filter by",
  59. required=False,
  60. help='Filter by date: no opening balance will be displayed. '
  61. '(opening balance can only be computed based on period to be '
  62. 'correct).'
  63. )
  64. @api.multi
  65. def _get_moves_from_dates_domain(self):
  66. """ Prepare domain for `_get_moves_from_dates` """
  67. domain = []
  68. if self.centralize:
  69. domain = [('centralized', '=', False)]
  70. start_date = self.start_date
  71. end_date = self.end_date
  72. if start_date:
  73. domain += [('date', '>=', start_date)]
  74. if end_date:
  75. domain += [('date', '<=', end_date)]
  76. if self.target_move == 'posted':
  77. domain += [('move_state', '=', 'posted')]
  78. if self.account_ids:
  79. domain += [('account_id', 'in', self.account_ids.ids)]
  80. return domain