odoo-addon-base-view-inheritance-extension 16.0.1.0.0.11__py3-none-any.whl → 16.0.1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- odoo/addons/base_view_inheritance_extension/README.rst +33 -2
- odoo/addons/base_view_inheritance_extension/__manifest__.py +1 -1
- odoo/addons/base_view_inheritance_extension/models/ir_ui_view.py +115 -0
- odoo/addons/base_view_inheritance_extension/readme/CONTRIBUTORS.rst +6 -1
- odoo/addons/base_view_inheritance_extension/readme/USAGE.rst +26 -0
- odoo/addons/base_view_inheritance_extension/static/description/index.html +27 -3
- odoo/addons/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py +67 -0
- {odoo_addon_base_view_inheritance_extension-16.0.1.0.0.11.dist-info → odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info}/METADATA +34 -3
- {odoo_addon_base_view_inheritance_extension-16.0.1.0.0.11.dist-info → odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info}/RECORD +11 -11
- {odoo_addon_base_view_inheritance_extension-16.0.1.0.0.11.dist-info → odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info}/WHEEL +1 -1
- {odoo_addon_base_view_inheritance_extension-16.0.1.0.0.11.dist-info → odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info}/top_level.txt +0 -0
|
@@ -7,7 +7,7 @@ Extended view inheritance
|
|
|
7
7
|
!! This file is generated by oca-gen-addon-readme !!
|
|
8
8
|
!! changes will be overwritten. !!
|
|
9
9
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
-
!! source digest: sha256:
|
|
10
|
+
!! source digest: sha256:c4e765a621083d8bc3499b930418a7e00123f7228e93615dd74fe42b1b19af26
|
|
11
11
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
12
|
|
|
13
13
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
|
|
@@ -56,6 +56,32 @@ Usage
|
|
|
56
56
|
Note that views are subject to evaluation of xmlids anyways, so if you need
|
|
57
57
|
to refer to some xmlid, say ``%(xmlid)s``.
|
|
58
58
|
|
|
59
|
+
**Add text after and/or before than original**
|
|
60
|
+
|
|
61
|
+
.. code-block:: xml
|
|
62
|
+
|
|
63
|
+
<attribute name="$attribute" operation="text_add">
|
|
64
|
+
$text_before {old_value} $text_after
|
|
65
|
+
</attribute>
|
|
66
|
+
|
|
67
|
+
**Add domain with AND/OR join operator (AND if missed) allowing conditional changes**
|
|
68
|
+
|
|
69
|
+
.. code-block:: xml
|
|
70
|
+
|
|
71
|
+
<attribute name="$attribute" operation="domain_add"
|
|
72
|
+
condition="$field_condition" join_operator="OR">
|
|
73
|
+
$domain_to_add
|
|
74
|
+
</attribute>
|
|
75
|
+
|
|
76
|
+
**Add domain with AND/OR join operator (AND if missed) for key in attrs**
|
|
77
|
+
|
|
78
|
+
.. code-block:: xml
|
|
79
|
+
|
|
80
|
+
<attribute name="$attribute" operation="attrs_domain_add"
|
|
81
|
+
key="$attrs_key" join_operator="OR">
|
|
82
|
+
$domain_to_add_to_attrs_key
|
|
83
|
+
</attribute>
|
|
84
|
+
|
|
59
85
|
Known issues / Roadmap
|
|
60
86
|
======================
|
|
61
87
|
|
|
@@ -84,8 +110,13 @@ Contributors
|
|
|
84
110
|
|
|
85
111
|
* Holger Brunn <hbrunn@therp.nl>
|
|
86
112
|
* Ronald Portier <rportier@therp.nl>
|
|
87
|
-
*
|
|
113
|
+
* `Tecnativa <https://www.tecnativa.com>`_:
|
|
114
|
+
|
|
115
|
+
* Sergio Teruel
|
|
116
|
+
* Carlos Dauden
|
|
117
|
+
|
|
88
118
|
* Iván Todorovich <ivan.todorovich@camptocamp.com>
|
|
119
|
+
* Carlos Serra-Toro <carlos.serra@braintec.com>
|
|
89
120
|
|
|
90
121
|
Maintainers
|
|
91
122
|
~~~~~~~~~~~
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
|
4
4
|
{
|
|
5
5
|
"name": "Extended view inheritance",
|
|
6
|
-
"version": "16.0.1.
|
|
6
|
+
"version": "16.0.1.2.0",
|
|
7
7
|
"development_status": "Mature",
|
|
8
8
|
"author": "Therp BV,Odoo Community Association (OCA)",
|
|
9
9
|
"license": "LGPL-3",
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# Copyright 2016 Therp BV <https://therp.nl>
|
|
2
2
|
# Copyright 2018 Tecnativa - Sergio Teruel
|
|
3
3
|
# Copyright 2021 Camptocamp SA (https://www.camptocamp.com).
|
|
4
|
+
# Copyright 2023 Tecnativa - Carlos Dauden
|
|
4
5
|
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
|
|
5
6
|
|
|
6
7
|
import ast
|
|
8
|
+
import re
|
|
7
9
|
|
|
8
10
|
import astor
|
|
9
11
|
from lxml import etree
|
|
10
12
|
|
|
11
13
|
from odoo import api, models
|
|
14
|
+
from odoo.osv import expression
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
def ast_dict_update(source, update):
|
|
@@ -128,3 +131,115 @@ class IrUiView(models.Model):
|
|
|
128
131
|
pretty_source=lambda s: "".join(s).strip(),
|
|
129
132
|
)
|
|
130
133
|
return source
|
|
134
|
+
|
|
135
|
+
@api.model
|
|
136
|
+
def inheritance_handler_attributes_text_add(self, source, specs):
|
|
137
|
+
"""Implement
|
|
138
|
+
<$node position="attributes">
|
|
139
|
+
<attribute name="$attribute" operation="text_add">
|
|
140
|
+
$text_before {old_value} $text_after
|
|
141
|
+
</attribute>
|
|
142
|
+
</$node>"""
|
|
143
|
+
node = self.locate_node(source, specs)
|
|
144
|
+
for attribute_node in specs:
|
|
145
|
+
attribute_name = attribute_node.get("name")
|
|
146
|
+
old_value = node.get(attribute_name) or ""
|
|
147
|
+
node.attrib[attribute_name] = attribute_node.text.format(
|
|
148
|
+
old_value=old_value
|
|
149
|
+
)
|
|
150
|
+
return source
|
|
151
|
+
|
|
152
|
+
@api.model
|
|
153
|
+
def inheritance_handler_attributes_domain_add(self, source, specs):
|
|
154
|
+
"""Implement
|
|
155
|
+
<$node position="attributes">
|
|
156
|
+
<attribute name="$attribute" operation="domain_add"
|
|
157
|
+
condition="$field_condition" join_operator="OR">
|
|
158
|
+
$domain_to_add
|
|
159
|
+
</attribute>
|
|
160
|
+
</$node>"""
|
|
161
|
+
node = self.locate_node(source, specs)
|
|
162
|
+
for attribute_node in specs:
|
|
163
|
+
attribute_name = attribute_node.get("name")
|
|
164
|
+
condition = attribute_node.get("condition")
|
|
165
|
+
join_operator = attribute_node.get("join_operator") or "AND"
|
|
166
|
+
old_value = node.get(attribute_name) or ""
|
|
167
|
+
if old_value:
|
|
168
|
+
old_domain = ast.literal_eval(
|
|
169
|
+
self.var2str_domain_text(old_value.strip())
|
|
170
|
+
)
|
|
171
|
+
new_domain = ast.literal_eval(
|
|
172
|
+
self.var2str_domain_text(attribute_node.text.strip())
|
|
173
|
+
)
|
|
174
|
+
if join_operator == "OR":
|
|
175
|
+
new_value = str(expression.OR([old_domain, new_domain]))
|
|
176
|
+
else:
|
|
177
|
+
new_value = str(expression.AND([old_domain, new_domain]))
|
|
178
|
+
new_value = self.str2var_domain_text(new_value)
|
|
179
|
+
else:
|
|
180
|
+
# We must ensure that the domain definition has not line breaks because
|
|
181
|
+
# in update mode the domain cause an invalid syntax error
|
|
182
|
+
new_value = attribute_node.text.strip()
|
|
183
|
+
if condition:
|
|
184
|
+
new_value = "{condition} and {new_value} or {old_value}".format(
|
|
185
|
+
condition=condition,
|
|
186
|
+
new_value=new_value,
|
|
187
|
+
old_value=old_value or [],
|
|
188
|
+
)
|
|
189
|
+
node.attrib[attribute_name] = new_value
|
|
190
|
+
return source
|
|
191
|
+
|
|
192
|
+
@api.model
|
|
193
|
+
def inheritance_handler_attributes_attrs_domain_add(self, source, specs):
|
|
194
|
+
"""Implement attrs_domain_add
|
|
195
|
+
|
|
196
|
+
<attribute name="$attribute" operation="attrs_domain_add"
|
|
197
|
+
key="$attrs_key" join_operator="OR">
|
|
198
|
+
$domain_to_add_to_attrs_key
|
|
199
|
+
</attribute>
|
|
200
|
+
"""
|
|
201
|
+
node = self.locate_node(source, specs)
|
|
202
|
+
for attribute_node in specs:
|
|
203
|
+
attribute_name = attribute_node.get("name")
|
|
204
|
+
key = attribute_node.get("key")
|
|
205
|
+
join_operator = attribute_node.get("join_operator") or "AND"
|
|
206
|
+
old_value = node.get(attribute_name) or ""
|
|
207
|
+
if old_value:
|
|
208
|
+
old_value = ast.literal_eval(
|
|
209
|
+
self.var2str_domain_text(old_value.strip())
|
|
210
|
+
)
|
|
211
|
+
old_domain_attrs = old_value.get(key)
|
|
212
|
+
new_domain = ast.literal_eval(
|
|
213
|
+
self.var2str_domain_text(attribute_node.text.strip())
|
|
214
|
+
)
|
|
215
|
+
if join_operator == "OR":
|
|
216
|
+
new_value = expression.OR([old_domain_attrs, new_domain])
|
|
217
|
+
else:
|
|
218
|
+
new_value = expression.AND([old_domain_attrs, new_domain])
|
|
219
|
+
old_value[key] = new_value
|
|
220
|
+
new_value = self.str2var_domain_text(str(old_value))
|
|
221
|
+
else:
|
|
222
|
+
# We must ensure that the domain definition has not line breaks because
|
|
223
|
+
# in update mode the domain cause an invalid syntax error
|
|
224
|
+
new_value = "{'%s': %s}" % (key, attribute_node.text.strip())
|
|
225
|
+
node.attrib[attribute_name] = new_value
|
|
226
|
+
return source
|
|
227
|
+
|
|
228
|
+
@api.model
|
|
229
|
+
def var2str_domain_text(self, domain_str):
|
|
230
|
+
"""Replaces var names with str names to allow eval without defined vars"""
|
|
231
|
+
# Replace fields in 2 steps because 1 step returns "parent_sufix"."var_sufix"
|
|
232
|
+
regex_parent = re.compile(r"parent\.(\b\w+\b)")
|
|
233
|
+
domain_str = re.sub(
|
|
234
|
+
regex_parent, r"'parent.\1_is_a_var_to_replace'", domain_str
|
|
235
|
+
)
|
|
236
|
+
regex = re.compile(r"(?<!\')(\b\w+\b)(?!\')")
|
|
237
|
+
return re.sub(regex, r"'\1_is_a_var_to_replace'", domain_str)
|
|
238
|
+
|
|
239
|
+
@api.model
|
|
240
|
+
def str2var_domain_text(self, domain_str):
|
|
241
|
+
"""Revert var2str_domain_text cleaning apostrophes and suffix in vars"""
|
|
242
|
+
pattern = re.compile(r"'(parent\.[^']+)_is_a_var_to_replace'")
|
|
243
|
+
domain_str = pattern.sub(r"\1", domain_str)
|
|
244
|
+
pattern = re.compile(r"'([^']+)_is_a_var_to_replace'")
|
|
245
|
+
return pattern.sub(r"\1", domain_str)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
* Holger Brunn <hbrunn@therp.nl>
|
|
2
2
|
* Ronald Portier <rportier@therp.nl>
|
|
3
|
-
*
|
|
3
|
+
* `Tecnativa <https://www.tecnativa.com>`_:
|
|
4
|
+
|
|
5
|
+
* Sergio Teruel
|
|
6
|
+
* Carlos Dauden
|
|
7
|
+
|
|
4
8
|
* Iván Todorovich <ivan.todorovich@camptocamp.com>
|
|
9
|
+
* Carlos Serra-Toro <carlos.serra@braintec.com>
|
|
@@ -14,3 +14,29 @@
|
|
|
14
14
|
|
|
15
15
|
Note that views are subject to evaluation of xmlids anyways, so if you need
|
|
16
16
|
to refer to some xmlid, say ``%(xmlid)s``.
|
|
17
|
+
|
|
18
|
+
**Add text after and/or before than original**
|
|
19
|
+
|
|
20
|
+
.. code-block:: xml
|
|
21
|
+
|
|
22
|
+
<attribute name="$attribute" operation="text_add">
|
|
23
|
+
$text_before {old_value} $text_after
|
|
24
|
+
</attribute>
|
|
25
|
+
|
|
26
|
+
**Add domain with AND/OR join operator (AND if missed) allowing conditional changes**
|
|
27
|
+
|
|
28
|
+
.. code-block:: xml
|
|
29
|
+
|
|
30
|
+
<attribute name="$attribute" operation="domain_add"
|
|
31
|
+
condition="$field_condition" join_operator="OR">
|
|
32
|
+
$domain_to_add
|
|
33
|
+
</attribute>
|
|
34
|
+
|
|
35
|
+
**Add domain with AND/OR join operator (AND if missed) for key in attrs**
|
|
36
|
+
|
|
37
|
+
.. code-block:: xml
|
|
38
|
+
|
|
39
|
+
<attribute name="$attribute" operation="attrs_domain_add"
|
|
40
|
+
key="$attrs_key" join_operator="OR">
|
|
41
|
+
$domain_to_add_to_attrs_key
|
|
42
|
+
</attribute>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
1
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
2
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
4
3
|
<head>
|
|
@@ -367,7 +366,7 @@ ul.auto-toc {
|
|
|
367
366
|
!! This file is generated by oca-gen-addon-readme !!
|
|
368
367
|
!! changes will be overwritten. !!
|
|
369
368
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
370
|
-
!! source digest: sha256:
|
|
369
|
+
!! source digest: sha256:c4e765a621083d8bc3499b930418a7e00123f7228e93615dd74fe42b1b19af26
|
|
371
370
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
|
372
371
|
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-tools/tree/16.0/base_view_inheritance_extension"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-tools-16-0/server-tools-16-0-base_view_inheritance_extension"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
|
373
372
|
<p>This module was written to make it simple to add custom operators for view
|
|
@@ -400,6 +399,26 @@ inheritance.</p>
|
|
|
400
399
|
</pre>
|
|
401
400
|
<p>Note that views are subject to evaluation of xmlids anyways, so if you need
|
|
402
401
|
to refer to some xmlid, say <tt class="docutils literal">%(xmlid)s</tt>.</p>
|
|
402
|
+
<p><strong>Add text after and/or before than original</strong></p>
|
|
403
|
+
<pre class="code xml literal-block">
|
|
404
|
+
<span class="nt"><attribute</span><span class="w"> </span><span class="na">name=</span><span class="s">"$attribute"</span><span class="w"> </span><span class="na">operation=</span><span class="s">"text_add"</span><span class="nt">></span><span class="w">
|
|
405
|
+
</span>$text_before<span class="w"> </span>{old_value}<span class="w"> </span>$text_after<span class="w">
|
|
406
|
+
</span><span class="nt"></attribute></span>
|
|
407
|
+
</pre>
|
|
408
|
+
<p><strong>Add domain with AND/OR join operator (AND if missed) allowing conditional changes</strong></p>
|
|
409
|
+
<pre class="code xml literal-block">
|
|
410
|
+
<span class="nt"><attribute</span><span class="w"> </span><span class="na">name=</span><span class="s">"$attribute"</span><span class="w"> </span><span class="na">operation=</span><span class="s">"domain_add"</span><span class="w">
|
|
411
|
+
</span><span class="na">condition=</span><span class="s">"$field_condition"</span><span class="w"> </span><span class="na">join_operator=</span><span class="s">"OR"</span><span class="nt">></span><span class="w">
|
|
412
|
+
</span>$domain_to_add<span class="w">
|
|
413
|
+
</span><span class="nt"></attribute></span>
|
|
414
|
+
</pre>
|
|
415
|
+
<p><strong>Add domain with AND/OR join operator (AND if missed) for key in attrs</strong></p>
|
|
416
|
+
<pre class="code xml literal-block">
|
|
417
|
+
<span class="nt"><attribute</span><span class="w"> </span><span class="na">name=</span><span class="s">"$attribute"</span><span class="w"> </span><span class="na">operation=</span><span class="s">"attrs_domain_add"</span><span class="w">
|
|
418
|
+
</span><span class="na">key=</span><span class="s">"$attrs_key"</span><span class="w"> </span><span class="na">join_operator=</span><span class="s">"OR"</span><span class="nt">></span><span class="w">
|
|
419
|
+
</span>$domain_to_add_to_attrs_key<span class="w">
|
|
420
|
+
</span><span class="nt"></attribute></span>
|
|
421
|
+
</pre>
|
|
403
422
|
</div>
|
|
404
423
|
<div class="section" id="known-issues-roadmap">
|
|
405
424
|
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
|
|
@@ -428,8 +447,13 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|
|
428
447
|
<ul class="simple">
|
|
429
448
|
<li>Holger Brunn <<a class="reference external" href="mailto:hbrunn@therp.nl">hbrunn@therp.nl</a>></li>
|
|
430
449
|
<li>Ronald Portier <<a class="reference external" href="mailto:rportier@therp.nl">rportier@therp.nl</a>></li>
|
|
431
|
-
<li
|
|
450
|
+
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
|
451
|
+
<li>Sergio Teruel</li>
|
|
452
|
+
<li>Carlos Dauden</li>
|
|
453
|
+
</ul>
|
|
454
|
+
</li>
|
|
432
455
|
<li>Iván Todorovich <<a class="reference external" href="mailto:ivan.todorovich@camptocamp.com">ivan.todorovich@camptocamp.com</a>></li>
|
|
456
|
+
<li>Carlos Serra-Toro <<a class="reference external" href="mailto:carlos.serra@braintec.com">carlos.serra@braintec.com</a>></li>
|
|
433
457
|
</ul>
|
|
434
458
|
</div>
|
|
435
459
|
<div class="section" id="maintainers">
|
|
@@ -240,3 +240,70 @@ class TestBaseViewInheritanceExtension(TransactionCase):
|
|
|
240
240
|
)
|
|
241
241
|
with self.assertRaisesRegex(TypeError, "Attribute `domain` is not a dict"):
|
|
242
242
|
self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
|
|
243
|
+
|
|
244
|
+
def test_attrs_domain_add_join_operator_or(self):
|
|
245
|
+
"""Test that we can add an OR domain to an existing attrs key."""
|
|
246
|
+
self._test_attrs_domain_add(join_operator="OR")
|
|
247
|
+
|
|
248
|
+
def test_attrs_domain_add_join_operator_and(self):
|
|
249
|
+
"""Test that we can add an AND domain to an existing attrs key."""
|
|
250
|
+
self._test_attrs_domain_add(join_operator="AND")
|
|
251
|
+
|
|
252
|
+
def _test_attrs_domain_add(self, join_operator):
|
|
253
|
+
"""Test that we can add a domain to an existing attrs domain key."""
|
|
254
|
+
source = etree.fromstring(
|
|
255
|
+
"""
|
|
256
|
+
<form>
|
|
257
|
+
<field
|
|
258
|
+
name="ref"
|
|
259
|
+
attrs="{
|
|
260
|
+
'invisible': [('state', '=', 'draft')],
|
|
261
|
+
'required': [('state', '=', False)],
|
|
262
|
+
}"
|
|
263
|
+
/>
|
|
264
|
+
</form>
|
|
265
|
+
"""
|
|
266
|
+
)
|
|
267
|
+
specs = etree.fromstring(
|
|
268
|
+
"""
|
|
269
|
+
<field name="ref" position="attributes">
|
|
270
|
+
<attribute name="attrs" operation="attrs_domain_add"
|
|
271
|
+
key="required" join_operator="%s">
|
|
272
|
+
[('state', '!=', 'draft')]
|
|
273
|
+
</attribute>
|
|
274
|
+
</field>
|
|
275
|
+
"""
|
|
276
|
+
% (join_operator,)
|
|
277
|
+
)
|
|
278
|
+
res = self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
|
|
279
|
+
self.assertEqual(
|
|
280
|
+
res.xpath('//field[@name="ref"]')[0].attrib["attrs"],
|
|
281
|
+
"{'invisible': [('state', '=', 'draft')], "
|
|
282
|
+
"'required': ['%s', ('state', '=', False), ('state', '!=', 'draft')]}"
|
|
283
|
+
% ("|" if join_operator == "OR" else "&"),
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
def test_attrs_domain_add_no_attrs(self):
|
|
287
|
+
"""Test attrs_domain_add if there is no attrs: attrs is created."""
|
|
288
|
+
source = etree.fromstring(
|
|
289
|
+
"""
|
|
290
|
+
<form>
|
|
291
|
+
<field name="ref"/>
|
|
292
|
+
</form>
|
|
293
|
+
"""
|
|
294
|
+
)
|
|
295
|
+
specs = etree.fromstring(
|
|
296
|
+
"""
|
|
297
|
+
<field name="ref" position="attributes">
|
|
298
|
+
<attribute name="attrs" operation="attrs_domain_add"
|
|
299
|
+
key="required" join_operator="OR">
|
|
300
|
+
[('state', '!=', 'draft')]
|
|
301
|
+
</attribute>
|
|
302
|
+
</field>
|
|
303
|
+
"""
|
|
304
|
+
)
|
|
305
|
+
res = self.env["ir.ui.view"].apply_inheritance_specs(source, specs)
|
|
306
|
+
self.assertEqual(
|
|
307
|
+
res.xpath('//field[@name="ref"]')[0].attrib["attrs"],
|
|
308
|
+
"{'required': [('state', '!=', 'draft')]}",
|
|
309
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: odoo-addon-base-view-inheritance-extension
|
|
3
|
-
Version: 16.0.1.
|
|
3
|
+
Version: 16.0.1.2.0
|
|
4
4
|
Summary: Adds more operators for view inheritance
|
|
5
5
|
Home-page: https://github.com/OCA/server-tools
|
|
6
6
|
Author: Therp BV,Odoo Community Association (OCA)
|
|
@@ -25,7 +25,7 @@ Extended view inheritance
|
|
|
25
25
|
!! This file is generated by oca-gen-addon-readme !!
|
|
26
26
|
!! changes will be overwritten. !!
|
|
27
27
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
28
|
-
!! source digest: sha256:
|
|
28
|
+
!! source digest: sha256:c4e765a621083d8bc3499b930418a7e00123f7228e93615dd74fe42b1b19af26
|
|
29
29
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
30
30
|
|
|
31
31
|
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
|
|
@@ -74,6 +74,32 @@ Usage
|
|
|
74
74
|
Note that views are subject to evaluation of xmlids anyways, so if you need
|
|
75
75
|
to refer to some xmlid, say ``%(xmlid)s``.
|
|
76
76
|
|
|
77
|
+
**Add text after and/or before than original**
|
|
78
|
+
|
|
79
|
+
.. code-block:: xml
|
|
80
|
+
|
|
81
|
+
<attribute name="$attribute" operation="text_add">
|
|
82
|
+
$text_before {old_value} $text_after
|
|
83
|
+
</attribute>
|
|
84
|
+
|
|
85
|
+
**Add domain with AND/OR join operator (AND if missed) allowing conditional changes**
|
|
86
|
+
|
|
87
|
+
.. code-block:: xml
|
|
88
|
+
|
|
89
|
+
<attribute name="$attribute" operation="domain_add"
|
|
90
|
+
condition="$field_condition" join_operator="OR">
|
|
91
|
+
$domain_to_add
|
|
92
|
+
</attribute>
|
|
93
|
+
|
|
94
|
+
**Add domain with AND/OR join operator (AND if missed) for key in attrs**
|
|
95
|
+
|
|
96
|
+
.. code-block:: xml
|
|
97
|
+
|
|
98
|
+
<attribute name="$attribute" operation="attrs_domain_add"
|
|
99
|
+
key="$attrs_key" join_operator="OR">
|
|
100
|
+
$domain_to_add_to_attrs_key
|
|
101
|
+
</attribute>
|
|
102
|
+
|
|
77
103
|
Known issues / Roadmap
|
|
78
104
|
======================
|
|
79
105
|
|
|
@@ -102,8 +128,13 @@ Contributors
|
|
|
102
128
|
|
|
103
129
|
* Holger Brunn <hbrunn@therp.nl>
|
|
104
130
|
* Ronald Portier <rportier@therp.nl>
|
|
105
|
-
*
|
|
131
|
+
* `Tecnativa <https://www.tecnativa.com>`_:
|
|
132
|
+
|
|
133
|
+
* Sergio Teruel
|
|
134
|
+
* Carlos Dauden
|
|
135
|
+
|
|
106
136
|
* Iván Todorovich <ivan.todorovich@camptocamp.com>
|
|
137
|
+
* Carlos Serra-Toro <carlos.serra@braintec.com>
|
|
107
138
|
|
|
108
139
|
Maintainers
|
|
109
140
|
~~~~~~~~~~~
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
odoo/addons/base_view_inheritance_extension/README.rst,sha256=
|
|
1
|
+
odoo/addons/base_view_inheritance_extension/README.rst,sha256=okC1jdR_GYFuR9Tr8GvOiUefgK-aaC-UM77nhVUo1c0,4371
|
|
2
2
|
odoo/addons/base_view_inheritance_extension/__init__.py,sha256=X9EJGOE2GtZbS0G82PtSXmWSZ_R8jEM0rlJTDliQjp4,21
|
|
3
|
-
odoo/addons/base_view_inheritance_extension/__manifest__.py,sha256=
|
|
3
|
+
odoo/addons/base_view_inheritance_extension/__manifest__.py,sha256=fsbbfjJlG3SMKHd5YCZrpLSgLTPMBeKmvezriCvtlQQ,616
|
|
4
4
|
odoo/addons/base_view_inheritance_extension/demo/ir_ui_view.xml,sha256=MHPVOGOM6XnNOTsq0ylz1B5r0sPJpRKHLan3K2mZ6sA,1200
|
|
5
5
|
odoo/addons/base_view_inheritance_extension/i18n/base_view_inheritance_extension.pot,sha256=fs9N7L3F1tQYphJ4_BoE725z8zXA0ULVEIW4-qsQRTw,1031
|
|
6
6
|
odoo/addons/base_view_inheritance_extension/i18n/ca.po,sha256=7ncEf2XfOWoOIlU7jysZhKYtd1KEF7oUHABgxJeEm9Q,1443
|
|
@@ -12,16 +12,16 @@ odoo/addons/base_view_inheritance_extension/i18n/it.po,sha256=342XK5tLJJavpToQ_T
|
|
|
12
12
|
odoo/addons/base_view_inheritance_extension/i18n/sl.po,sha256=YjMtgl3N0bkOH8ngh_FMy7m-vxpNXt12WWiHYSmnFhY,1446
|
|
13
13
|
odoo/addons/base_view_inheritance_extension/i18n/tr.po,sha256=S3G6M2N5DNbiTpctuhlJ14hfKa_BJ_v0Ju-4cHu7eQQ,1453
|
|
14
14
|
odoo/addons/base_view_inheritance_extension/models/__init__.py,sha256=SjKfc8ocbCImvP5DpGQbS0hWmQRYPjtzJdyio6TPII0,25
|
|
15
|
-
odoo/addons/base_view_inheritance_extension/models/ir_ui_view.py,sha256=
|
|
16
|
-
odoo/addons/base_view_inheritance_extension/readme/CONTRIBUTORS.rst,sha256=
|
|
15
|
+
odoo/addons/base_view_inheritance_extension/models/ir_ui_view.py,sha256=xhYckU6Jc1TT8WdlkMFKmefZ5dGsuxJ12vzaX1ZwTJA,9843
|
|
16
|
+
odoo/addons/base_view_inheritance_extension/readme/CONTRIBUTORS.rst,sha256=er1wsP0tAgTprk5TY_A9qnHgOIfb9-v9CgD6ooWGifg,252
|
|
17
17
|
odoo/addons/base_view_inheritance_extension/readme/DESCRIPTION.rst,sha256=pamURJDYfLUcZtHl0ZvXTtzKO1LvHlhhYIND05AMzbk,88
|
|
18
18
|
odoo/addons/base_view_inheritance_extension/readme/ROADMAP.rst,sha256=Cz02ovrYCAgtqjY3nTSnikVgWaKPcWLP-bsuJxCTlKw,56
|
|
19
|
-
odoo/addons/base_view_inheritance_extension/readme/USAGE.rst,sha256=
|
|
19
|
+
odoo/addons/base_view_inheritance_extension/readme/USAGE.rst,sha256=qVIT8mE5xZVenXbqbWFEqx9bwbF4w-2jgEzdBYKSkAg,1099
|
|
20
20
|
odoo/addons/base_view_inheritance_extension/static/description/icon.png,sha256=6xBPJauaFOF0KDHfHgQopSc28kKvxMaeoQFQWZtfZDo,9455
|
|
21
|
-
odoo/addons/base_view_inheritance_extension/static/description/index.html,sha256=
|
|
21
|
+
odoo/addons/base_view_inheritance_extension/static/description/index.html,sha256=p0idwN891buQdlNvHDT9RGBMBk2tQ3UdTkI4Z5hKZSs,16318
|
|
22
22
|
odoo/addons/base_view_inheritance_extension/tests/__init__.py,sha256=kTcGsgnWhpM7vII3sEdNX5XVxDHHqRc5KdrxInG6GSw,51
|
|
23
|
-
odoo/addons/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py,sha256=
|
|
24
|
-
odoo_addon_base_view_inheritance_extension-16.0.1.
|
|
25
|
-
odoo_addon_base_view_inheritance_extension-16.0.1.
|
|
26
|
-
odoo_addon_base_view_inheritance_extension-16.0.1.
|
|
27
|
-
odoo_addon_base_view_inheritance_extension-16.0.1.
|
|
23
|
+
odoo/addons/base_view_inheritance_extension/tests/test_base_view_inheritance_extension.py,sha256=4_43OP09f63VK-3B_iErrGqUj_UCcC4p6I3_YibhP_g,11114
|
|
24
|
+
odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info/METADATA,sha256=xJtJzP_G3jdF9n6o3J3uyWvQbNlf3aWmw36GZRShf58,5010
|
|
25
|
+
odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
26
|
+
odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info/top_level.txt,sha256=qBj40grFkGOfDZ2WDSw3y1RnDlgG0u8rP8pvGNdbz4w,5
|
|
27
|
+
odoo_addon_base_view_inheritance_extension-16.0.1.2.0.dist-info/RECORD,,
|