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
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
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
cooperatic-foodcoops
third-party
Commits
b174700f
Commit
b174700f
authored
Jul 05, 2022
by
François C.
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2937-REC-update-qty-in-2nd-step' into 'dev_cooperatic'
2937 rec update qty in 2nd step See merge request
!189
parents
707b2289
bf02619f
Pipeline
#2295
passed with stage
in 1 minute 26 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
432 additions
and
253 deletions
+432
-253
config_lacagette.py
coops_configurations/config_lacagette.py
+1
-0
config.md
outils/config.md
+4
-0
reception_style.css
reception/static/css/reception_style.css
+29
-19
reception_produits.js
reception/static/js/reception_produits.js
+396
-234
views.py
reception/views.py
+1
-0
reception_produits.html
templates/reception/reception_produits.html
+1
-0
No files found.
coops_configurations/config_lacagette.py
View file @
b174700f
...
@@ -56,6 +56,7 @@ EM_URL = ''
...
@@ -56,6 +56,7 @@ EM_URL = ''
RECEPTION_MERGE_ORDERS_PSWD
=
'jpsrcp'
RECEPTION_MERGE_ORDERS_PSWD
=
'jpsrcp'
RECEPTION_ADD_PRODUCTS_PSWD
=
'jpsrcp'
RECEPTION_ADD_PRODUCTS_PSWD
=
'jpsrcp'
RECEPTION_UPDATE_QTY_PSWD
=
'jpsrcp'
RECEPTION_PB
=
"Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris.
\
RECEPTION_PB
=
"Ici, vous pouvez signaler toute anomalie lors d'une réception, les produits non commandés, cassés ou pourris.
\
Merci d'indiquer un maximum d'informations, le nom du produit et son code barre."
Merci d'indiquer un maximum d'informations, le nom du produit et son code barre."
DISPLAY_COL_AUTRES
=
False
DISPLAY_COL_AUTRES
=
False
...
...
outils/config.md
View file @
b174700f
...
@@ -357,6 +357,10 @@
...
@@ -357,6 +357,10 @@
Password to enter to add products to an order during reception
Password to enter to add products to an order during reception
Same principle as previous pswd
Same principle as previous pswd
-
RECEPTION_UPDATE_QTY_PSWD = 'pass2makeApause'
Password to update a product qty during prices update.
-
RECEPTION_PDT_LABELS_BTN_TEXT = 'Lancer l
\'
impression'
-
RECEPTION_PDT_LABELS_BTN_TEXT = 'Lancer l
\'
impression'
-
RECEPTION_PDT_LABELS_FN = 'print_product_labels()'
-
RECEPTION_PDT_LABELS_FN = 'print_product_labels()'
...
...
reception/static/css/reception_style.css
View file @
b174700f
...
@@ -280,6 +280,35 @@ tr.odd td.row_product_no_qty {
...
@@ -280,6 +280,35 @@ tr.odd td.row_product_no_qty {
background-color
:
#acb3c2
;
background-color
:
#acb3c2
;
}
}
#error_report
{
width
:
100%
;
height
:
200px
;
border
:
2px
solid
#555
;
border-radius
:
10px
;
white-space
:
pre-wrap
;
}
#main_content
{
width
:
100%
;}
.select_product_action
{
max-width
:
5px
;
}
.toProcess_line_edit
,
.toProcess_line_valid
{
min-width
:
11px
;
}
.product_qty_cell
{
cursor
:
pointer
;
}
.product_qty_cell
:hover
{
background-color
:
#e7e9ed
;
}
td
.row_product_no_qty.product_qty_cell
:hover
{
background-color
:
#db9129
;
}
/* Accordion style */
/* Accordion style */
/* Style the buttons that are used to open and close the accordion panel */
/* Style the buttons that are used to open and close the accordion panel */
...
@@ -327,21 +356,3 @@ hr {
...
@@ -327,21 +356,3 @@ hr {
.panel.active
:after
{
.panel.active
:after
{
margin-bottom
:
30px
;
margin-bottom
:
30px
;
}
}
#error_report
{
width
:
100%
;
height
:
200px
;
border
:
2px
solid
#555
;
border-radius
:
10px
;
white-space
:
pre-wrap
;
}
#main_content
{
width
:
100%
;}
.select_product_action
{
max-width
:
5px
;
}
.toProcess_line_edit
,
.toProcess_line_valid
{
min-width
:
11px
;
}
\ No newline at end of file
reception/static/js/reception_produits.js
View file @
b174700f
...
@@ -32,7 +32,8 @@ var reception_status = null,
...
@@ -32,7 +32,8 @@ var reception_status = null,
barcodes
=
null
,
// Barcodes stored locally
barcodes
=
null
,
// Barcodes stored locally
priceToWeightIsCorrect
=
true
,
priceToWeightIsCorrect
=
true
,
suppliers_products
=
[],
// All products of current order(s) supplier(s)
suppliers_products
=
[],
// All products of current order(s) supplier(s)
products_to_add
=
[];
// Products to add to order
products_to_add
=
[],
// Products to add to order
re_editing_qty
=
false
;
// During prices edition, edit qty mode enabled
var
dbc
=
null
,
var
dbc
=
null
,
sync
=
null
,
sync
=
null
,
...
@@ -495,6 +496,13 @@ function initLists() {
...
@@ -495,6 +496,13 @@ function initLists() {
});
});
}
}
// Titles for Qty column
const
base_qty_title
=
"Qté"
;
const
qty_title_tooltip
=
`<div class="tooltip tt_twolines">
Qté
<span class="tooltiptext">Qté comptée / Qté commandée</span>
</div>`
;
columns_to_process
=
columns_to_process
.
concat
([
columns_to_process
=
columns_to_process
.
concat
([
{
data
:
"product_id.0"
,
title
:
"id"
,
visible
:
false
},
{
data
:
"product_id.0"
,
title
:
"id"
,
visible
:
false
},
{
data
:
"shelf_sortorder"
,
title
:
"Rayon"
,
className
:
"dt-body-center"
,
width
:
"4%"
},
{
data
:
"shelf_sortorder"
,
title
:
"Rayon"
,
className
:
"dt-body-center"
,
width
:
"4%"
},
...
@@ -529,8 +537,8 @@ function initLists() {
...
@@ -529,8 +537,8 @@ function initLists() {
},
},
{
{
data
:
"product_qty"
,
data
:
"product_qty"
,
title
:
"Qté"
,
title
:
(
reception_status
==
"qty_valid"
)
?
qty_title_tooltip
:
base_qty_title
,
className
:
"dt-body-center"
,
className
:
(
reception_status
==
"qty_valid"
)
?
"dt-body-center product_qty_cell"
:
"dt-body-center"
,
width
:
"5%"
,
width
:
"5%"
,
render
:
function
(
data
,
type
,
full
)
{
render
:
function
(
data
,
type
,
full
)
{
if
(
reception_status
==
"False"
)
{
if
(
reception_status
==
"False"
)
{
...
@@ -604,8 +612,8 @@ function initLists() {
...
@@ -604,8 +612,8 @@ function initLists() {
{
data
:
"product_uom.1"
,
title
:
"Unité vente"
,
className
:
"dt-body-center"
,
orderable
:
false
,
width
:
"5%"
},
{
data
:
"product_uom.1"
,
title
:
"Unité vente"
,
className
:
"dt-body-center"
,
orderable
:
false
,
width
:
"5%"
},
{
{
data
:
"product_qty"
,
data
:
"product_qty"
,
title
:
"Qté"
,
title
:
qty_title_tooltip
,
className
:
"dt-head-center dt-body-center"
,
className
:
(
reception_status
==
"qty_valid"
)
?
"dt-head-center dt-body-center product_qty_cell"
:
"dt-head-center dt-body-center"
,
width
:
"5%"
,
width
:
"5%"
,
// visible: (reception_status == "False"),
// visible: (reception_status == "False"),
render
:
function
(
data
,
type
,
full
)
{
render
:
function
(
data
,
type
,
full
)
{
...
@@ -648,17 +656,30 @@ function initLists() {
...
@@ -648,17 +656,30 @@ function initLists() {
}
}
];
];
table_to_process_ordering
=
[
[
0
,
"asc"
]
];
// For grouped orders, order first by number of order, then by product id
if
(
is_grouped_order
())
{
table_to_process_ordering
.
push
(
[
1
,
"asc"
]
)
}
// Init table for to_process content
// Init table for to_process content
table_to_process
=
$
(
'#table_to_process'
).
DataTable
({
table_to_process
=
$
(
'#table_to_process'
).
DataTable
({
data
:
list_to_process
,
data
:
list_to_process
,
columns
:
columns_to_process
,
columns
:
columns_to_process
,
rowId
:
"product_id.0"
,
rowId
:
"product_id.0"
,
order
:
[
order
:
table_to_process_ordering
,
[
0
,
"asc"
]
],
scrollY
:
"33vh"
,
scrollY
:
"33vh"
,
scrollCollapse
:
true
,
scrollCollapse
:
true
,
paging
:
false
,
paging
:
false
,
...
@@ -895,6 +916,68 @@ function initLists() {
...
@@ -895,6 +916,68 @@ function initLists() {
clearLineEdition
();
clearLineEdition
();
}
}
});
});
$
(
'#table_to_process tbody'
).
on
(
'click'
,
'.product_qty_cell'
,
function
()
{
// Prevent editing mutiple lines at a time
if
(
editing_product
==
null
)
{
let
pswd
=
prompt
(
'Mot de passe requis pour éditer la quantité de ce produit'
);
if
(
pswd
==
update_qty_pswd
)
{
// Password ok, edit product qty
let
row
=
table_to_process
.
row
(
$
(
this
).
parents
(
'tr'
));
let
data
=
row
.
data
();
// Product goes to editing
editing_origin
=
"to_process"
;
re_editing_qty
=
true
;
setLineEdition
(
data
);
remove_from_toProcess
(
row
,
data
);
document
.
getElementById
(
'search_input'
).
value
=
''
;
$
(
'table.dataTable'
).
DataTable
()
.
search
(
''
)
.
draw
();
}
else
if
(
pswd
==
null
)
{
return
;
}
else
{
alert
(
'Mauvais mot de passe !'
);
}
}
else
{
alert
(
"Il y a déjà un produit dans la zone d'édition. Terminez d'abord d'éditer ce produit."
)
}
});
$
(
'#table_processed tbody'
).
on
(
'click'
,
'.product_qty_cell'
,
function
()
{
// Prevent editing mutiple lines at a time
if
(
editing_product
==
null
)
{
let
pswd
=
prompt
(
'Mot de passe requis pour éditer la quantité de ce produit'
);
if
(
pswd
==
update_qty_pswd
)
{
// Password ok, edit product qty
let
row
=
table_processed
.
row
(
$
(
this
).
parents
(
'tr'
));
let
data
=
row
.
data
();
// Product goes to editing
editing_origin
=
"processed"
;
re_editing_qty
=
true
;
setLineEdition
(
data
);
remove_from_processed
(
row
,
data
);
document
.
getElementById
(
'search_input'
).
value
=
''
;
$
(
'table.dataTable'
).
DataTable
()
.
search
(
''
)
.
draw
();
}
else
if
(
pswd
==
null
)
{
return
;
}
else
{
alert
(
'Mauvais mot de passe !'
);
}
}
else
{
alert
(
"Il y a déjà un produit dans la zone d'édition. Terminez d'abord d'éditer ce produit."
)
}
});
}
}
// Add a line to to_process
// Add a line to to_process
...
@@ -1076,23 +1159,23 @@ function set_supplier_shortage(row, product, from_processed = false) {
...
@@ -1076,23 +1159,23 @@ function set_supplier_shortage(row, product, from_processed = false) {
/* EDITION */
/* EDITION */
// Set edition
// Set edition
area
function
setLineEdition
(
product
)
{
function
setLineEdition
(
product
)
{
editing_product
=
product
;
editing_product
=
product
;
// name
// name
document
.
getElementById
(
'product_name'
).
innerHTML
=
editing_product
.
product_id
[
1
];
document
.
getElementById
(
'product_name'
).
innerHTML
=
editing_product
.
product_id
[
1
];
// intput
// intput
if
(
reception_status
==
"qty_valid"
)
if
(
reception_status
==
'False'
||
re_editing_qty
===
true
)
document
.
getElementById
(
'edition_input'
).
value
=
editing_product
.
price_unit
;
else
document
.
getElementById
(
'edition_input'
).
value
=
editing_product
.
product_qty
;
document
.
getElementById
(
'edition_input'
).
value
=
editing_product
.
product_qty
;
else
document
.
getElementById
(
'edition_input'
).
value
=
editing_product
.
price_unit
;
document
.
getElementById
(
"edition_input"
).
focus
();
document
.
getElementById
(
"edition_input"
).
focus
();
// uom
// uom
if
(
editing_product
.
product_uom
[
0
]
==
1
)
{
// Unit
if
(
editing_product
.
product_uom
[
0
]
==
1
)
{
// Unit
if
(
reception_status
==
'False'
)
{
if
(
reception_status
==
'False'
||
re_editing_qty
===
true
)
{
document
.
getElementById
(
'product_uom'
).
innerHTML
=
' unité(s)'
;
document
.
getElementById
(
'product_uom'
).
innerHTML
=
' unité(s)'
;
$
(
'#edition_input'
).
attr
(
'type'
,
'number'
)
$
(
'#edition_input'
).
attr
(
'type'
,
'number'
)
.
attr
(
'step'
,
1
)
.
attr
(
'step'
,
1
)
...
@@ -1104,7 +1187,7 @@ function setLineEdition(product) {
...
@@ -1104,7 +1187,7 @@ function setLineEdition(product) {
.
attr
(
'max'
,
9999
);
.
attr
(
'max'
,
9999
);
}
}
}
else
if
(
editing_product
.
product_uom
[
0
]
==
21
)
{
// kg
}
else
if
(
editing_product
.
product_uom
[
0
]
==
21
)
{
// kg
if
(
reception_status
==
'False'
)
{
if
(
reception_status
==
'False'
||
re_editing_qty
===
true
)
{
document
.
getElementById
(
'product_uom'
).
innerHTML
=
' kg'
;
document
.
getElementById
(
'product_uom'
).
innerHTML
=
' kg'
;
$
(
'#edition_input'
).
attr
(
'type'
,
'number'
)
$
(
'#edition_input'
).
attr
(
'type'
,
'number'
)
.
attr
(
'step'
,
0.001
)
.
attr
(
'step'
,
0.001
)
...
@@ -1117,6 +1200,12 @@ function setLineEdition(product) {
...
@@ -1117,6 +1200,12 @@ function setLineEdition(product) {
}
}
}
}
// If editing qty during prices edition
if
(
re_editing_qty
===
true
)
{
document
.
getElementById
(
'edition_header'
).
innerHTML
=
"Ré-éditer la quantité"
;
document
.
getElementById
(
'edition_input_label'
).
innerHTML
=
"Qté"
;
}
// Make edition area blink when edition button clicked
// Make edition area blink when edition button clicked
container_edition
.
classList
.
add
(
'blink_me'
);
container_edition
.
classList
.
add
(
'blink_me'
);
}
}
...
@@ -1130,6 +1219,13 @@ function clearLineEdition() {
...
@@ -1130,6 +1219,13 @@ function clearLineEdition() {
document
.
getElementById
(
'edition_input'
).
value
=
null
;
document
.
getElementById
(
'edition_input'
).
value
=
null
;
document
.
getElementById
(
'search_input'
).
focus
();
document
.
getElementById
(
'search_input'
).
focus
();
document
.
getElementById
(
'product_uom'
).
innerHTML
=
''
;
document
.
getElementById
(
'product_uom'
).
innerHTML
=
''
;
if
(
re_editing_qty
===
true
)
{
document
.
getElementById
(
'edition_header'
).
innerHTML
=
"Editer les prix"
;
document
.
getElementById
(
'edition_input_label'
).
innerHTML
=
"Prix unit."
;
re_editing_qty
=
false
;
}
}
}
/**
/**
...
@@ -1154,6 +1250,57 @@ function editProductInfo (productToEdit, value = null, batch = false) {
...
@@ -1154,6 +1250,57 @@ function editProductInfo (productToEdit, value = null, batch = false) {
newValue
=
isFinite
(
newValue
)
?
newValue
:
0
;
newValue
=
isFinite
(
newValue
)
?
newValue
:
0
;
}
}
// Particular process in case of qty reedition during prices update
if
(
re_editing_qty
===
true
)
{
// Look for product in product's order first step data
let
previous_step_index
=
-
1
;
for
(
let
i
=
0
;
i
<
orders
[
productToEdit
.
id_po
][
"previous_steps_data"
][
"False"
][
"updated_products"
].
length
;
i
++
)
{
if
(
orders
[
productToEdit
.
id_po
][
"previous_steps_data"
][
"False"
][
"updated_products"
][
i
].
id
===
productToEdit
.
id
)
{
previous_step_index
=
i
;
break
;
}
}
if
(
previous_step_index
===
-
1
)
{
// Product qty hasn't been updated yet: add to first step data
productToEdit
.
old_qty
=
productToEdit
.
product_qty
;
productToEdit
.
product_qty
=
newValue
;
productToEdit
.
product_qty_package
=
1
;
productToEdit
.
package_qty
=
productToEdit
.
product_qty
;
orders
[
productToEdit
.
id_po
][
"previous_steps_data"
][
"False"
][
"updated_products"
].
push
(
productToEdit
)
}
else
{
productToEdit
.
product_qty
=
newValue
;
productToEdit
.
package_qty
=
productToEdit
.
product_qty
;
// Product qty has been updated before, update first step data
orders
[
productToEdit
.
id_po
][
"previous_steps_data"
][
"False"
][
"updated_products"
][
previous_step_index
].
product_qty
=
newValue
;
orders
[
productToEdit
.
id_po
][
"previous_steps_data"
][
"False"
][
"updated_products"
][
previous_step_index
].
package_qty
=
newValue
;
}
/* Send request to server to update a single product */
updateType
=
"qty_valid"
;
send
([
productToEdit
]);
// Update temp couchdb order
update_distant_order
(
productToEdit
.
id_po
);
// Put back product in its original list
if
(
editing_origin
===
"to_process"
)
{
add_to_toProcess
(
productToEdit
);
}
else
if
(
editing_origin
===
"processed"
)
{
add_to_processed
(
productToEdit
);
}
return
true
;
}
// addition mode = weight is directly added from scanned product
// addition mode = weight is directly added from scanned product
$
.
each
(
list_processed
,
function
(
i
,
e
)
{
$
.
each
(
list_processed
,
function
(
i
,
e
)
{
if
(
if
(
...
@@ -1433,8 +1580,14 @@ function data_validation() {
...
@@ -1433,8 +1580,14 @@ function data_validation() {
});
});
}
}
// Send the request to the server
/**
function
send
()
{
* Send the request to update order(s) data
*
* @param {Array} given_products If set, only update these products.
* If no given products, we're in the regular process, ie the end of a reception.
* Else, we're in the middle of a reception, so we'll skip some parts.
*/
function
send
(
given_products
=
[])
{
try
{
try
{
// Loading on
// Loading on
openModal
();
openModal
();
...
@@ -1451,15 +1604,19 @@ function send() {
...
@@ -1451,15 +1604,19 @@ function send() {
update_data
.
orders
[
order_id
]
=
{
'po'
:
[]};
update_data
.
orders
[
order_id
]
=
{
'po'
:
[]};
}
}
has_given_products
=
given_products
.
length
>
0
;
// If given products, update these only, else update global updatedProducts list
products_to_update
=
has_given_products
===
true
?
given_products
:
updatedProducts
;
// for each updated product, add it to its order list
// for each updated product, add it to its order list
for
(
i
in
updatedProducts
)
{
for
(
i
in
products_to_update
)
{
/* ---> The following part concerns products found in different orders */
/* ---> The following part concerns products found in different orders */
if
(
'other_orders_data'
in
updatedProducts
[
i
])
{
if
(
'other_orders_data'
in
products_to_update
[
i
])
{
// for each other order of product
// for each other order of product
for
(
other_order_data
of
updatedProducts
[
i
].
other_orders_data
)
{
for
(
other_order_data
of
products_to_update
[
i
].
other_orders_data
)
{
// Make a clone (deep copy) of the product object
// Make a clone (deep copy) of the product object
let
product_copy
=
$
.
extend
(
true
,
{},
updatedProducts
[
i
]);
let
product_copy
=
$
.
extend
(
true
,
{},
products_to_update
[
i
]);
// Set correct order line id for this product
// Set correct order line id for this product
product_copy
.
id
=
other_order_data
.
id_product
;
product_copy
.
id
=
other_order_data
.
id_product
;
...
@@ -1468,30 +1625,30 @@ function send() {
...
@@ -1468,30 +1625,30 @@ function send() {
if
(
reception_status
==
'False'
)
{
if
(
reception_status
==
'False'
)
{
// Reset initial qties in respective orders
// Reset initial qties in respective orders
product_copy
.
old_qty
=
other_order_data
.
initial_qty
;
product_copy
.
old_qty
=
other_order_data
.
initial_qty
;
for
(
j
in
orders
[
updatedProducts
[
i
].
id_po
][
'updated_products'
])
{
for
(
j
in
orders
[
products_to_update
[
i
].
id_po
][
'updated_products'
])
{
if
(
orders
[
updatedProducts
[
i
].
id_po
][
'updated_products'
][
j
].
product_id
[
0
]
if
(
orders
[
products_to_update
[
i
].
id_po
][
'updated_products'
][
j
].
product_id
[
0
]
==
product_copy
.
product_id
[
0
])
{
==
product_copy
.
product_id
[
0
])
{
orders
[
updatedProducts
[
i
].
id_po
][
'updated_products'
][
j
].
old_qty
-=
other_order_data
.
initial_qty
;
orders
[
products_to_update
[
i
].
id_po
][
'updated_products'
][
j
].
old_qty
-=
other_order_data
.
initial_qty
;
break
;
break
;
}
}
}
}
if
(
product_copy
.
product_uom
[
0
]
==
21
&&
updatedProducts
[
i
].
product_qty
>
0.1
)
{
// kg
if
(
product_copy
.
product_uom
[
0
]
==
21
&&
products_to_update
[
i
].
product_qty
>
0.1
)
{
// kg
// Add minimum qty in other orders
// Add minimum qty in other orders
product_copy
.
product_qty_package
=
1
;
product_copy
.
product_qty_package
=
1
;
product_copy
.
package_qty
=
0.1
;
product_copy
.
package_qty
=
0.1
;
product_copy
.
product_qty
=
0.1
;
product_copy
.
product_qty
=
0.1
;
// Remove this qty from first order
// Remove this qty from first order
updatedProducts
[
i
].
package_qty
-=
0.1
;
products_to_update
[
i
].
package_qty
-=
0.1
;
updatedProducts
[
i
].
product_qty
-=
0.1
;
products_to_update
[
i
].
product_qty
-=
0.1
;
}
else
if
(
product_copy
.
product_uom
[
0
]
==
1
&&
updatedProducts
[
i
].
product_qty
>
1
)
{
// Unit
}
else
if
(
product_copy
.
product_uom
[
0
]
==
1
&&
products_to_update
[
i
].
product_qty
>
1
)
{
// Unit
product_copy
.
product_qty_package
=
1
;
product_copy
.
product_qty_package
=
1
;
product_copy
.
package_qty
=
1
;
product_copy
.
package_qty
=
1
;
product_copy
.
product_qty
=
1
;
product_copy
.
product_qty
=
1
;
updatedProducts
[
i
].
package_qty
-=
1
;
products_to_update
[
i
].
package_qty
-=
1
;
updatedProducts
[
i
].
product_qty
-=
1
;
products_to_update
[
i
].
product_qty
-=
1
;
}
else
{
// Not handled, all qty in one order
}
else
{
// Not handled, all qty in one order
product_copy
.
product_qty_package
=
0
;
product_copy
.
product_qty_package
=
0
;
product_copy
.
package_qty
=
0
;
product_copy
.
package_qty
=
0
;
...
@@ -1514,73 +1671,76 @@ function send() {
...
@@ -1514,73 +1671,76 @@ function send() {
/* <--- */
/* <--- */
// Add product to order's prod list
// Add product to order's prod list
prod_order_id
=
updatedProducts
[
i
].
id_po
;
prod_order_id
=
products_to_update
[
i
].
id_po
;
update_data
.
orders
[
prod_order_id
][
'po'
].
push
(
updatedProducts
[
i
]);
update_data
.
orders
[
prod_order_id
][
'po'
].
push
(
products_to_update
[
i
]);
}
/* Create the error report */
// Send changes between items to process and processed items
var
error_report_data
=
{
'group_amount_total'
:
0
,
'update_type'
:
updateType
,
'updated_products'
:
updatedProducts
,
'user_comments'
:
user_comments
,
'orders'
:
[]
};
for
(
let
i
in
orders
)
{
error_report_data
.
group_amount_total
+=
orders
[
i
].
amount_total
;
error_report_data
.
orders
.
push
(
orders
[
i
]);
}
}
//Create list of articl with no barcode
// Only send error report & no barcode list when no given products (ie normal process, end of reception)
no_barcode_list
=
[];
if
(
has_given_products
===
false
)
{
for
(
var
i
=
0
;
i
<
list_processed
.
length
;
i
++
)
{
/* Create the error report */
if
(
list_processed
[
i
].
product_qty
!=
0
&&
(
list_processed
[
i
].
barcode
==
false
||
list_processed
[
i
].
barcode
==
null
||
list_processed
[
i
].
barcode
==
""
))
{
// Send changes between items to process and processed items
no_barcode_list
.
push
([
var
error_report_data
=
{
list_processed
[
i
][
"product_id"
][
0
],
'group_amount_total'
:
0
,
list_processed
[
i
][
"product_id"
][
1
]
'update_type'
:
updateType
,
]);
'updated_products'
:
products_to_update
,
'user_comments'
:
user_comments
,
'orders'
:
[]
};
for
(
let
i
in
orders
)
{
error_report_data
.
group_amount_total
+=
orders
[
i
].
amount_total
;
error_report_data
.
orders
.
push
(
orders
[
i
]);
}
}
}
//Create list of articl with no barcode
data_send_no_barcode
=
{
no_barcode_list
=
[];
"order"
:
orders
[
order_data
[
'id_po'
]],
for
(
var
i
=
0
;
i
<
list_processed
.
length
;
i
++
)
{
"no_barcode_list"
:
no_barcode_list
if
(
list_processed
[
i
].
product_qty
!=
0
&&
(
list_processed
[
i
].
barcode
==
false
||
list_processed
[
i
].
barcode
==
null
||
list_processed
[
i
].
barcode
==
""
))
{
};
no_barcode_list
.
push
([
list_processed
[
i
][
"product_id"
][
0
],
list_processed
[
i
][
"product_id"
][
1
]
// Send of articl with no barcode to mail send
]);
if
(
no_barcode_list
.
length
>
0
)
{
}
}
data_send_no_barcode
=
{
"order"
:
orders
[
order_data
[
'id_po'
]],
"no_barcode_list"
:
no_barcode_list
};
// Send of articl with no barcode to mail send
if
(
no_barcode_list
.
length
>
0
)
{
$
.
ajax
({
type
:
"POST"
,
url
:
"../send_mail_no_barcode"
,
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
data_send_no_barcode
),
success
:
function
()
{},
error
:
function
()
{
alert
(
'Erreur dans l
\'
envoi des produite sont barre code.'
);
}
});
}
// Send request for error report
$
.
ajax
({
$
.
ajax
({
type
:
"POST"
,
type
:
"POST"
,
url
:
"../s
end_mail_no_barcode
"
,
url
:
"../s
ave_error_report
"
,
dataType
:
"json"
,
dataType
:
"json"
,
traditional
:
true
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
data_send_no_barcode
),
data
:
JSON
.
stringify
(
error_report_data
),
success
:
function
()
{},
success
:
function
()
{},
error
:
function
()
{
error
:
function
()
{
alert
(
'Erreur dans l
\'
envoi des produite sont barre code.'
);
closeModal
();
alert
(
'Erreur dans l
\'
envoi du rapport.'
);
}
}
});
});
}
}
// Send request for error report
$
.
ajax
({
type
:
"POST"
,
url
:
"../save_error_report"
,
dataType
:
"json"
,
traditional
:
true
,
contentType
:
"application/json; charset=utf-8"
,
data
:
JSON
.
stringify
(
error_report_data
),
success
:
function
()
{},
error
:
function
()
{
closeModal
();
alert
(
'Erreur dans l
\'
envoi du rapport.'
);
}
});
/* Update orders */
/* Update orders */
$
.
ajax
({
$
.
ajax
({
type
:
"PUT"
,
type
:
"PUT"
,
...
@@ -1592,163 +1752,165 @@ function send() {
...
@@ -1592,163 +1752,165 @@ function send() {
success
:
function
()
{
success
:
function
()
{
closeModal
();
closeModal
();
try
{
if
(
has_given_products
===
false
)
{
// If step 1 (counting)
try
{
if
(
reception_status
==
"False"
)
{
// If step 1 (counting)
/* Open pop-up with procedure explanation */
if
(
reception_status
==
"False"
)
{
var
barcodes_to_print
=
false
;
/* Open pop-up with procedure explanation */
var
barcodes_to_print
=
false
;
// Select products with local barcode and without barcode, when qty > 0
for
(
var
i
=
0
;
i
<
list_processed
.
length
;
i
++
)
{
// Select products with local barcode and without barcode, when qty > 0
if
(
list_processed
[
i
].
product_qty
!=
0
)
{
for
(
var
i
=
0
;
i
<
list_processed
.
length
;
i
++
)
{
// set DOM data
if
(
list_processed
[
i
].
product_qty
!=
0
)
{
if
(
typeof
(
list_processed
[
i
].
barcode
)
==
"string"
&&
list_processed
[
i
].
barcode
.
startsWith
(
fixed_barcode_prefix
)
&&
!
barcodes_to_print
)
{
// set DOM data
// Products with barcode to print (local barcode)
if
(
typeof
(
list_processed
[
i
].
barcode
)
==
"string"
&&
list_processed
[
i
].
barcode
.
startsWith
(
fixed_barcode_prefix
)
&&
!
barcodes_to_print
)
{
document
.
getElementById
(
"barcodesToPrint"
).
hidden
=
false
;
// Products with barcode to print (local barcode)
document
.
getElementById
(
"nothingToDo"
).
hidden
=
true
;
document
.
getElementById
(
"barcodesToPrint"
).
hidden
=
false
;
barcodes_to_print
=
true
;
}
/* else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") {
// Products with no barcode
var node = document.createElement('li');
let textNode = document.createTextNode(list_processed[i]["product_id"][1]);
node.appendChild(textNode);
document.getElementById('barcodesEmpty_list').appendChild(node);
if (document.getElementById("barcodesEmpty").hidden) {
document.getElementById("barcodesEmpty").hidden = false;
document
.
getElementById
(
"nothingToDo"
).
hidden
=
true
;
document
.
getElementById
(
"nothingToDo"
).
hidden
=
true
;
}
}*/
barcodes_to_print
=
true
;
}
}
/* else if (list_processed[i].barcode == false || list_processed[i].barcode == null || list_processed[i].barcode == "") {
}
// Products with no barcode
var node = document.createElement('li');
for
(
let
i
=
0
;
i
<
no_barcode_list
.
length
;
i
++
)
{
let textNode = document.createTextNode(list_processed[i]["product_id"][1]);
var
node
=
document
.
createElement
(
'li'
);
let
textNode
=
document
.
createTextNode
(
no_barcode_list
[
i
]);
node.appendChild(textNode);
document.getElementById('barcodesEmpty_list').appendChild(node);
node
.
appendChild
(
textNode
);
document
.
getElementById
(
'barcodesEmpty_list'
).
appendChild
(
node
);
if (document.getElementById("barcodesEmpty").hidden) {
document.getElementById("barcodesEmpty").hidden = false;
if
(
document
.
getElementById
(
"barcodesEmpty"
).
hidden
)
{
document.getElementById("nothingToDo").hidden = true;
document
.
getElementById
(
"barcodesEmpty"
).
hidden
=
false
;
}
document
.
getElementById
(
"nothingToDo"
).
hidden
=
true
;
}*/
}
}
}
}
for
(
let
i
=
0
;
i
<
no_barcode_list
.
length
;
i
++
)
{
// Set order(s) name in popup DOM
var
node
=
document
.
createElement
(
'li'
);
if
(
is_grouped_order
()
===
false
)
{
// Single order
let
textNode
=
document
.
createTextNode
(
no_barcode_list
[
i
]);
document
.
getElementById
(
"order_ref"
).
innerHTML
=
orders
[
Object
.
keys
(
orders
)[
0
]].
name
;
}
else
{
// group
node
.
appendChild
(
textNode
);
document
.
getElementById
(
"success_order_name_container"
).
hidden
=
true
;
document
.
getElementById
(
'barcodesEmpty_list'
).
appendChild
(
node
);
document
.
getElementById
(
"success_orders_name_container"
).
hidden
=
false
;
if
(
document
.
getElementById
(
"barcodesEmpty"
).
hidden
)
{
for
(
order_id
in
orders
)
{
document
.
getElementById
(
"barcodesEmpty"
).
hidden
=
false
;
var
p_node
=
document
.
createElement
(
'p'
);
document
.
getElementById
(
"nothingToDo"
).
hidden
=
true
;
}
var
span_node
=
document
.
createElement
(
'span'
);
span_node
.
className
=
'order_ref_reminder'
;
let
textNode
=
document
.
createTextNode
(
orders
[
order_id
].
name
);
span_node
.
appendChild
(
textNode
);
textNode
=
document
.
createTextNode
(
orders
[
order_id
].
partner
+
' du '
+
orders
[
order_id
].
date_order
+
' : '
);
p_node
.
appendChild
(
textNode
);
p_node
.
appendChild
(
span_node
);
document
.
getElementById
(
"orders_ref"
).
appendChild
(
p_node
);
}
}
}
// Set order(s) name in popup DOM
openModal
(
if
(
is_grouped_order
()
===
false
)
{
// Single order
$
(
'#modal_qtiesValidated'
).
html
(),
document
.
getElementById
(
"order_ref"
).
innerHTML
=
orders
[
Object
.
keys
(
orders
)[
0
]].
name
;
back
,
}
else
{
// group
'Retour à la liste des commandes'
,
document
.
getElementById
(
"success_order_name_container"
).
hidden
=
true
;
true
,
document
.
getElementById
(
"success_orders_name_container"
).
hidden
=
false
;
false
);
for
(
order_id
in
orders
)
{
var
p_node
=
document
.
createElement
(
'p'
);
/* Not last step: update distant data */
for
(
let
order_id
in
orders
)
{
var
span_node
=
document
.
createElement
(
'span'
);
// Save current step updated data
orders
[
order_id
].
previous_steps_data
=
{};
span_node
.
className
=
'order_ref_reminder'
;
orders
[
order_id
].
previous_steps_data
[
reception_status
]
=
{
let
textNode
=
document
.
createTextNode
(
orders
[
order_id
].
name
);
updated_products
:
orders
[
order_id
].
updated_products
||
[],
user_comments
:
user_comments
span_node
.
appendChild
(
textNode
);
};
orders
[
order_id
].
reception_status
=
updateType
;
textNode
=
document
.
createTextNode
(
orders
[
order_id
].
partner
+
' du '
+
orders
[
order_id
].
date_order
+
' : '
);
// Unlock order
p_node
.
appendChild
(
textNode
);
orders
[
order_id
].
last_update
=
{
p_node
.
appendChild
(
span_node
);
timestamp
:
null
,
fingerprint
:
null
document
.
getElementById
(
"orders_ref"
).
appendChild
(
p_node
);
};
// Delete temp data
delete
orders
[
order_id
].
valid_products
;
delete
orders
[
order_id
].
updated_products
;
}
dbc
.
bulkDocs
(
Object
.
values
(
orders
)).
catch
((
err
)
=>
{
console
.
log
(
err
);
});
}
else
{
// Print etiquettes with new prices
if
(
updatedProducts
.
length
>
0
)
{
document
.
getElementById
(
"etiquettesToPrint"
).
hidden
=
false
;
}
openModal
(
$
(
'#templates #modal_pricesValidated'
).
html
(),
back
,
'Retour à la liste des commandes'
,
true
,
false
);
/* Last step: Clear distant data */
// Delete orders doc
for
(
let
order_id
in
orders
)
{
orders
[
order_id
].
_deleted
=
true
;
}
// Remove orders group
dbc
.
get
(
"grouped_orders"
).
then
((
doc
)
=>
{
let
couchdb_update_data
=
Object
.
values
(
orders
);
// We're in a group, remove it & update groups doc
if
(
is_grouped_order
())
{
let
groups_doc
=
doc
;
let
first_order_id
=
parseInt
(
Object
.
keys
(
orders
)[
0
]);
for
(
let
i
in
groups_doc
.
groups
)
{
if
(
groups_doc
.
groups
[
i
].
includes
(
first_order_id
))
{
groups_doc
.
groups
.
splice
(
i
,
1
);
break
;
}
}
}
couchdb_update_data
.
push
(
groups_doc
);
}
}
return
dbc
.
bulkDocs
(
couchdb_update_data
);
openModal
(
})
$
(
'#modal_qtiesValidated'
).
html
(),
.
catch
(
function
(
err
)
{
back
,
'Retour à la liste des commandes'
,
true
,
false
);
/* Not last step: update distant data */
for
(
let
order_id
in
orders
)
{
// Save current step updated data
orders
[
order_id
].
previous_steps_data
=
{};
orders
[
order_id
].
previous_steps_data
[
reception_status
]
=
{
updated_products
:
orders
[
order_id
].
updated_products
||
[],
user_comments
:
user_comments
};
orders
[
order_id
].
reception_status
=
updateType
;
// Unlock order
orders
[
order_id
].
last_update
=
{
timestamp
:
null
,
fingerprint
:
null
};
// Delete temp data
delete
orders
[
order_id
].
valid_products
;
delete
orders
[
order_id
].
updated_products
;
}
dbc
.
bulkDocs
(
Object
.
values
(
orders
)).
catch
((
err
)
=>
{
console
.
log
(
err
);
console
.
log
(
err
);
});
});
}
else
{
// Print etiquettes with new prices
if
(
updatedProducts
.
length
>
0
)
{
document
.
getElementById
(
"etiquettesToPrint"
).
hidden
=
false
;
}
openModal
(
$
(
'#templates #modal_pricesValidated'
).
html
(),
back
,
'Retour à la liste des commandes'
,
true
,
false
);
/* Last step: Clear distant data */
// Delete orders doc
for
(
let
order_id
in
orders
)
{
orders
[
order_id
].
_deleted
=
true
;
}
// Remove orders group
dbc
.
get
(
"grouped_orders"
).
then
((
doc
)
=>
{
let
couchdb_update_data
=
Object
.
values
(
orders
);
// We're in a group, remove it & update groups doc
if
(
is_grouped_order
())
{
let
groups_doc
=
doc
;
let
first_order_id
=
parseInt
(
Object
.
keys
(
orders
)[
0
]);
for
(
let
i
in
groups_doc
.
groups
)
{
if
(
groups_doc
.
groups
[
i
].
includes
(
first_order_id
))
{
groups_doc
.
groups
.
splice
(
i
,
1
);
break
;
}
}
couchdb_update_data
.
push
(
groups_doc
);
}
return
dbc
.
bulkDocs
(
couchdb_update_data
);
})
.
catch
(
function
(
err
)
{
console
.
log
(
err
);
});
}
// Back if modal closed
$
(
'#modal_closebtn_top'
).
on
(
'click'
,
back
);
$
(
'#modal_closebtn_bottom'
).
on
(
'click'
,
back
);
}
catch
(
ee
)
{
err
=
{
msg
:
ee
.
name
+
' : '
+
ee
.
message
,
ctx
:
'callback update_orders'
};
console
.
error
(
err
);
report_JS_error
(
err
,
'reception'
);
}
}
// Back if modal closed
$
(
'#modal_closebtn_top'
).
on
(
'click'
,
back
);
$
(
'#modal_closebtn_bottom'
).
on
(
'click'
,
back
);
}
catch
(
ee
)
{
err
=
{
msg
:
ee
.
name
+
' : '
+
ee
.
message
,
ctx
:
'callback update_orders'
};
console
.
error
(
err
);
report_JS_error
(
err
,
'reception'
);
}
}
},
},
error
:
function
()
{
error
:
function
()
{
...
...
reception/views.py
View file @
b174700f
...
@@ -93,6 +93,7 @@ def produits(request, id):
...
@@ -93,6 +93,7 @@ def produits(request, id):
"ADD_ALL_LEFT_IS_GOOD_QTIES"
:
False
,
"ADD_ALL_LEFT_IS_GOOD_QTIES"
:
False
,
"ADD_ALL_LEFT_IS_GOOD_PRICES"
:
False
,
"ADD_ALL_LEFT_IS_GOOD_PRICES"
:
False
,
'add_products_pswd'
:
getattr
(
settings
,
'RECEPTION_ADD_PRODUCTS_PSWD'
,
'makeastop'
),
'add_products_pswd'
:
getattr
(
settings
,
'RECEPTION_ADD_PRODUCTS_PSWD'
,
'makeastop'
),
'update_qty_pswd'
:
getattr
(
settings
,
'RECEPTION_UPDATE_QTY_PSWD'
,
'makeastop'
)
}
}
fixed_barcode_prefix
=
'0490'
fixed_barcode_prefix
=
'0490'
...
...
templates/reception/reception_produits.html
View file @
b174700f
...
@@ -241,6 +241,7 @@
...
@@ -241,6 +241,7 @@
var
add_all_left_is_good_qties
=
"{{ADD_ALL_LEFT_IS_GOOD_QTIES}}"
var
add_all_left_is_good_qties
=
"{{ADD_ALL_LEFT_IS_GOOD_QTIES}}"
var
add_all_left_is_good_prices
=
"{{ADD_ALL_LEFT_IS_GOOD_PRICES}}"
var
add_all_left_is_good_prices
=
"{{ADD_ALL_LEFT_IS_GOOD_PRICES}}"
var
add_products_pswd
=
"{{add_products_pswd}}"
var
add_products_pswd
=
"{{add_products_pswd}}"
var
update_qty_pswd
=
"{{update_qty_pswd}}"
</script>
</script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
1651853225"
></script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
1651853225"
></script>
<script
src=
'{% static "js/barcodes.js" %}?v=1651853225'
></script>
<script
src=
'{% static "js/barcodes.js" %}?v=1651853225'
></script>
...
...
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