Commit 285f694e by Damien Moulard

ALC: assign computed qty to supplier with highest priority

parent 5916f6b2
Pipeline #2272 passed with stage
in 1 minute 23 seconds
...@@ -331,7 +331,7 @@ ...@@ -331,7 +331,7 @@
margin: 15px 0; margin: 15px 0;
position: -webkit-sticky; position: -webkit-sticky;
position: sticky; position: sticky;
top: 140px; top: 120px;
z-index: 5; z-index: 5;
pointer-events: none; pointer-events: none;
} }
......
...@@ -298,9 +298,20 @@ function compute_and_affect_product_supplier_quantities(coeff, days) { ...@@ -298,9 +298,20 @@ function compute_and_affect_product_supplier_quantities(coeff, days) {
const daily_conso = product.daily_conso; const daily_conso = product.daily_conso;
let purchase_package_qty_for_coverage = compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days); let purchase_package_qty_for_coverage = compute_purchase_qty_for_coverage(product, coeff, stock, incoming_qty, daily_conso, days);
// Set qty to purchase for first supplier only
// Set qty to purchase for supplier with higher priority
let target_supplierinfo_index = 0;
let min_sequence = Number.POSITIVE_INFINITY; // min sequence = higher priority
for (let i in products[key].suppliersinfo) {
let suppliersinfo_sequence = products[key].suppliersinfo[i].sequence;
if (suppliersinfo_sequence < min_sequence) {
min_sequence = suppliersinfo_sequence;
target_supplierinfo_index = i;
}
}
products[key].suppliersinfo[0].qty = purchase_package_qty_for_coverage; products[key].suppliersinfo[target_supplierinfo_index].qty = purchase_package_qty_for_coverage;
} }
} }
} }
......
...@@ -607,7 +607,7 @@ class CagetteProducts(models.Model): ...@@ -607,7 +607,7 @@ class CagetteProducts(models.Model):
if supplier_ids is not None and len(supplier_ids) > 0: if supplier_ids is not None and len(supplier_ids) > 0:
# Get products/supplier relation # Get products/supplier relation
f = ["id", "product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name', 'product_code'] f = ["id", "product_tmpl_id", 'date_start', 'date_end', 'package_qty', 'price', 'name', 'product_code', 'sequence']
c = [['name', 'in', [ int(x) for x in supplier_ids]]] c = [['name', 'in', [ int(x) for x in supplier_ids]]]
psi = api.search_read('product.supplierinfo', c, f) psi = api.search_read('product.supplierinfo', c, f)
...@@ -669,7 +669,8 @@ class CagetteProducts(models.Model): ...@@ -669,7 +669,8 @@ class CagetteProducts(models.Model):
'supplier_id': int(psi_item["name"][0]), 'supplier_id': int(psi_item["name"][0]),
'package_qty': psi_item["package_qty"], 'package_qty': psi_item["package_qty"],
'price': psi_item["price"], 'price': psi_item["price"],
'product_code': psi_item["product_code"] 'product_code': psi_item["product_code"],
'sequence': psi_item["sequence"]
}) })
for s in sales: for s in sales:
......
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