Commit e28f2ee2 by Yvon Kerdoncuff

in reception app, when filtering out products already present, compare by…

in reception app, when filtering out products already present, compare by template id and not by name (names are sometimes different)
parent d5cf2194
Pipeline #4208 failed with stage
in 0 seconds
......@@ -435,10 +435,18 @@ function fetch_suppliers_products() {
suppliers_products = data.res.products;
// 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_id[1] === p.name) === -1);
suppliers_products = suppliers_products.filter(p => [editing_product].findIndex(ep => ep.product_tmpl_id === p.id) === -1);
}
closeModal();
......
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