I need to pass the value of my two fields i.e date_from n date_to from my wizard to the report it calls/prints. Following is my code. This is working fine but only problem is i am not able to find how to print these two fields. Any help is appreciated.
class my_wizard_report(osv.osv_memory):
_name = 'my.wizard.report'
## _inherit = 'account.invoice'
_description = 'Test Report'
_columns = {
'date_from':fields.date('Date From',store=True),
'date_to':fields.date('Date To',store=True),
'invoice_ids':fields.many2many('account.invoice', string='Filter on invoices',help="Only selected invoices will be printed"),
}
_defaults = {
'date_from': lambda *a: time.strftime('%Y-%m-%d'),
'date_to': lambda *a: time.strftime('%Y-%m-%d'),
}
def print_report(self, cr, uid, ids, context=None):
datas = {}
if context is None:
context = {}
data = self.read(cr, uid, ids,['date_from', 'date_to', 'invoice_ids'], context=context)
date_from = data[0]['date_from']
date_to = data[0]['date_to']
obj = self.pool.get('account.invoice')
ids = obj.search(cr, uid, [('date_invoice','>=',date_from),('date_invoice','<=',date_to)])
datas = {
'ids': ids,
'model': 'account.invoice',
'form': data
}
return {'type': 'ir.actions.report.xml', 'report_name': 'account.invoice.rnd5c3tV', 'datas': datas}
my_wizard_report()
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- cancel order -->
<record id="view_my_wiz_form" model="ir.ui.view">
<field name="name">print.report.form</field>
<field name="model">my.wizard.report</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Print Report">
<group colspan="4" >
<field name="date_from" filter_domain="[('date_invoice','>=',self)]" />
<field name="date_to" filter_domain="[('date_invoice','<=',self)]" />
</group>
<separator string="Print Only" colspan="4" />
<group colspan = "4">
<field name="invoice_ids" colspan="4" nolabel="1"/>
</group>
<group colspan="4" col="6">
<button icon="gtk-ok" name="print_report" string="Print" type="object"/>
</group>
</form>
</field>
</record>
<record id="action_my_wiz_form" model="ir.actions.act_window">
<field name="name">Print Report</field>
<field name="res_model">my.wizard.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_my_wiz_form"/>
<field name="target">new</field>
</record>
<act_window id="action_my_wiz_form_values"
key2="client_action_multi" name="Print Report"
res_model="my.wizard.report" src_model="add.penalty"
view_mode="form" target="new" view_type="form"/>
</data>
</openerp>