Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
third-party
Commits
21df373f
Commit
21df373f
authored
Dec 21, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add context to odoo api update
parent
b479fafd
Pipeline
#1679
passed with stage
in 1 minute 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
common.py
outils/common.py
+5
-2
models.py
products/models.py
+1
-3
No files found.
outils/common.py
View file @
21df373f
...
@@ -47,7 +47,7 @@ class OdooAPI:
...
@@ -47,7 +47,7 @@ class OdooAPI:
order
=
'id ASC'
):
order
=
'id ASC'
):
"""Main api request, retrieving data according search conditions."""
"""Main api request, retrieving data according search conditions."""
fields_and_context
=
{
'fields'
:
fields
,
fields_and_context
=
{
'fields'
:
fields
,
'context'
:
{
'lang'
:
'fr_FR'
,
'tz'
:
'Europe/Paris'
},
'context'
:
{
'lang'
:
'fr_FR'
,
'tz'
:
'Europe/Paris'
},
'limit'
:
limit
,
'limit'
:
limit
,
'offset'
:
offset
,
'offset'
:
offset
,
'order'
:
order
'order'
:
order
...
@@ -59,8 +59,11 @@ class OdooAPI:
...
@@ -59,8 +59,11 @@ class OdooAPI:
def
update
(
self
,
entity
,
ids
,
fields
):
def
update
(
self
,
entity
,
ids
,
fields
):
"""Update entities which have ids, with new fields values."""
"""Update entities which have ids, with new fields values."""
context
=
{
'context'
:
{
'lang'
:
'fr_FR'
,
'tz'
:
'Europe/Paris'
}
}
return
self
.
models
.
execute_kw
(
self
.
db
,
self
.
uid
,
self
.
passwd
,
return
self
.
models
.
execute_kw
(
self
.
db
,
self
.
uid
,
self
.
passwd
,
entity
,
'write'
,
[
ids
,
fields
])
entity
,
'write'
,
[
ids
,
fields
]
,
context
)
def
create
(
self
,
entity
,
fields
):
def
create
(
self
,
entity
,
fields
):
"""Create entity instance with given fields values."""
"""Create entity instance with given fields values."""
...
...
products/models.py
View file @
21df373f
...
@@ -268,17 +268,15 @@ class CagetteProduct(models.Model):
...
@@ -268,17 +268,15 @@ class CagetteProduct(models.Model):
f
[
'name'
]
=
data
[
'name'
]
if
(
'[NPA]'
in
data
[
'name'
])
else
data
[
'name'
]
+
" [NPA]"
f
[
'name'
]
=
data
[
'name'
]
if
(
'[NPA]'
in
data
[
'name'
])
else
data
[
'name'
]
+
" [NPA]"
f
[
'purchase_ok'
]
=
0
f
[
'purchase_ok'
]
=
0
elif
'[NPA]'
in
data
[
'name'
]:
elif
'[NPA]'
in
data
[
'name'
]:
#
Remove [NPA] from name
# Remove [NPA] from name
f
[
'name'
]
=
re
.
sub
(
r'( \[NPA\])'
,
''
,
data
[
'name'
])
f
[
'name'
]
=
re
.
sub
(
r'( \[NPA\])'
,
''
,
data
[
'name'
])
current_name
=
data
[
'name'
]
if
(
'name'
not
in
f
)
else
f
[
'name'
]
current_name
=
data
[
'name'
]
if
(
'name'
not
in
f
)
else
f
[
'name'
]
if
'fds-in-name'
in
data
[
'npa'
]:
if
'fds-in-name'
in
data
[
'npa'
]:
f
[
'name'
]
=
current_name
if
'[FDS]'
in
data
[
'name'
]
else
current_name
+
" [FDS]"
f
[
'name'
]
=
current_name
if
'[FDS]'
in
data
[
'name'
]
else
current_name
+
" [FDS]"
f
[
'purchase_ok'
]
=
0
f
[
'purchase_ok'
]
=
0
elif
'[FDS]'
in
current_name
:
elif
'[FDS]'
in
current_name
:
f
[
'name'
]
=
re
.
sub
(
r'( \[FDS\])'
,
''
,
current_name
)
f
[
'name'
]
=
re
.
sub
(
r'( \[FDS\])'
,
''
,
current_name
)
if
len
(
data
[
'npa'
])
==
0
:
if
len
(
data
[
'npa'
])
==
0
:
f
[
'purchase_ok'
]
=
1
f
[
'purchase_ok'
]
=
1
res
[
"update"
]
=
api
.
update
(
'product.template'
,
data
[
'id'
],
f
)
res
[
"update"
]
=
api
.
update
(
'product.template'
,
data
[
'id'
],
f
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment