Commit 48148aa3 by Damien Moulard

Merge branch '4950-scan-in-reception-evolutions-bis' into 'dev_cooperatic'

meet new specs for normal barcodes while keeping existing special barcode logic

See merge request !244
parents f28b87c4 de1e3940
Pipeline #3002 failed with stage
in 1 minute 7 seconds
......@@ -100,17 +100,25 @@ function select_product_from_bc(barcode) {
priceToWeightIsCorrect = true;
if (scannedProduct == null) {
alert("Le code-barre " + barcode + " ne correspond à aucun article connu.");
alert(
"Article introuvable.\n" +
"Le code barre " + barcode + " n'est associé à aucun article." +
" Mettez ce produit de côté et prévenez un salarié.\n" +
"ATTENTION : A la fin de la réception, ne validez pas tant que ce colis n'a pas été ajouté par le salarié.e."
);
return -1;
}
var foundProduct = {data: null, place: null};
var qtyOfProcessedProduct = null;
var product_id = null;
// Does the product come from to_process ?
$.each(list_to_process, function(i, e) {
if (e.product_id[0] == scannedProduct.data[barcodes['keys']['id']]) {
foundProduct.data = e;
product_id = e.product_id[0];
foundProduct.place = 'to_process';
}
});
......@@ -120,6 +128,8 @@ function select_product_from_bc(barcode) {
$.each(list_processed, function(i, e) {
if (e.product_id[0] == scannedProduct.data[barcodes['keys']['id']]) {
foundProduct.data = JSON.parse(JSON.stringify(e));
qtyOfProcessedProduct = foundProduct.data.product_qty;
product_id = e.product_id[0];
foundProduct.data.product_qty = null; // Set qty to null from product already scanned
foundProduct.place = 'processed';
}
......@@ -141,9 +151,15 @@ function select_product_from_bc(barcode) {
if (scannedProduct.rule !== 'price_to_weight') {
if (foundProduct.data.product_uom[0] != 21) {
setLineEdition(foundProduct.data);
if(foundProduct.place == 'processed') {
//https://redmine.coopdev.fr/issues/4820 specs
foundProduct.data.product_qty = qtyOfProcessedProduct;
alert("Attention, "+qtyOfProcessedProduct+" unités de mesure de ce produit ont déjà été comptées.");
$('#'+product_id+' > td > #processed_line_edit').click();
} else { //place == to_process
$('#'+product_id+' > td > .toProcess_line_edit').click();
}
} else {
if (foundProduct.place === 'to_process') {
let row = table_to_process.row($('#'+foundProduct.data.product_id[0]));
......@@ -152,6 +168,16 @@ function select_product_from_bc(barcode) {
// Don't remove product from processed list
}
}
} else {
//product found in odoo but it's not in this receipt
alert(
"Article trouvé non concerné par cette réception.\n" +
"Le code barre " + barcode + " n'est associé à aucun article de cette réception." +
" Mettez ce produit de côté et prévenez un salarié.\n" +
"ATTENTION : A la fin de la réception, ne validez pas tant que ce colis n'a pas été ajouté par le salarié.e"
);
return -1;
}
}
} catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'select_product_from_bc'};
......@@ -374,6 +400,11 @@ function fetch_data(po_ids = null) {
// Load barcodes at page loading, then barcodes are stored locally
var get_barcodes = async function() {
if (barcodes == null) barcodes = await init_barcodes();
//A partial test of https://redmine.coopdev.fr/issues/4950 without scanner : choose barcode and uncomment following line.
//If you paste this line in the console, the focus().select() will not work, but it will work in real conditions
//select_product_from_bc("0493408000008");
//select_product_from_bc("0490010008521");
//select_product_from_bc("0490010008651");
};
// Get labels to print for current orders from server
......@@ -817,6 +848,7 @@ function initLists() {
$('table.dataTable').DataTable()
.search('')
.draw();
$("#edition_input").focus().select();
}
} catch (e) {
err = {msg: e.name + ' : ' + e.message, ctx: 'initLists : listener edit line from list to process'};
......@@ -874,6 +906,7 @@ function initLists() {
$('table.dataTable').DataTable()
.search('')
.draw();
$("#edition_input").focus().select();
}
} catch (e) {
err = {
......
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