hi, i need to pass filtered purchase orders to a report. the report prints from button function call.
i have two buttons on my wizard. one is to filter the purchase orders based on the field values present in the wizard.and the other is a print button which should print the filtered purchase orders.now the filtering works fine.what should i do to print the filtered purchase orders on my button click
this is my function to print the wizard, and it is incomplete
def print_wizard(self,cr,uid,ids,context=None):
datas={}
if context is None:
context = {}
data = self.read(cr, uid, ids)[0]
datas = {
'ids': [],
'model': 'filter_wizard',
'form': data,
}
return {'type': 'ir.actions.report.xml', 'report_name': 'Ship.report_wizard','datas': datas}
and this is filter function which works
def filter_opt(self,cr,uid,ids,context=None):
DOMAIN=''
filter_rec = self.browse(cr,uid,ids,context=context)
cu_id=filter_rec.customer.id
sel_field = filter_rec.selection_field
#order_id = context.get('active_id',False)
# sal_obj = self.pool.get('sale.order').browse(cr,uid,ids)
if filter_rec.customer and filter_rec.selection_field:
print "yes1"
if sel_field=='n':
DOMAIN=[('partner_id','=',cu_id) ,('state','=','progress'),('state','=','done')]
elif sel_field=='c':
DOMAIN=[('partner_id','=',cu_id),('state','=','shipping_except'),('state','=','invoice_except')]
elif sel_field=='n':
print "yes2"
DOMAIN=['|' ,('state','=','progress'),('state','=','done')]
elif sel_field=='c':
print "yes3"
DOMAIN=['|',('state','=','shipping_except'),('state','=','invoice_except')]
elif filter_rec.customer:
# cu_id=filter_rec.customer.id
print "yes4"
DOMAIN=[('partner_id','=',cu_id)]
elif filter_rec.date_from and filter_rec.date_to:
print "yes5"
DOMAIN=[('date_order','<',filter_rec.date_to),('date_order','>',filter_rec.date_from)]
elif filter_rec.date_from:
raise exceptions.except_orm(_('Warning!'), _('choose the necessary fields'))
elif filter_rec.date_to:
raise exceptions.except_orm(_('Warning!'), _('choose the necessary fields'))
return {
'name': ' purchase order ',
'view_type': 'tree',
'view_mode': 'tree',
'res_model': 'purchase.order',
'domain': DOMAIN,
'context': context,
'type': 'ir.actions.act_window',
'target': 'current',
}
this is my report
<report id="custom_report_wizard"
model="filter_wizard"
string="wizard"
report_type="qweb-pdf"
name="Ship.report_wizard"
attachment_use="False"
file="Ship.wizard_report"
/>
and this is my template
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_wizard">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="report.external_layout">
<div class="page">
<div class="row" />
<!--<div class="text-center"><h1><span t-esc="doc"></span></h1></div>-->
<h3>Title</h3>
</div>
</t>
</t>
</t>
</template>
<!--<template id="report_wizard">-->
<!--<t t-call="report.html_container">-->
<!--<t t-foreach="doc_ids" t-as="doc_id">-->
<!--<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'Ship.report_wizard_document')"/>-->
<!--</t>-->
<!--</t>-->
<!--</template>-->
</data>
</openerp>.
pls help me.. i am beginner