It is currently Sat Feb 11, 2012 8:49 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Please help: How to print dynamic report by using wizard!!!
PostPosted: Wed Mar 10, 2010 6:19 am 
Offline

Joined: Wed Jan 13, 2010 4:49 pm
Posts: 18
Hi,
I have got problem when I made a new wizard to print a report
I define my field, as you see below, it has only field project_id
_fields = {
'project_id':{'string':'Project_id','type':'many2one','relation':'project.project'},
}


I want users to choose project_id via wizard form, then I will print the report that satisfied the conditonal, so my code is:
def _get_data(self, cr, uid, data, context):
sql ="""SELECT * FROM project_task t WHERE t.project_id='%s'"""%(data['form']['project_id'])
cr.execute(sql)
objects=cr.fetchall()
return data['form']

The result is that it appears the form for me to choose project_id, but when I press Print button, report didn't show the id or (value) of the record that satisfied the project_id (it only shows ex: [[o.name]], [[o.project_id]])
I wonder whether I'm wrong with python code. Therefore, I really need your help. Does anyone give me suggestion to fix this problem.
If anyone can solve this problem, please help me.
I'll appreciate this and thanks anyway.
[/img][/url]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2010 8:09 am 
Offline

Joined: Fri Dec 19, 2008 8:30 am
Posts: 60
Hello,

I am not getting exactly because you have not given complete code .....
But what i am getting is , after wizard, you can see the report then i think your wizard is OK.
The problem is in report.

May be you are accessing fields of wizard in report.
In report, [[repeatIn(objects,'o') ]] means you can access all the fields of current object by giving reference like o.name, o.code ..... means name and code must be in that current object. You can't access fields of wizard by giving reference of o.

But here i am not sure about project_id and name fields which you accessed in report.
Are those fields in the current object from which you are running wizard ? or in the wizard ?
Are you getting any error on server or client side, while printing a report ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2010 4:25 pm 
Offline

Joined: Wed Jan 13, 2010 4:49 pm
Posts: 18
Hi,
Yes, my problem is that the report doesn't understand those fields that I have chosen from wizard form.
The wizard appears ok, but I can't get the field that input in wizard form.
For examle:
Wizard form appears with 1 field project_id:, and I chose the value id=3 (project_id=3). However the report didn't print the record that has the id=3
It's only print the current object(ex: id=2) or error likes [[o.name]],.... =>That means my wizard is useless because I had chosen the id=3 before.
So I guess my problem encounters 2 cases:
Case 1: My python code is wrong somewhere so it doesn't understand my sql statements
Case 2: as you said, my report only get current object, and it can't access the field that I typed in wizard form
I really appreciate because of your response. I also try everything but it doesn't work.
Another questions, if we don't use [[repeatIn(objects,'o')]] so what's the statement we will use for report access those fields that we had typed in wizard??
Thanks anyway
@ Priyesh: can you give me your email, so I can send you my detailed problem description. If you can solve this problem like this, please help me. I really need your help. Thanks for your being so kind!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2010 7:17 am 
Offline

Joined: Fri Dec 19, 2008 8:30 am
Posts: 60
Hello,

My email address is pso@tinyerp.com. You can mail me your detailed description on this id.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 16, 2010 10:31 am 
Offline

Joined: Thu Feb 19, 2009 3:42 pm
Posts: 57
Location: Bordeaux France
Hi,

First, in your python code , I wonder why you return "data[form]" and not "objects" ?
Maybe I don't really understand your code...

You have examples of such wizards and rml reports in module accout/project. Quantity_cost_ledger (wizard and report) helps me a lot to understand the way it works.

Other examples can be found in hr/timesheest using xsl reports. I think it's closer of what you need.

Good luck.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2010 3:20 pm 
Offline

Joined: Thu May 29, 2008 12:58 pm
Posts: 208
Location: Gandhinagar,Gujarat,India
hi,

you need to return objects and in your rml you need to call like repeatIn(_get_data(),o)
then you can refer like this only if your return value is browse_record object i.e o.name,o.code etc. but if it is dictionary({}) then you need to refer as o['name'],o['code']


hope this helps !

_________________
Regards,
Naresh Choksy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2010 6:23 am 
Offline

Joined: Wed Jan 13, 2010 4:49 pm
Posts: 18
Hi,
Thank Naresh, your help is worth. It makes me learn more about the python code. However, I was confused about which file we should put the function _get_data , in wizard or in report.
Actually, I also test out this way by putting function (_get_data) in wizard, and call repeatIn(_get_data(),o) in my rml but it noticed the error like "_get_data is not defined" so I don't know why. After that, I changed to put my function _get_data in file python of report and it works. According to your knowledge, if it's possible to put the function on wizard and call it in rml file or we must put the function on report.
Anyway, thanks for your response!


Last edited by howtolearn on Thu Apr 01, 2010 4:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2010 6:48 am 
Offline

Joined: Thu May 29, 2008 12:58 pm
Posts: 208
Location: Gandhinagar,Gujarat,India
Hello,


You need to put that function on report if it is a normal report that is report without wizard.

In short If I can tell you you just refer the report product_pricelist in module product. In this report the wizard takes the product quantity and based on that the report is printed.

I am sure this will help you to achieve your Goal !

_________________
Regards,
Naresh Choksy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP