Commit 9ade24a4 by François C.

Add 2 parameters available in Odoo system parameters for products sale averages

parent a72bfb41
......@@ -3,7 +3,9 @@
'name': "La Cagette Products",
'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': """
......@@ -16,12 +18,13 @@
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
# for the full list
'category': 'Product',
'version': '0.0.1',
'version': '0.0.2',
# any module necessary for this one to work correctly
'depends': ['base', 'product'],
# always loaded
'data': [
'data/ir_config_parameter_data.xml'
],
'installable': True,
}
......@@ -114,7 +114,9 @@ class LaCagetteProducts(models.Model):
@days: list of full period days (except excluded one, such as sundays)
@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
missing_days = []
for d in days:
......@@ -188,6 +190,8 @@ class LaCagetteProducts(models.Model):
@params: list of parameters ('ids', 'period', excluded_days)
@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 = {}
if 'ids' in params:
ids = list(filter(lambda x: isinstance(x, int), params['ids']))
......@@ -204,7 +208,7 @@ class LaCagetteProducts(models.Model):
if 'from' in params:
dfrom = params['from']
else:
dfrom = today - datetime.timedelta(50)
dfrom = today - datetime.timedelta(delta_day)
dfrom = dfrom.strftime("%Y-%m-%d")
try:
sql = """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment