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
6b43449d
Commit
6b43449d
authored
Jun 29, 2021
by
François
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add average sales to supplier products
parent
32241a99
Pipeline
#1112
failed with stage
in 1 minute 19 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletions
+21
-1
models.py
products/models.py
+21
-1
No files found.
products/models.py
View file @
6b43449d
...
...
@@ -451,6 +451,17 @@ class CagetteProducts(models.Model):
return
bc_map
@staticmethod
def
get_template_products_sales_average
(
params
=
{}):
api
=
OdooAPI
()
res
=
{}
try
:
res
=
api
.
execute
(
'lacagette.products'
,
'get_template_products_sales_average'
,
params
)
except
Exception
as
e
:
coop_logger
.
error
(
'get_template_products_sales_average
%
s (
%
s)'
,
str
(
e
),
str
(
params
))
res
[
"error"
]
=
str
(
e
)
return
res
@staticmethod
def
get_products_by_supplier
(
supplier_id
):
api
=
OdooAPI
()
res
=
{}
...
...
@@ -488,6 +499,12 @@ class CagetteProducts(models.Model):
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]]
products_t
=
api
.
search_read
(
'product.template'
,
c
,
f
)
filtered_products_t
=
[
p
for
p
in
products_t
if
p
[
"state"
]
!=
"end"
and
p
[
"state"
]
!=
"obsolete"
]
# sales = CagetteProducts.get_template_products_sales_average({'ids': ptids, 'from': '2020-06-10', 'to': '2020-08-10'})
sales
=
CagetteProducts
.
get_template_products_sales_average
({
'ids'
:
ptids
})
if
'list'
in
sales
and
len
(
sales
[
'list'
])
>
0
:
sales
=
sales
[
'list'
]
else
:
sales
=
[]
# Add supplier data to product data
for
i
,
fp
in
enumerate
(
filtered_products_t
):
...
...
@@ -497,10 +514,13 @@ class CagetteProducts(models.Model):
'package_qty'
:
psi_item
[
"package_qty"
],
'price'
:
psi_item
[
"price"
]
}]
for
s
in
sales
:
if
s
[
"id"
]
==
fp
[
"id"
]:
filtered_products_t
[
i
][
'per_day_qty'
]
=
s
[
"average_qty"
]
res
[
"products"
]
=
filtered_products_t
except
Exception
as
e
:
print
(
str
(
e
))
coop_logger
.
error
(
'get_products_by_supplier
%
s (
%
s)'
,
str
(
e
),
str
(
supplier_id
))
res
[
"error"
]
=
str
(
e
)
return
res
...
...
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