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
ff8bc7e6
Commit
ff8bc7e6
authored
Aug 30, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update supplierinfo instead of creating a new onewhen reassociating
parent
8347a3c1
Pipeline
#1281
passed with stage
in 1 minute 21 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
oders_helper_style.css
orders/static/css/oders_helper_style.css
+1
-1
orders_helper.js
orders/static/js/orders_helper.js
+0
-0
models.py
products/models.py
+26
-1
No files found.
orders/static/css/oders_helper_style.css
View file @
ff8bc7e6
...
...
@@ -291,7 +291,7 @@
margin
:
30px
0
20px
0
;
position
:
-webkit-sticky
;
position
:
sticky
;
top
:
1
5
0px
;
top
:
1
4
0px
;
z-index
:
5
;
}
...
...
orders/static/js/orders_helper.js
View file @
ff8bc7e6
products/models.py
View file @
ff8bc7e6
...
...
@@ -137,6 +137,28 @@ class CagetteProduct(models.Model):
package_qty
=
data
[
"package_qty"
]
price
=
data
[
"price"
]
# Look for existing association
f
=
[
"id"
]
c
=
[[
'product_tmpl_id'
,
'='
,
product_tmpl_id
],
[
'name'
,
'='
,
partner_id
]]
res_existing_supplierinfo
=
api
.
search_read
(
'product.supplierinfo'
,
c
,
f
)
if
(
len
(
res_existing_supplierinfo
)
>
0
):
# A relation already exists, update it's start & end dates
psi_id
=
res_existing_supplierinfo
[
0
][
'id'
]
today
=
datetime
.
date
.
today
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
f
=
{
'date_start'
:
today
,
'date_end'
:
False
}
try
:
res
[
"update"
]
=
api
.
update
(
'product.supplierinfo'
,
psi_id
,
f
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
else
:
# Relation doesn't exists, create one
f
=
[
"id"
,
"standard_price"
,
"purchase_ok"
]
c
=
[[
'product_tmpl_id'
,
'='
,
product_tmpl_id
]]
res_products
=
api
.
search_read
(
'product.product'
,
c
,
f
)
...
...
@@ -174,7 +196,10 @@ class CagetteProduct(models.Model):
f
=
[
"id"
]
c
=
[[
'product_tmpl_id'
,
'='
,
product_tmpl_id
],
[
'name'
,
'='
,
partner_id
],
[
'date_end'
,
'='
,
False
]]
res_supplierinfo
=
api
.
search_read
(
'product.supplierinfo'
,
c
,
f
)
psi_id
=
res_supplierinfo
[
0
][
'id'
]
# End all active associations in case multiple are open (which shouldn't happen)
for
psi
in
res_supplierinfo
:
psi_id
=
psi
[
'id'
]
today
=
datetime
.
date
.
today
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
...
...
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