12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- # -*- coding: utf-8 -*-
- ##############################################################################
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
- #
- # You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
- # GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
- # If not, see <http://www.gnu.org/licenses/>.
- #
- ##############################################################################
- from openerp import models, fields
- class MrpReportWizard (models.Model):
- _name = "mrp.report"
- filter = fields.Boolean('Habilitar filtro por fecha')
- date_from = fields.Date("Fecha Desde")
- date_to = fields.Date("Fecha Hasta")
- filter_user = fields.Boolean("Filtrar por Responsable")
- responsible = fields.Many2many('res.users', string='Responsable')
- product = fields.Many2many('product.product', string='Producto')
- stage = fields.Selection([
- ('confirmed', 'Confirmado'),
- ('planned', 'Planeado'),
- ('progress', 'En progreso'),
- ('done', 'Hecho'),
- ('cancel', 'Cancelado')], string="Filtrar por estado")
- def check_report(self, cr, uid, ids, context):
- data = self.read(cr, uid, ids, ['filter_user',
- 'filter', 'date_from', 'responsible',
- 'date_to', 'product', 'stage'], context=context)[0]
- return {'type': 'ir.actions.report.xml',
- 'report_name': 'eirumrp_reports_xls',
- 'datas': data}
- def print_pdf(self, cr, uid, ids, context=None):
- if context is None:
- context = {}
- data = self.read(cr, uid, ids, ['filter_user',
- 'filter', 'date_from', 'responsible',
- 'date_to', 'product', 'stage'], context=context)[0]
- datas = {
- 'ids': context.get('active_ids', []),
- 'model': 'mrp.report',
- 'form': data
- }
- datas['form']['active_ids'] = context.get('active_ids', False)
- return self.pool['report'].get_action(cr, uid, [], 'eirumrp_reports.mrp_pdf', data=data,
- context=context)
|