Commit 34d61306 by Yvon Kerdoncuff

Merge branch '7819-prevent-adding-product-already-in-order' into 'migration-v12'

7819 prevent adding product already in order

See merge request !286
parents e75db440 e28f2ee2
Pipeline #4213 failed with stage
...@@ -435,8 +435,19 @@ function fetch_suppliers_products() { ...@@ -435,8 +435,19 @@ function fetch_suppliers_products() {
suppliers_products = data.res.products; suppliers_products = data.res.products;
// Filter supplier products on products already in orders // Filter supplier products on products already in orders
suppliers_products = suppliers_products.filter(p => list_to_process.findIndex(ptp => ptp.product_id[1] === p.name) === -1);
suppliers_products = suppliers_products.filter(p => list_processed.findIndex(pp => pp.product_id[1] === p.name) === -1); // Be careful as comparing names may not work due to get_lines accessing name of product which calls _name_get of product.product
// therefore adding [code] before the name of the product, which is different from, for example, product.supplier_info.name.
// Comparing product templates instead of products itself may seem weird as a product template may have several variants,
// however the code fetching suppliers_products actually fetches product templates and not variants.
// On 2024-04-11 for la cagette, there is only one product template with several variants, and it does not seem to be used.
suppliers_products = suppliers_products.filter(p => list_to_process.findIndex(ptp => ptp.product_tmpl_id === p.id) === -1);
suppliers_products = suppliers_products.filter(p => list_processed.findIndex(pp => pp.product_tmpl_id === p.id) === -1);
if(editing_product) {
suppliers_products = suppliers_products.filter(p => [editing_product].findIndex(ep => ep.product_tmpl_id === p.id) === -1);
}
closeModal(); closeModal();
set_add_products_modal(); set_add_products_modal();
......
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