eirumrp_report_wizard.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. # This program is distributed in the hope that it will be useful,
  4. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6. # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
  7. #
  8. # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
  9. # GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
  10. # If not, see <http://www.gnu.org/licenses/>.
  11. #
  12. ##############################################################################
  13. from openerp import models, fields
  14. class MrpReportWizard (models.Model):
  15. _name = "mrp.report"
  16. filter = fields.Boolean('Habilitar filtro por fecha')
  17. date_from = fields.Date("Fecha Desde")
  18. date_to = fields.Date("Fecha Hasta")
  19. filter_user = fields.Boolean("Filtrar por Responsable")
  20. responsible = fields.Many2many('res.users', string='Responsable')
  21. product = fields.Many2many('product.product', string='Producto')
  22. stage = fields.Selection([
  23. ('confirmed', 'Confirmado'),
  24. ('planned', 'Planeado'),
  25. ('progress', 'En progreso'),
  26. ('done', 'Hecho'),
  27. ('cancel', 'Cancelado')], string="Filtrar por estado")
  28. def check_report(self, cr, uid, ids, context):
  29. data = self.read(cr, uid, ids, ['filter_user',
  30. 'filter', 'date_from', 'responsible',
  31. 'date_to', 'product', 'stage'], context=context)[0]
  32. return {'type': 'ir.actions.report.xml',
  33. 'report_name': 'eirumrp_reports_xls',
  34. 'datas': data}
  35. def print_pdf(self, cr, uid, ids, context=None):
  36. if context is None:
  37. context = {}
  38. data = self.read(cr, uid, ids, ['filter_user',
  39. 'filter', 'date_from', 'responsible',
  40. 'date_to', 'product', 'stage'], context=context)[0]
  41. datas = {
  42. 'ids': context.get('active_ids', []),
  43. 'model': 'mrp.report',
  44. 'form': data
  45. }
  46. datas['form']['active_ids'] = context.get('active_ids', False)
  47. return self.pool['report'].get_action(cr, uid, [], 'eirumrp_reports.mrp_pdf', data=data,
  48. context=context)