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.

86 lines
3.3 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # OpenERP, Open Source Management Solution
  5. # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. import pooler
  22. from tools.translate import _
  23. class common_report_header(object):
  24. def _get_start_date(self, data):
  25. if data.get('form', False) and data['form'].get('date_from', False):
  26. return data['form']['date_from']
  27. return ''
  28. def _get_target_move(self, data):
  29. if data.get('form', False) and data['form'].get('target_move', False):
  30. if data['form']['target_move'] == 'all':
  31. return _('All Entries')
  32. return _('All Posted Entries')
  33. return ''
  34. def _get_end_date(self, data):
  35. if data.get('form', False) and data['form'].get('date_to', False):
  36. return data['form']['date_to']
  37. return ''
  38. def get_start_period(self, data):
  39. if data.get('form', False) and data['form'].get('period_from', False):
  40. return pooler.get_pool(self.cr.dbname).get(
  41. 'account.period').browse(self.cr, self.uid, data[
  42. 'form']['period_from'][0]).name
  43. return ''
  44. def get_end_period(self, data):
  45. if data.get('form', False) and data['form'].get('period_to', False):
  46. return pooler.get_pool(self.cr.dbname).get(
  47. 'account.period').browse(self.cr, self.uid, data[
  48. 'form']['period_to'][0]).name
  49. return ''
  50. def _get_account(self, data):
  51. if data.get('form', False) and data['form'].get(
  52. 'chart_account_id', False
  53. ):
  54. return pooler.get_pool(self.cr.dbname).get(
  55. 'account.account').browse(self.cr, self.uid, data[
  56. 'form']['chart_account_id'][0]).name
  57. return ''
  58. def _get_sortby(self, data):
  59. raise (_('Error'), _('Not implemented'))
  60. def _get_filter(self, data):
  61. if data.get('form', False) and data['form'].get('filter', False):
  62. if data['form']['filter'] == 'filter_date':
  63. return _('Date')
  64. elif data['form']['filter'] == 'filter_period':
  65. return _('Periods')
  66. return _('No Filter')
  67. def _get_fiscalyear(self, data):
  68. if data.get('form', False) and data['form'].get(
  69. 'fiscalyear_id', False
  70. ):
  71. return pooler.get_pool(self.cr.dbname).get(
  72. 'account.fiscalyear').browse(self.cr, self.uid, data[
  73. 'form']['fiscalyear_id'][0]).name
  74. return ''