Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Xbus emitter
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
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
Xbus emitter
Commits
b459804f
Commit
b459804f
authored
6 years ago
by
Christophe de Vienne
Browse files
Options
Downloads
Patches
Plain Diff
export: Test and implement export of string fiels
parent
f0223fde
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
export.py
+22
-1
22 additions, 1 deletion
export.py
pyproject.toml
+2
-0
2 additions, 0 deletions
pyproject.toml
tests/__init__.py
+1
-0
1 addition, 0 deletions
tests/__init__.py
tests/test_export.py
+17
-0
17 additions, 0 deletions
tests/test_export.py
with
42 additions
and
1 deletion
export.py
+
22
−
1
View file @
b459804f
...
...
@@ -23,4 +23,25 @@
are not yet supported, unless the same mapping applies to all the types.
More complex cases should be handled with ``custom``.
"""
return
{}
fields
=
record
.
fields_get
()
output
=
{}
for
key
,
options
in
mapping
.
items
():
source
,
custom
,
mapping
=
options
.
get
(
'
source
'
),
options
.
get
(
'
custom
'
),
options
.
get
(
'
mapping
'
)
if
source
is
None
and
custom
is
None
:
source
=
key
if
source
is
not
None
:
field
=
fields
[
source
]
value
=
getattr
(
record
,
source
)
if
value
is
False
:
value
=
None
output
[
key
]
=
value
return
output
This diff is collapsed.
Click to expand it.
pyproject.toml
0 → 100644
+
2
−
0
View file @
b459804f
[tool.black]
line-length
=
79
This diff is collapsed.
Click to expand it.
tests/__init__.py
+
1
−
0
View file @
b459804f
# flake8: noqa
from
.
import
test_xbus_emitter
from
.
import
test_export
This diff is collapsed.
Click to expand it.
tests/test_export.py
0 → 100644
+
17
−
0
View file @
b459804f
import
odoo
from
..export
import
export
from
.util.odoo_tests
import
TestBase
@odoo.tests.common.at_install
(
False
)
@odoo.tests.common.post_install
(
True
)
class
Test
(
TestBase
):
def
test_export_string_field
(
self
):
record
=
self
.
env
[
"
res.partner
"
].
create
({
"
name
"
:
"
my name
"
})
self
.
assertEqual
(
{
"
name
"
:
"
my name
"
,
"
company
"
:
None
},
export
(
record
,
{
"
name
"
:
{},
"
company
"
:
{
"
source
"
:
"
company_name
"
}}
),
)
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