Skip to content

Commit d7d029b

Browse files
committed
[FIX] correct doc formatting
closes #72 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent a74af0a commit d7d029b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/base/17.0.1.3/attr_domains2expr.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
2-
This file contains tools for making views compatible with Odoo 17. Two main changes are
3-
performed here:
2+
This file contains tools for making views compatible with Odoo 17.
3+
4+
Two main changes are performed here:
45
1. Convert `attrs` attributes of view elements from domains into Python expressions.
56
2. Remove `states` attribute, merge its logic into `invisible` attribute.
67
@@ -43,7 +44,9 @@ def migrate(cr, version):
4344

4445
def adapt_view(cr, view_xmlid):
4546
"""
46-
Example usage of the utilities in this script.
47+
Adapt one view.
48+
49+
Example usage of the utilities in this file.
4750
4851
We use `util.edit_view` because it handles the propagation of the changes to all
4952
languages while updating the whole arch. Alternatively you could just update specific
@@ -55,7 +58,6 @@ def adapt_view(cr, view_xmlid):
5558
IrUiView = util.env(cr)["ir.ui.view"].with_context(lang=lang)
5659
```
5760
"""
58-
5961
vid = util.ref(view_xmlid)
6062
IrUiView = util.env(cr)["ir.ui.view"]
6163
view = IrUiView.browse(vid)
@@ -90,9 +92,7 @@ class InvalidDomainError(Exception):
9092

9193

9294
class Ast2StrVisitor(ast._Unparser):
93-
"""
94-
Extend standard unparser to allow specific names to be replaced.
95-
"""
95+
"""Extend standard unparser to allow specific names to be replaced."""
9696

9797
def __init__(self, replace_names=None):
9898
self._replace_names = replace_names if replace_names else DEFAULT_CONTEXT_REPLACE
@@ -104,7 +104,9 @@ def visit_Name(self, node):
104104

105105
def mod2bool_str(s):
106106
"""
107-
Convert yes/no/true/false/on/off into True/False strings. Otherwise returns the input unchanged.
107+
Convert yes/no/true/false/on/off into True/False strings.
108+
109+
Otherwise returns the input unchanged.
108110
The checked values would raise an error instead if used in a Python expression.
109111
Note that 0 and 1 are left unchanged since they have the same True/False meaning in Python.
110112
"""
@@ -117,7 +119,7 @@ def mod2bool_str(s):
117119

118120

119121
def _clean_bool(s):
120-
"""Minimal simplification of trivial boolean expressions"""
122+
"""Minimal simplification of trivial boolean expressions."""
121123
return {
122124
"(1)": "1",
123125
"(0)": "0",
@@ -130,7 +132,9 @@ def _clean_bool(s):
130132

131133
def target_elem_and_view_type(elem, comb_arch):
132134
"""
133-
Find the target of an element. If there is no `comb_arch` or the element doesn't look like
135+
Find the target of an element.
136+
137+
If there is no `comb_arch` or the element doesn't look like
134138
targeting anything (no position attributes) assume the input `elem` is the target and return it.
135139
Along with the target we also return the view type of the elem, plus the field path from the
136140
arch root.
@@ -400,7 +404,8 @@ def fix_attrs(cr, model, arch, comb_arch):
400404

401405
def check_true_false(lv, ov, rv_ast):
402406
"""
403-
Returns True/False if the leaf (lp, op, rp) is something that can be considered as a True/False leaf.
407+
Return True/False if the leaf (lp, op, rp) is something that can be considered as a True/False leaf.
408+
404409
Otherwise returns None.
405410
"""
406411
ov = {"=": "==", "<>": "!="}.get(ov, ov)
@@ -432,7 +437,9 @@ def ast_term2domain_term(term):
432437

433438
def convert_attrs_val(cr, model, field_path, val):
434439
"""
435-
Convert an `attrs` value into a python formula. We need to use the AST representation because
440+
Convert an `attrs` value into a python formula.
441+
442+
We need to use the AST representation because
436443
values representing domains could be:
437444
* an if, or boolean, expression returning alternative domains
438445
* a string constant with the domain
@@ -516,6 +523,7 @@ def target_field_type(cr, model, path):
516523
def convert_domain_leaf(cr, model, field_path, leaf):
517524
"""
518525
Convert a domain leaf (tuple) into a python expression.
526+
519527
It always return the expression surrounded by parenthesis such that it's safe to use it as a sub-expression.
520528
"""
521529
if isinstance(leaf, bool):

0 commit comments

Comments
 (0)