Merge lp:~openerp-dev/openobject-server/6.0-opw-17600-odo into lp:openobject-server/6.0

Proposed by Olivier Dony (Odoo)
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-server/6.0-opw-17600-odo
Merge into: lp:openobject-server/6.0
Diff against target: 25 lines (+11/-5)
1 file modified
bin/report/preprocess.py (+11/-5)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/6.0-opw-17600-odo
Reviewer Review Type Date Requested Status
OpenERP Publisher's Warranty Team Pending
Review via email: mp+77920@code.launchpad.net

Description of the change

(Correct target branch this time, sorry for previous one)

This patch makes the report preprocessing system properly handle separately inner and trailing text for each XML node. This fixes potential issues where the tailing text would be put inside the node if the node is empty, e.g:
   <p></p>bar would become <p>bar</p>

But it also avoids ignoring trailing text when there is an inner text, e.g.:
   <p>[[ o.name ]]</p>[[ removeParentNode('td') ]] would have the removeParentNode() part ignored.

To be further tested with real reports, this is untested so far.

To post a comment you must log in.

Unmerged revisions

3510. By Olivier Dony (Odoo)

[FIX] report.preprocess: properly handle node.text and node.tail [CASE 17600]

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/report/preprocess.py'
2--- bin/report/preprocess.py 2010-05-18 10:32:42 +0000
3+++ bin/report/preprocess.py 2011-10-03 12:07:14 +0000
4@@ -71,11 +71,17 @@
5 n = n.getparent()
6 n.set('rml_loop', txt.group(2))
7 return '[['+txt.group(1)+"''"+txt.group(4)+']]'
8- t = _regex1.sub(_sub1, node.text or node.tail)
9- if t == " ":
10- t = _regex11.sub(_sub1, node.text or node.tail)
11- t = _regex3.sub(_sub3, t)
12- node.text = _regex2.sub(_sub2, t)
13+ def preprocess_string(text):
14+ t = _regex1.sub(_sub1, text)
15+ if t == " ":
16+ t = _regex11.sub(_sub1, text)
17+ t = _regex3.sub(_sub3, t)
18+ t = _regex2.sub(_sub2, t)
19+ return t
20+ if node.text:
21+ node.text = preprocess_string(node.text)
22+ if node.tail:
23+ node.tail = preprocess_string(node.tail)
24 self.preprocess_rml(node,type)
25 return root_node
26