Commit 8b25f8a3 by Damien Moulard

fix add one product

parent da96a62e
...@@ -468,7 +468,7 @@ class CagetteProducts(models.Model): ...@@ -468,7 +468,7 @@ class CagetteProducts(models.Model):
try: try:
today = datetime.date.today().strftime("%Y-%m-%d") today = datetime.date.today().strftime("%Y-%m-%d")
if len(supplier_ids) > 0: if supplier_ids is not None and len(supplier_ids) > 0:
# Get products/supplier relation # Get products/supplier relation
f = ["product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name'] f = ["product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name']
c = [['name', 'in', [ int(x) for x in supplier_ids]]] c = [['name', 'in', [ int(x) for x in supplier_ids]]]
...@@ -503,8 +503,8 @@ class CagetteProducts(models.Model): ...@@ -503,8 +503,8 @@ class CagetteProducts(models.Model):
sales_average_params = { sales_average_params = {
'ids': ptids, 'ids': ptids,
'from': '2019-04-10', # 'from': '2019-04-10',
'to': '2019-08-10', # 'to': '2019-08-10',
} }
sales = CagetteProducts.get_template_products_sales_average(sales_average_params) sales = CagetteProducts.get_template_products_sales_average(sales_average_params)
...@@ -515,7 +515,7 @@ class CagetteProducts(models.Model): ...@@ -515,7 +515,7 @@ class CagetteProducts(models.Model):
# 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):
if len(supplier_ids) > 0: if supplier_ids is not None and len(supplier_ids) > 0:
psi_item = next(item for item in psi if item["product_tmpl_id"] is not False and item["product_tmpl_id"][0] == fp["id"]) psi_item = next(item for item in psi if item["product_tmpl_id"] is not False and item["product_tmpl_id"][0] == fp["id"])
filtered_products_t[i]['suppliersinfo'] = [{ filtered_products_t[i]['suppliersinfo'] = [{
'supplier_id': int(psi_item["name"][0]), 'supplier_id': int(psi_item["name"][0]),
......
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