yamaksy Posted February 24, 2014 Share Posted February 24, 2014 Hi, I have a OpenErp installation, JasperReports working well and Ireport 3.7.5. I'm trying to pass the ids of the products selected to the report. I want to create a dynamic SQL Report.In the report I have the next parameters :ids, PIDS, product_ids and LIDS.In OpenErp I have the next code : def do_catalog(self, cr, uid, ids, context={}): product_ids = context.get('active_ids',False) catalog_builder = self.browse(cr,uid,ids[0]) data = { 'model': 'product.product', 'ids': product_ids , } return { 'type': 'ir.actions.report.xml', 'report_name': 'pruebas', 'datas': data, 'parameters': { 'product_ids':product_ids, }, 'nodestroy': False }[/code]I have try lots of SQL's , now I have this :select * from product_product where $X{ IN ,product_product.id,product_ids} . It returns me all the data in produts_prodcts not the ones I have selected. I don't know what I'm doing bad, I had read all the information I have find. Can anyone help me?Regards Link to comment Share on other sites More sharing options...
marianol Posted February 24, 2014 Share Posted February 24, 2014 Yamarksy,At first glance it looks like your query is correct (note: i do not have a lot of experience with OpenERP).Your report is likely showing all the data because the parameter prodcut_id is null. Look how $X behaves in building the query here http://jasperreports.sourceforge.net/sample.reference/query/#query (scroll down to Built-in SQL Clause Functions )Can you attache your JRXML report? That will help me better understand where the problem may be. Link to comment Share on other sites More sharing options...
yamaksy Posted February 25, 2014 Author Share Posted February 25, 2014 I have attache the JRXML report, but I think my problem is earlier, when I try to pass the parameters from OpenErp to the report. Thanks for your help. Link to comment Share on other sites More sharing options...
Solution yamaksy Posted February 25, 2014 Author Solution Share Posted February 25, 2014 After reading a lot, I get the answer and I will post it :In the function called by the action you have to pass the ids to the report like this. def do_catalog(self, cr, uid, ids, context={}): product_ids = context.get('active_ids',False) catalog_builder = self.browse(cr,uid,ids[0]) data = { 'model': 'product.product', 'ids': product_ids, } return { 'type': 'ir.actions.report.xml', 'report_name': 'pruebas', 'datas': data, }[/code]aIn the report you have to have a parameter called the same but in UPPERCASE. In this case IDS, and the class have to be java.lang.Object . You sould have another parameter called as you want to convert that object to collection : $P{IDS}.toList()[/code]The SQL should look like this : select * from product_product where $X{ IN ,product_product.id,PIDS}[/code]This works for me .Thanks for helping. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now