Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
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
cooperatic-foodcoops
odoo
Commits
9ade24a4
Commit
9ade24a4
authored
Jul 01, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 2 parameters available in Odoo system parameters for products sale averages
parent
a72bfb41
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
__openerp__.py
lacagette_addons/lacagette_products/__openerp__.py
+5
-2
products.py
lacagette_addons/lacagette_products/models/products.py
+6
-2
No files found.
lacagette_addons/lacagette_products/__openerp__.py
View file @
9ade24a4
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
'name'
:
"La Cagette Products"
,
'name'
:
"La Cagette Products"
,
'summary'
:
"""
'summary'
:
"""
Retrieve data such as barcode for all available products (too long request with standard API)"""
,
Retrieve data such as barcode for all available products (too long request with standard API),
average sales (for products in purchase order for ex.)
"""
,
'description'
:
"""
'description'
:
"""
...
@@ -16,12 +18,13 @@
...
@@ -16,12 +18,13 @@
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
# for the full list
'category'
:
'Product'
,
'category'
:
'Product'
,
'version'
:
'0.0.
1
'
,
'version'
:
'0.0.
2
'
,
# any module necessary for this one to work correctly
# any module necessary for this one to work correctly
'depends'
:
[
'base'
,
'product'
],
'depends'
:
[
'base'
,
'product'
],
# always loaded
# always loaded
'data'
:
[
'data'
:
[
'data/ir_config_parameter_data.xml'
],
],
'installable'
:
True
,
'installable'
:
True
,
}
}
lacagette_addons/lacagette_products/models/products.py
View file @
9ade24a4
...
@@ -114,7 +114,9 @@ class LaCagetteProducts(models.Model):
...
@@ -114,7 +114,9 @@ class LaCagetteProducts(models.Model):
@days: list of full period days (except excluded one, such as sundays)
@days: list of full period days (except excluded one, such as sundays)
@return : integer days to remove from days number to compute average
@return : integer days to remove from days number to compute average
"""
"""
minimum_significative_consecutive_days
=
5
# arbitrary set (TODO ? : set it in odoo parameters)
conf
=
self
.
env
[
'ir.config_parameter'
]
minimum_significative_consecutive_days
=
\
conf
.
get_param
(
'lacagette_products.nb_of_consecutive_non_sale_days_considered_as_break'
)
consecutive_found
=
[]
# each serie is added to compute total of them
consecutive_found
=
[]
# each serie is added to compute total of them
missing_days
=
[]
missing_days
=
[]
for
d
in
days
:
for
d
in
days
:
...
@@ -188,6 +190,8 @@ class LaCagetteProducts(models.Model):
...
@@ -188,6 +190,8 @@ class LaCagetteProducts(models.Model):
@params: list of parameters ('ids', 'period', excluded_days)
@params: list of parameters ('ids', 'period', excluded_days)
@return: list (with list key or error key)
@return: list (with list key or error key)
"""
"""
conf
=
self
.
env
[
'ir.config_parameter'
]
delta_day
=
conf
.
get_param
(
'lacagette_products.nb_past_days_to_compute_sales_average'
)
res
=
{}
res
=
{}
if
'ids'
in
params
:
if
'ids'
in
params
:
ids
=
list
(
filter
(
lambda
x
:
isinstance
(
x
,
int
),
params
[
'ids'
]))
ids
=
list
(
filter
(
lambda
x
:
isinstance
(
x
,
int
),
params
[
'ids'
]))
...
@@ -204,7 +208,7 @@ class LaCagetteProducts(models.Model):
...
@@ -204,7 +208,7 @@ class LaCagetteProducts(models.Model):
if
'from'
in
params
:
if
'from'
in
params
:
dfrom
=
params
[
'from'
]
dfrom
=
params
[
'from'
]
else
:
else
:
dfrom
=
today
-
datetime
.
timedelta
(
50
)
dfrom
=
today
-
datetime
.
timedelta
(
delta_day
)
dfrom
=
dfrom
.
strftime
(
"
%
Y-
%
m-
%
d"
)
dfrom
=
dfrom
.
strftime
(
"
%
Y-
%
m-
%
d"
)
try
:
try
:
sql
=
"""
sql
=
"""
...
...
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