Merge lp:~kangol/openobject-server/6.0-context-report into lp:openobject-server/6.0

Proposed by Christophe Simonis (OpenERP)
Status: Needs review
Proposed branch: lp:~kangol/openobject-server/6.0-context-report
Merge into: lp:openobject-server/6.0
Diff against target: 75 lines (+7/-7)
5 files modified
bin/report/custom.py (+2/-2)
bin/report/interface.py (+1/-1)
bin/report/printscreen/ps_form.py (+1/-1)
bin/report/printscreen/ps_list.py (+1/-1)
bin/report/render/rml2pdf/trml2pdf.py (+2/-2)
To merge this branch: bzr merge lp:~kangol/openobject-server/6.0-context-report
Reviewer Review Type Date Requested Status
Naresh(OpenERP) (community) Needs Fixing
Review via email: mp+61936@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Christophe,

if we talk about passing the missing context the merge proposal seems Good ! :)

But at the end you removed the 'internal_header' from the localcontext, doing so will not print the page number formatting on right top corner (page 1 out of 10) which is supposed to be printed when internal header is selected. The condition is needed here

if self.localcontext and not self.localcontext.get('internal_header',False):
    self.localcontext.pop('internal_header', None)

Thanks,

review: Needs Fixing
Revision history for this message
Vo Minh Thu (thu) wrote :

Naresh,

If there is *no* internal_header in the dict, remove it from the dict? This doesn't make any sense.

So we need to know when the internal_header is present and what is the complete behavior. The previous code never entered the if body (or it would have broke), so it seems the internal_header was always present in the dict with a non-False value. We need to know if we can assume the internal_header is always there.

Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Hello Thu,

Yes, the localcontext dict will always have the key 'internal_header' present with value True / False
depending on the report's parser 'header' argument. if you specify header = 'internal' or 'internal landscape' the key will have value as True else False. If its true You will see a different header format on the final output.
for eg:
report_sxw.report_sxw('report.account.aged_trial_balance', 'res.partner',
        'addons/account/report/account_aged_partner_balance.rml',parser=aged_trial_report, header="internal landscape")

The previous code do enters *IF* body if you print something there you will see the output(but only when you shut your server down dont know why:(

Thanks

Unmerged revisions

3433. By Christophe Simonis (OpenERP)

[FIX] report: correct context cleaning when render RML

3432. By Christophe Simonis (OpenERP)

[FIX] report: pass context when render RML

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/report/custom.py'
2--- bin/report/custom.py 2010-09-23 10:01:45 +0000
3+++ bin/report/custom.py 2011-05-23 09:14:23 +0000
4@@ -340,7 +340,7 @@
5 'addons/base/report/custom_new.xsl')))
6 rml = etree.tostring(transform(new_doc))
7
8- self.obj = render.rml(rml)
9+ self.obj = render.rml(rml, context)
10 self.obj.render()
11 return True
12
13@@ -620,7 +620,7 @@
14 'addons/base/report/custom_new.xsl')))
15 rml = etree.tostring(transform(new_doc))
16
17- self.obj = render.rml(rml)
18+ self.obj = render.rml(rml, context)
19 self.obj.render()
20 return True
21 report_custom('report.custom')
22
23=== modified file 'bin/report/interface.py'
24--- bin/report/interface.py 2011-01-17 18:44:44 +0000
25+++ bin/report/interface.py 2011-05-23 09:14:23 +0000
26@@ -93,7 +93,7 @@
27 report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
28 self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
29 create_doc = self.generators[report_type]
30- pdf = create_doc(rml, title=self.title)
31+ pdf = create_doc(rml, context, title=self.title)
32 return (pdf, report_type)
33
34 def create_xml(self, cr, uid, ids, datas, context=None):
35
36=== modified file 'bin/report/printscreen/ps_form.py'
37--- bin/report/printscreen/ps_form.py 2010-09-06 08:11:04 +0000
38+++ bin/report/printscreen/ps_form.py 2011-05-23 09:14:23 +0000
39@@ -127,7 +127,7 @@
40 'addons/base/report/custom_new.xsl')))
41 rml = etree.tostring(transform(new_doc))
42
43- self.obj = render.rml(rml, self.title)
44+ self.obj = render.rml(rml, context, self.title)
45 self.obj.render()
46 return True
47 report_printscreen_list('report.printscreen.form')
48
49=== modified file 'bin/report/printscreen/ps_list.py'
50--- bin/report/printscreen/ps_list.py 2010-10-11 09:37:09 +0000
51+++ bin/report/printscreen/ps_list.py 2011-05-23 09:14:23 +0000
52@@ -262,7 +262,7 @@
53 etree.parse(os.path.join(tools.config['root_path'],
54 'addons/base/report/custom_new.xsl')))
55 rml = etree.tostring(transform(new_doc))
56- self.obj = render.rml(rml, title=self.title)
57+ self.obj = render.rml(rml, context, title=self.title)
58 self.obj.render()
59 return True
60 report_printscreen_list('report.printscreen.list')
61
62=== modified file 'bin/report/render/rml2pdf/trml2pdf.py'
63--- bin/report/render/rml2pdf/trml2pdf.py 2011-05-04 09:50:00 +0000
64+++ bin/report/render/rml2pdf/trml2pdf.py 2011-05-23 09:14:23 +0000
65@@ -931,8 +931,8 @@
66 self.doc_tmpl.addPageTemplates(self.page_templates)
67
68 def render(self, node_stories):
69- if self.localcontext and not self.localcontext.get('internal_header',False):
70- del self.localcontext['internal_header']
71+ if self.localcontext:
72+ self.localcontext.pop('internal_header', None)
73 fis = []
74 r = _rml_flowable(self.doc,self.localcontext, images=self.images, path=self.path, title=self.title)
75 story_cnt = 0