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.

69 lines
3.3 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Author: Houssine BAKKALI
  5. # Copyright Open Architects Consulting
  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 import api, fields, models, _
  22. class cooperative_report(models.TransientModel):
  23. _name = 'cooperative.history.report'
  24. def _print_report(self, data):
  25. return {'type': 'ir.actions.report.xml',
  26. 'report_name': data['report'],
  27. 'datas': data}
  28. def check_report(self):
  29. data = {}
  30. report_name = ''
  31. obj_ids = []
  32. if self._context.get('active_ids') :
  33. data['ids'] = self._context.get('active_ids', [])
  34. else:
  35. if self.report == 'coop_register':
  36. report_name = 'easy_my_coop.cooperator_register_G001'
  37. res_partner_obj = self.pool.get('res.partner')
  38. domain = []
  39. domain.append(('cooperator','=','True'))
  40. if self.display_cooperator == 'member' :
  41. domain.append(('member','=','True'))
  42. obj_ids = res_partner_obj.search(cr,uid, domain, order='cooperator_register_number')
  43. elif self.report == 'operation_register' :
  44. report_name = 'energiris_wp_sync.cooperator_subscription_G001'
  45. obj_ids = self.pool.get('subscription.register').search(cr,uid,[], order='register_number_operation')
  46. else :
  47. raise osv.except_osv(_("Error!"), _("the report you've specified doesn't exist !"))
  48. data['model'] = context.get('active_model', 'ir.ui.menu')
  49. data['report'] = report_name
  50. #data['form'] = self.read(cr, uid, ids, ['date_from', 'date_to','display_time','display_cooperator','group_by_task','group_by_task_work'], context=context)[0]
  51. data['ids'] = obj_ids
  52. return self._print_report(cr, uid, ids, data, context=context)
  53. name = fields.Char(string='Name')
  54. report = fields.Selection([('coop_register', 'Cooperators Register'),
  55. ('operation_register', 'Operations Register')],
  56. string='Report',
  57. required=True, default='coop_register')
  58. display_cooperator = fields.Selection([('all', 'All'),
  59. ('member', 'Effective member')],
  60. string='Display cooperator',
  61. required=True, default='all')