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
64358d3332b7
Commit
64358d3332b7
authored
6 years ago
by
Christophe de Vienne
Browse files
Options
Downloads
Patches
Plain Diff
export: Fix deep relations
parent
ac35cc40b8b7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
export.py
+11
-7
11 additions, 7 deletions
export.py
tests/test_export.py
+20
-0
20 additions, 0 deletions
tests/test_export.py
with
31 additions
and
7 deletions
export.py
+
11
−
7
View file @
64358d33
...
...
@@ -71,4 +71,6 @@
if
source
is
not
None
:
path
=
source
.
split
(
"
.
"
)
cur_fields
=
fields
for
i
,
fname
in
enumerate
(
path
):
...
...
@@ -74,6 +76,6 @@
for
i
,
fname
in
enumerate
(
path
):
field
=
fields
[
fname
]
field
=
cur_
fields
[
fname
]
value_datatype
=
field
[
"
type
"
]
value
=
getattr
(
value
,
fname
)
...
...
@@ -76,13 +78,15 @@
value_datatype
=
field
[
"
type
"
]
value
=
getattr
(
value
,
fname
)
if
(
field
[
"
type
"
]
in
(
"
many2one
"
,
"
many2many
"
,
"
one2many
"
)
and
len
(
value
)
==
0
):
value
=
None
break
if
field
[
"
type
"
]
in
(
"
many2one
"
,
"
many2many
"
,
"
one2many
"
):
cur_fields
=
value
.
fields_get
()
if
len
(
value
)
==
0
:
value
=
None
break
# TODO for 2many relations, keep all the values
if
i
!=
len
(
path
)
-
1
:
value
=
value
[
0
]
if
field
[
"
type
"
]
in
(
"
char
"
,
"
text
"
)
and
value
is
False
:
value
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/test_export.py
+
20
−
0
View file @
64358d33
...
...
@@ -111,6 +111,26 @@
export
(
record
,
m
),
)
def
test_export_deep_relation
(
self
):
m
=
{
"
company
"
:
{
"
source
"
:
"
partner_ids.company_id
"
,
"
mapping
"
:
{
"
name
"
:
{}},
}
}
c1
=
self
.
env
[
"
res.partner.category
"
].
create
({
"
name
"
:
"
cat1
"
})
company
=
self
.
env
[
"
res.company
"
].
create
({
"
name
"
:
"
company
"
})
p1
=
self
.
env
[
"
res.partner
"
].
create
(
{
"
name
"
:
"
partner 1
"
,
"
company_id
"
:
company
.
id
}
)
c1
.
partner_ids
=
[
p1
.
id
]
self
.
assertEqual
({
"
company
"
:
{
"
name
"
:
"
company
"
}},
export
(
c1
,
m
))
def
test_export_custom_char
(
self
):
record
=
self
.
env
[
"
res.partner
"
].
create
({
"
name
"
:
"
my name
"
})
self
.
assertEqual
(
...
...
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