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
0
Merge Requests
0
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
Alexis AOUN
third-party
Commits
8fd36ac7
Commit
8fd36ac7
authored
Jun 30, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/sales_averages' into aide_a_la_commande
parents
20b89a57
6b43449d
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 @
8fd36ac7
...
@@ -457,6 +457,17 @@ class CagetteProducts(models.Model):
...
@@ -457,6 +457,17 @@ class CagetteProducts(models.Model):
return
bc_map
return
bc_map
@staticmethod
@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
):
def
get_products_by_supplier
(
supplier_id
):
api
=
OdooAPI
()
api
=
OdooAPI
()
res
=
{}
res
=
{}
...
@@ -494,6 +505,12 @@ class CagetteProducts(models.Model):
...
@@ -494,6 +505,12 @@ class CagetteProducts(models.Model):
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]]
c
=
[[
'id'
,
'in'
,
ptids
],
[
'purchase_ok'
,
'='
,
True
]]
products_t
=
api
.
search_read
(
'product.template'
,
c
,
f
)
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"
]
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
# Add supplier data to product data
for
i
,
fp
in
enumerate
(
filtered_products_t
):
for
i
,
fp
in
enumerate
(
filtered_products_t
):
...
@@ -503,10 +520,13 @@ class CagetteProducts(models.Model):
...
@@ -503,10 +520,13 @@ class CagetteProducts(models.Model):
'package_qty'
:
psi_item
[
"package_qty"
],
'package_qty'
:
psi_item
[
"package_qty"
],
'price'
:
psi_item
[
"price"
]
'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
res
[
"products"
]
=
filtered_products_t
except
Exception
as
e
:
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
)
res
[
"error"
]
=
str
(
e
)
return
res
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