Commit 1988c674 by Alexis Aoun

Refactor et renommage de variable

parent da42e4c6
......@@ -68,64 +68,51 @@ function searchUpdatedProduct() {
function select_product_from_bc(barcode) {
try {
if (editing_product == null) {
var p = barcodes.get_corresponding_odoo_product(barcode);
var qtyIsWeight = false;
var qtyIsPriceToWeight = false;
var scannedProduct = barcodes.get_corresponding_odoo_product(barcode);
priceToWeightIsCorrect = true;
console.log(p);
if (p == null) {
if (scannedProduct == null) {
alert("Le code-barre " + barcode + " ne correspond à aucun article connu.");
return -1;
}
var found = {data: null, place: null};
console.log(p.rule);
if(p.rule == 'weight')
qtyIsWeight = true;
else if(p.rule == 'price_to_weight')
qtyIsPriceToWeight = true;
var foundProduct = {data: null, place: null};
$.each(list_to_process, function(i, e) {
if (e.product_id[0] == p.data[barcodes['keys']['id']]) {
found.data = e;
found.place = 'to_process';
if (e.product_id[0] == scannedProduct.data[barcodes['keys']['id']]) {
foundProduct.data = e;
foundProduct.place = 'to_process';
}
});
if (found.data == null) {
if (foundProduct.data == null) {
$.each(list_processed, function(i, e) {
if (e.product_id[0] == p.data[barcodes['keys']['id']]) {
found.data = JSON.parse(JSON.stringify(e));
found.place = 'processed';
if (e.product_id[0] == scannedProduct.data[barcodes['keys']['id']]) {
foundProduct.data = JSON.parse(JSON.stringify(e));
foundProduct.place = 'processed';
}
});
}
if(qtyIsWeight)
found.data.product_qty = p.qty;
if(scannedProduct.rule == 'weight')
foundProduct.data.product_qty = scannedProduct.qty;
else if(qtyIsPriceToWeight){
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(found, p));
setupPopUpBtnStyle(p);
else if(scannedProduct.rule == 'price_to_weight'){
openModal($('#templates #modal_confirm_price_to_weight').html(), price_to_weight_is_wrong, 'Non', false, true, price_to_weight_confirmed_callback(foundProduct, scannedProduct));
setupPopUpBtnStyle(scannedProduct);
}
if(found.data !== null && !qtyIsPriceToWeight){
if(qtyIsWeight)
editProductInfo(found.data, found.data.product_qty);
if(foundProduct.data !== null && !(scannedProduct.rule == 'price_to_weight')){
if(scannedProduct.rule == 'weight')
editProductInfo(foundProduct.data, foundProduct.data.product_qty);
else
setLineEdition(found.data);
if (found.place === 'to_process') {
let row = table_to_process.row($('#'+found.data.product_id[0]));
setLineEdition(foundProduct.data);
remove_from_toProcess(row, found.data);
if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
remove_from_toProcess(row, foundProduct.data);
}
}
}
......
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