Skip to content

Commit f47459b

Browse files
[FIX] report_qweb_parameter: out and raw doesn't work with conditionals
1 parent 2a388f6 commit f47459b

File tree

6 files changed

+52
-11
lines changed

6 files changed

+52
-11
lines changed

report_qweb_parameter/README.rst

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Contributors
7777

7878
* Iván Antón <ozono@ozonomultimedia.com>
7979

80+
* `Sygel Technology <https://www.sygel.es>`_:
81+
82+
* Valentin Vinagre
83+
8084
Maintainers
8185
~~~~~~~~~~~
8286

report_qweb_parameter/demo/test_report_field_length.xml

+17-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
t-esc="docs[0].street"
1616
t-if="docs[0].street"
1717
/>
18+
<li
19+
name="esc_conditional_length"
20+
t-length="3"
21+
t-esc="docs[0].name or docs[0].company_registry"
22+
/>
1823
<li
1924
name="esc_maxlength"
2025
t-maxlength="10"
@@ -28,21 +33,31 @@
2833
t-raw="docs[0].vat"
2934
t-if="docs[0].vat"
3035
/>
36+
<li
37+
name="raw_conditional_length"
38+
t-length="4"
39+
t-raw="docs[0].name or docs[0].company_registry"
40+
/>
3141
<li
3242
name="raw_maxlength"
3343
t-maxlength="10"
3444
t-raw="docs[0].company_registry"
3545
t-if="docs[0].company_registry"
3646
/>
3747
<li
38-
name="raw_length"
48+
name="out_length"
3949
t-minlength="10"
4050
t-length="10"
4151
t-out="docs[0].vat"
4252
t-if="docs[0].vat"
4353
/>
4454
<li
45-
name="raw_maxlength"
55+
name="out_conditional_length"
56+
t-length="5"
57+
t-out="docs[0].name or docs[0].company_registry"
58+
/>
59+
<li
60+
name="out_maxlength"
4661
t-maxlength="10"
4762
t-out="docs[0].company_registry"
4863
t-if="docs[0].company_registry"

report_qweb_parameter/models/ir_qweb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _compile_directive_out(self, el, compile_context, level):
4949
)
5050
if "t-length" in el.attrib:
5151
tlength = el.attrib.pop("t-length")
52-
el.attrib["t-out"] = el.attrib["t-out"] + "[:" + tlength + "]"
52+
el.attrib["t-out"] = "(" + el.attrib["t-out"] + ")[:" + tlength + "]"
5353
return super()._compile_directive_out(el, compile_context, level)
5454

5555
def _compile_directive_raw(self, el, compile_context, level):
@@ -68,5 +68,5 @@ def _compile_directive_raw(self, el, compile_context, level):
6868
)
6969
if "t-length" in el.attrib:
7070
tlength = el.attrib.pop("t-length")
71-
el.attrib["t-raw"] = el.attrib["t-raw"] + "[:" + tlength + "]"
71+
el.attrib["t-raw"] = "(" + el.attrib["t-raw"] + ")[:" + tlength + "]"
7272
return super()._compile_directive_raw(el, compile_context, level)

report_qweb_parameter/readme/CONTRIBUTORS.rst

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
* Carlos Roca
66

77
* Iván Antón <ozono@ozonomultimedia.com>
8+
9+
* `Sygel Technology <https://www.sygel.es>`_:
10+
11+
* Valentin Vinagre

report_qweb_parameter/static/description/index.html

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="utf-8"?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
@@ -9,10 +8,11 @@
98

109
/*
1110
:Author: David Goodger (goodger@python.org)
12-
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
11+
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
15+
Despite the name, some widely supported CSS2 features are used.
1616
1717
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1818
customize this style sheet.
@@ -275,7 +275,7 @@
275275
margin-left: 2em ;
276276
margin-right: 2em }
277277

278-
pre.code .ln { color: grey; } /* line numbers */
278+
pre.code .ln { color: gray; } /* line numbers */
279279
pre.code, code { background-color: #eeeeee }
280280
pre.code .comment, code .comment { color: #5C6576 }
281281
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -301,7 +301,7 @@
301301
span.pre {
302302
white-space: pre }
303303

304-
span.problematic {
304+
span.problematic, pre.problematic {
305305
color: red }
306306

307307
span.section-subtitle {
@@ -428,12 +428,21 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
428428
</li>
429429
<li><p class="first">Iván Antón &lt;<a class="reference external" href="mailto:ozono&#64;ozonomultimedia.com">ozono&#64;ozonomultimedia.com</a>&gt;</p>
430430
</li>
431+
<li><p class="first"><a class="reference external" href="https://www.sygel.es">Sygel Technology</a>:</p>
432+
<blockquote>
433+
<ul class="simple">
434+
<li>Valentin Vinagre</li>
435+
</ul>
436+
</blockquote>
437+
</li>
431438
</ul>
432439
</div>
433440
<div class="section" id="maintainers">
434441
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
435442
<p>This module is maintained by the OCA.</p>
436-
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
443+
<a class="reference external image-reference" href="https://odoo-community.org">
444+
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
445+
</a>
437446
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
438447
mission is to support the collaborative development of Odoo features and
439448
promote its widespread use.</p>

report_qweb_parameter/tests/test_report_qweb_parameter.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,18 @@ def test_qweb_parameter(self):
2424
docs.website = "1234567890" # for avoding that Odoo adds http://
2525
rep = report_object._render(report_name, docs.ids, False)
2626
root = ET.fromstring(rep[0])
27+
28+
# test length
2729
self.assertEqual(root[0].text, "1234567890")
28-
self.assertEqual(root[2].text, "1234567890")
29-
self.assertEqual(root[4].text, "1234567890")
30+
self.assertEqual(root[3].text, "1234567890")
31+
self.assertEqual(root[6].text, "1234567890")
32+
33+
# test condicional length
34+
self.assertEqual(root[1].text, "Tes")
35+
self.assertEqual(root[4].text, "Test")
36+
self.assertEqual(root[7].text, "Test ")
37+
38+
# test maxlength
3039
docs.update({"street": "123456789"})
3140
with self.assertRaises(QWebException):
3241
report_object._render(report_name, docs.ids, False)

0 commit comments

Comments
 (0)