Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Odoo scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container 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 scripts
Commits
9559e8b292df
Commit
9559e8b292df
authored
5 years ago
by
Vincent Hatakeyama
Browse files
Options
Downloads
Patches
Plain Diff
improve error handling in import_jsonrpc to help finding problems in import file
parent
1e540bc281fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
odoo_scripts/import_jsonrpc.py
+14
-2
14 additions, 2 deletions
odoo_scripts/import_jsonrpc.py
with
14 additions
and
2 deletions
odoo_scripts/import_jsonrpc.py
+
14
−
2
View file @
9559e8b2
...
...
@@ -7,6 +7,8 @@
import
sys
from
typing
import
Callable
,
Dict
,
List
,
Tuple
,
Union
from
odoorpc.error
import
RPCError
from
.
import
logging_from_verbose
,
odoo_connect_parser
,
odoo_login
from
.importing
import
add_importing_file_parsing
,
extract_info_from_parsed
...
...
@@ -54,6 +56,8 @@
imf_ids
=
imf
.
search
(
[(
"
model
"
,
"
=
"
,
model
),
(
"
name
"
,
"
=
"
,
field_name
)]
)
if
not
imf_ids
:
raise
Exception
(
"
No field {} in {}
"
.
format
(
field_name
,
model
))
return
imf
.
browse
(
imf_ids
)[
0
]
def
_convert_identity
(
value
):
...
...
@@ -157,7 +161,11 @@
write_id
=
_ref
(
xmlid
,
False
)
if
write_id
:
_logger
.
debug
(
"
Write %s (%d)
"
,
model
,
write_id
)
o
.
env
[
model
].
write
(
write_id
,
values
)
try
:
o
.
env
[
model
].
write
(
write_id
,
values
)
except
RPCError
:
_logger
.
error
(
"
Current values: %s
"
,
values
)
raise
wrote
.
append
(
write_id
)
else
:
_logger
.
debug
(
"
Creating a %s
"
,
model
)
...
...
@@ -161,7 +169,11 @@
wrote
.
append
(
write_id
)
else
:
_logger
.
debug
(
"
Creating a %s
"
,
model
)
created_id
=
o
.
env
[
model
].
create
(
values
)
try
:
created_id
=
o
.
env
[
model
].
create
(
values
)
except
RPCError
:
_logger
.
error
(
"
Current values: %s
"
,
values
)
raise
created
.
append
(
created_id
)
if
xmlid
:
_logger
.
debug
(
...
...
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