Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Redner Odoo Module
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XCG
Odoo modules
Redner Odoo Module
Commits
c7ee9e306253
Commit
c7ee9e306253
authored
3 weeks ago
by
Axel Prel
Browse files
Options
Downloads
Patches
Plain Diff
make ruff happier
parent
b9af52c79fd6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
models/redner_substitution.py
+36
-23
36 additions, 23 deletions
models/redner_substitution.py
with
36 additions
and
23 deletions
models/redner_substitution.py
+
36
−
23
View file @
c7ee9e30
...
...
@@ -48,6 +48,7 @@
(
CONSTANT
,
"
Constant value
"
),
]
DYNAMIC_PLACEHOLDER_ALLOWED_CONVERTERS
=
(
FIELD
,
MAIL_TEMPLATE
,
...
...
@@ -142,6 +143,38 @@
]
)
def
_build_field
(
self
,
sub
):
if
"
.
"
in
sub
.
value
:
path
,
name
=
sub
.
value
.
rsplit
(
"
.
"
,
1
)
else
:
path
,
name
=
None
,
sub
.
value
conv
=
converter
.
Field
(
name
)
if
path
:
conv
=
converter
.
relation
(
path
.
replace
(
"
.
"
,
"
/
"
),
conv
)
return
conv
def
_build_image
(
self
,
sub
):
if
"
.
"
in
sub
.
value
:
path
,
name
=
sub
.
value
.
rsplit
(
"
.
"
,
1
)
else
:
path
,
name
=
None
,
sub
.
value
conv
=
converter
.
ImageFile
(
name
)
if
path
:
conv
=
converter
.
relation
(
path
.
replace
(
"
.
"
,
"
/
"
),
conv
)
return
conv
def
_build_rel_2_many
(
self
,
sub
):
# Unpack the result of finding a field with its sort order into
# variable names.
value
,
sorted
=
parse_sorted_field
(
sub
.
value
)
conv
=
converter
.
RelationToMany
(
value
,
None
,
sortkey
=
sortkey
(
sorted
)
if
sorted
else
None
,
converter
=
sub
.
get_children
().
build_converter
(),
)
return
conv
def
build_converter
(
self
):
d
=
{}
for
sub
in
self
:
...
...
@@ -152,11 +185,5 @@
elif
sub
.
converter
==
CONSTANT
:
conv
=
converter
.
Constant
(
sub
.
value
)
elif
sub
.
converter
==
FIELD
:
if
"
.
"
in
sub
.
value
:
path
,
name
=
sub
.
value
.
rsplit
(
"
.
"
,
1
)
else
:
path
,
name
=
None
,
sub
.
value
conv
=
converter
.
Field
(
name
)
if
path
:
conv
=
converter
.
relation
(
path
.
replace
(
"
.
"
,
"
/
"
),
conv
)
conv
=
self
.
_build_field
(
sub
)
elif
sub
.
converter
==
IMAGE_FILE
:
...
...
@@ -162,11 +189,5 @@
elif
sub
.
converter
==
IMAGE_FILE
:
if
"
.
"
in
sub
.
value
:
path
,
name
=
sub
.
value
.
rsplit
(
"
.
"
,
1
)
else
:
path
,
name
=
None
,
sub
.
value
conv
=
converter
.
ImageFile
(
name
)
if
path
:
conv
=
converter
.
relation
(
path
.
replace
(
"
.
"
,
"
/
"
),
conv
)
conv
=
self
.
_build_image
(
sub
)
elif
sub
.
converter
==
IMAGE_DATAURL
:
conv
=
converter
.
ImageDataURL
(
sub
.
value
)
elif
sub
.
converter
==
QR_CODE_FILE
:
...
...
@@ -174,15 +195,7 @@
elif
sub
.
converter
==
QR_CODE_DATAURL
:
conv
=
converter
.
QRCodeDataURL
(
sub
.
value
)
elif
sub
.
converter
==
RELATION_2MANY
:
# Unpack the result of finding a field with its sort order into
# variable names.
value
,
sorted
=
parse_sorted_field
(
sub
.
value
)
conv
=
converter
.
RelationToMany
(
value
,
None
,
sortkey
=
sortkey
(
sorted
)
if
sorted
else
None
,
converter
=
sub
.
get_children
().
build_converter
(),
)
conv
=
self
.
_build_rel_2_many
(
sub
)
elif
sub
.
converter
==
RELATION_PATH
:
conv
=
converter
.
relation
(
sub
.
value
,
sub
.
get_children
().
build_converter
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment