1
# -*- coding: utf-8 -*- #
4
from osv import osv, fields
7
'production':'Production',
8
'sample':'Sale Sample',
9
'development':'Development',
11
class mm_report(osv.osv_memory):
13
_description = 'MM Report'
15
'year':fields.many2one('account.fiscalyear', 'Year', required=True),
16
'purpose':fields.selection([('production', 'PRODUCTION'),('sample', 'SQLE SAMPLE'),('development','DEVELOPMENT')], 'Purpose', required=True),
17
'report_type':fields.selection([('pdf','PDF'),('odt','ODT')],'Rrport Type', required=True),
24
def print_report(self, cr, uid, ids, context=None):
26
To get the date and print the report
27
@return : return report
31
report_obj = self.pool.get('ir.actions.report.xml')
32
datas={'ids':context.get('active_ids',[])}
33
res = self.read(cr, uid, ids, ['year','purpose','report_type'], context=context)
35
year = self.pool.get('account.fiscalyear').browse(cr, uid, res[0]['year'])
36
datas['purpose'] = res[0]['purpose']
37
datas['purpose_name'] = PURPOSE_MAPS.get(res[0]['purpose'], False)
38
datas['report_type'] = res[0]['report_type']
39
datas['year_start'] = year.date_start
40
datas['year_stop'] = year.date_stop
41
datas['year'] = time.strftime('%Y',time.strptime(year.date_start,'%Y-%m-%d'))
42
report_name = 'sample_mm'
43
if res[0]['purpose'] == 'production':
44
report_name = 'production_mm'
45
report_ids = report_obj.search(cr, uid, [('report_name','=',report_name)])
46
report_obj.write(cr, uid, report_ids[0], {'report_type':res[0]['report_type']})
48
'type':'ir.actions.report.xml',
49
'report_name':report_name,
56
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: