Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
third-party
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
261
Issues
261
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul
third-party
Commits
5a034993
Commit
5a034993
authored
Aug 02, 2021
by
Alexis AOUN
Committed by
Paul 🐻
Aug 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Détection automatique du poids par l'appli reception
parent
4e6a8a29
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
17 deletions
+100
-17
reception_produits.js
reception/static/js/reception_produits.js
+94
-17
reception_produits.html
templates/reception/reception_produits.html
+6
-0
No files found.
reception/static/js/reception_produits.js
View file @
5a034993
...
...
@@ -30,7 +30,8 @@ var reception_status = null,
updatedProducts
=
[],
// Keep record of updated products
validProducts
=
[],
// Keep record of directly validated products
updateType
=
""
,
// step 1: qty_valid; step2: br_valid
barcodes
=
null
;
// Barcodes stored locally
barcodes
=
null
,
// Barcodes stored locally
priceToWeightIsCorrect
=
true
;
var
dbc
=
null
,
sync
=
null
,
...
...
@@ -67,38 +68,55 @@ function searchUpdatedProduct() {
function
select_product_from_bc
(
barcode
)
{
try
{
if
(
editing_product
==
null
)
{
let
p
=
barcodes
.
get_corresponding_odoo_product
(
barcode
);
var
scannedProduct
=
barcodes
.
get_corresponding_odoo_product
(
barcode
);
if
(
p
==
null
)
{
priceToWeightIsCorrect
=
true
;
if
(
scannedProduct
==
null
)
{
alert
(
"Le code-barre "
+
barcode
+
" ne correspond à aucun article connu."
);
return
-
1
;
}
var
found
=
{
data
:
null
,
place
:
null
};
var
found
Product
=
{
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'
]])
{
found
Product
.
data
=
e
;
found
Product
.
place
=
'to_process'
;
}
});
if
(
found
.
data
==
null
)
{
if
(
found
Product
.
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'
]])
{
found
Product
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
e
));
found
Product
.
place
=
'processed'
;
}
});
}
if
(
found
.
data
!==
null
)
{
setLineEdition
(
found
.
data
);
if
(
found
.
place
===
'to_process'
)
{
let
row
=
table_to_process
.
row
(
$
(
'#'
+
found
.
data
.
product_id
[
0
]));
if
(
foundProduct
.
data
!==
null
)
{
if
(
foundProduct
.
data
.
product_uom
[
0
]
==
21
)
{
//if qty is in weight
if
(
scannedProduct
.
rule
===
'weight'
)
{
editing_product
=
foundProduct
.
data
;
editProductInfo
(
foundProduct
.
data
,
scannedProduct
.
qty
);
editing_product
=
null
;
}
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
(
scannedProduct
.
rule
!==
'price_to_weight'
)
{
if
(
foundProduct
.
data
.
product_uom
[
0
]
!=
21
)
{
setLineEdition
(
foundProduct
.
data
);
}
if
(
foundProduct
.
place
===
'to_process'
)
{
let
row
=
table_to_process
.
row
(
$
(
'#'
+
foundProduct
.
data
.
product_id
[
0
]));
remove_from_toProcess
(
row
,
found
.
data
);
remove_from_toProcess
(
row
,
foundProduct
.
data
);
}
}
}
}
...
...
@@ -156,6 +174,65 @@ function update_distant_orders() {
});
}
function
price_to_weight_confirmed_callback
(
foundProduct
,
scannedProduct
)
{
return
function
()
{
let
newQty
=
null
;
if
(
priceToWeightIsCorrect
)
{
newQty
=
scannedProduct
.
qty
;
}
else
{
let
tmp
=
Number
((
scannedProduct
.
value
/
document
.
getElementById
(
"new_price_to_weight"
).
value
).
toFixed
(
3
));
if
(
isFinite
(
tmp
))
{
newQty
=
tmp
;
}
}
if
(
foundProduct
.
data
!==
null
&&
newQty
!=
null
)
{
if
(
foundProduct
.
place
===
'to_process'
)
{
let
row
=
table_to_process
.
row
(
$
(
'#'
+
foundProduct
.
data
.
product_id
[
0
]));
remove_from_toProcess
(
row
,
foundProduct
.
data
);
}
editing_product
=
foundProduct
.
data
;
editProductInfo
(
foundProduct
.
data
,
newQty
);
editing_product
=
null
;
resetPopUpButtons
();
}
};
}
function
price_to_weight_is_wrong
()
{
document
.
getElementById
(
"new_price_to_weight"
).
style
.
display
=
""
;
document
.
getElementsByClassName
(
"btn--success"
)[
0
].
style
.
display
=
"none"
;
document
.
querySelector
(
'#modal_closebtn_bottom'
).
innerHTML
=
'OK'
;
priceToWeightIsCorrect
=
false
;
}
function
setupPopUpBtnStyle
(
p
)
{
//On inverse en quelque sorte les boutons succes et d'annulation en mettant "Oui" sur le btn d'annulation
// et "Non" sur le bouton de reussite.
//Cela nous permet de reecrire moins de code puisque si la reponse est Oui on ne veut
//rien modifier et sortir du pop up, ce qui correspond au comportement du bouton annulation
//(ou aussi appeler cancel button)
document
.
querySelector
(
'#modal_closebtn_bottom'
).
innerHTML
=
'Oui'
;
document
.
getElementById
(
"modal_closebtn_bottom"
).
style
.
backgroundColor
=
"green"
;
document
.
getElementsByClassName
(
"btn--success"
)[
0
].
style
.
backgroundColor
=
"red"
;
document
.
querySelector
(
'#product_to_verify'
).
innerHTML
=
p
.
data
[
0
];
document
.
querySelector
(
'#price_to_verify'
).
innerHTML
=
p
.
data
[
6
];
document
.
getElementById
(
"new_price_to_weight"
).
style
.
display
=
"none"
;
document
.
getElementsByClassName
(
"btn--success"
)[
0
].
style
.
display
=
""
;
}
function
resetPopUpButtons
()
{
document
.
getElementsByClassName
(
"btn--success"
)[
0
].
style
.
display
=
""
;
document
.
getElementsByClassName
(
"btn--success"
)[
0
].
style
.
backgroundColor
=
""
;
document
.
querySelector
(
'#modal_closebtn_bottom'
).
style
.
backgroundColor
=
""
;
}
/* INIT */
// Get order(s) data from server
...
...
@@ -870,7 +947,7 @@ function editProductInfo (productToEdit, value = null, batch = false) {
if
(
e
.
product_id
[
0
]
==
productToEdit
.
product_id
[
0
])
{
addition
=
true
;
productToEdit
=
e
;
newValue
=
newValue
+
productToEdit
.
product_qty
;
newValue
=
Number
((
newValue
+
productToEdit
.
product_qty
).
toFixed
(
3
))
;
}
});
// If qty edition & Check if qty changed
...
...
templates/reception/reception_produits.html
View file @
5a034993
...
...
@@ -177,6 +177,12 @@
<div
id=
"modal_FAQ_content"
></div>
<div
id=
"modal_qtiesValidated"
></div>
<div
id=
"modal_pricesValidated"
></div>
<div
id=
"modal_confirm_price_to_weight"
>
<h3>
Confirmation du prix
</h3>
<p>
Est ce que le prix au kilo du produit
<b><span
id=
"product_to_verify"
></span></b>
est bien
<b><span
id=
"price_to_verify"
></span></b>
euros/Kg ?
</p>
<input
type=
"number"
name=
"Prix au Kilo"
id=
"new_price_to_weight"
>
</div>
</div>
<br/>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment