Commit 925944d8 by François C.

Merge branch '3265-ALC-allocate-qties-to-first-supplier' into 'dev_cooperatic'

ALC: assign computed qty to supplier with highest priority

See merge request !186
parents 4f71500f 285f694e
Pipeline #2274 passed with stage
in 1 minute 24 seconds
......@@ -331,7 +331,7 @@
margin: 15px 0;
position: -webkit-sticky;
position: sticky;
top: 140px;
top: 120px;
z-index: 5;
pointer-events: none;
}
......
......@@ -298,9 +298,20 @@ function compute_and_affect_product_supplier_quantities(coeff, days) {
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);
// 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):
if supplier_ids is not None and len(supplier_ids) > 0:
# 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]]]
psi = api.search_read('product.supplierinfo', c, f)
......@@ -669,7 +669,8 @@ class CagetteProducts(models.Model):
'supplier_id': int(psi_item["name"][0]),
'package_qty': psi_item["package_qty"],
'price': psi_item["price"],
'product_code': psi_item["product_code"]
'product_code': psi_item["product_code"],
'sequence': psi_item["sequence"]
})
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