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.

85 lines
3.2 KiB

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. from openerp.tools.translate import _
  22. class common_report_header(object):
  23. def _get_start_date(self, data):
  24. if data.get('form', False) and data['form'].get('date_from', False):
  25. return data['form']['date_from']
  26. return ''
  27. def _get_target_move(self, data):
  28. if data.get('form', False) and data['form'].get('target_move', False):
  29. if data['form']['target_move'] == 'all':
  30. return _('All Entries')
  31. return _('All Posted Entries')
  32. return ''
  33. def _get_end_date(self, data):
  34. if data.get('form', False) and data['form'].get('date_to', False):
  35. return data['form']['date_to']
  36. return ''
  37. def get_start_period(self, data):
  38. if data.get('form', False) and data['form'].get('period_from', False):
  39. return self.pool['account.period'].browse(
  40. self.cr, self.uid,
  41. data['form']['period_from'][0]).name
  42. return ''
  43. def get_end_period(self, data):
  44. if data.get('form', False) and data['form'].get('period_to', False):
  45. return self.pool['account.period'].browse(
  46. self.cr, self.uid,
  47. data['form']['period_to'][0]).name
  48. return ''
  49. def _get_account(self, data):
  50. if data.get('form', False) and data['form'].get(
  51. 'chart_account_id', False
  52. ):
  53. return self.pool['account.account'].browse(
  54. self.cr, self.uid,
  55. data['form']['chart_account_id'][0]).name
  56. return ''
  57. def _get_sortby(self, data):
  58. raise (_('Error'), _('Not implemented'))
  59. def _get_filter(self, data):
  60. if data.get('form', False) and data['form'].get('filter', False):
  61. if data['form']['filter'] == 'filter_date':
  62. return _('Date')
  63. elif data['form']['filter'] == 'filter_period':
  64. return _('Periods')
  65. return _('No Filter')
  66. def _get_fiscalyear(self, data):
  67. if data.get('form', False) and data['form'].get(
  68. 'fiscalyear_id', False
  69. ):
  70. return self.pool['account.fiscalyear'].browse(
  71. self.cr, self.uid,
  72. data['form']['fiscalyear_id'][0]).name
  73. return ''