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
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
Alexis AOUN
third-party
Commits
9e7f5b76
Commit
9e7f5b76
authored
Apr 09, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sync between workstations for grouped orders & localstorage cleaning
parent
8bbbfbb4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
2 deletions
+68
-2
reception_index.js
reception/static/js/reception_index.js
+0
-0
urls.py
reception/urls.py
+2
-1
views.py
reception/views.py
+65
-1
index.html
templates/reception/index.html
+1
-0
No files found.
reception/static/js/reception_index.js
View file @
9e7f5b76
This diff is collapsed.
Click to expand it.
reception/urls.py
View file @
9e7f5b76
...
@@ -16,5 +16,6 @@ urlpatterns = [
...
@@ -16,5 +16,6 @@ urlpatterns = [
url
(
r'^reception_qtiesValidated'
,
views
.
reception_qtiesValidated
),
url
(
r'^reception_qtiesValidated'
,
views
.
reception_qtiesValidated
),
url
(
r'^reception_pricesValidated'
,
views
.
reception_pricesValidated
),
url
(
r'^reception_pricesValidated'
,
views
.
reception_pricesValidated
),
# url(r'^update_order_status/([0-9]+)$', views.tmp_update_order_status),
# url(r'^update_order_status/([0-9]+)$', views.tmp_update_order_status),
url
(
r'^po_process_picking$'
,
views
.
po_process_picking
)
url
(
r'^po_process_picking$'
,
views
.
po_process_picking
),
url
(
r'^save_order_group$'
,
views
.
save_order_group
)
]
]
reception/views.py
View file @
9e7f5b76
...
@@ -21,9 +21,18 @@ def as_text(value):
...
@@ -21,9 +21,18 @@ def as_text(value):
def
home
(
request
):
def
home
(
request
):
"""Page de selection de la commande suivant un fournisseurs"""
"""Page de selection de la commande suivant un fournisseurs"""
# Get grouped orders stored on the server
try
:
with
open
(
'temp/grouped_order.json'
,
'r'
)
as
json_file
:
saved_groups
=
json
.
load
(
json_file
)
except
Exception
:
saved_groups
=
[]
context
=
{
context
=
{
'title'
:
'Reception'
,
'title'
:
'Reception'
,
'merge_orders_pswd'
:
settings
.
RECEPTION_MERGE_ORDERS_PSWD
'merge_orders_pswd'
:
settings
.
RECEPTION_MERGE_ORDERS_PSWD
,
'server_stored_groups'
:
saved_groups
}
}
template
=
loader
.
get_template
(
'reception/index.html'
)
template
=
loader
.
get_template
(
'reception/index.html'
)
...
@@ -117,6 +126,40 @@ def data_validation(request):
...
@@ -117,6 +126,40 @@ def data_validation(request):
coop_logger
.
error
(
"Orders data validation :
%
s"
,
str
(
e
))
coop_logger
.
error
(
"Orders data validation :
%
s"
,
str
(
e
))
return
JsonResponse
({
'error'
:
str
(
e
)},
status
=
500
)
return
JsonResponse
({
'error'
:
str
(
e
)},
status
=
500
)
def
save_order_group
(
request
):
"""
When an order group is created, save it to force group these orders later.
Raise an error if one of the orders is already in a group.
"""
order_ids
=
json
.
loads
(
request
.
body
.
decode
())
try
:
try
:
# Check if any of the orders attempted to be grouped is already in a group
with
open
(
'temp/grouped_order.json'
,
'r'
)
as
json_file
:
saved_groups
=
json
.
load
(
json_file
)
for
order_id
in
order_ids
:
for
group
in
saved_groups
:
if
order_id
in
group
:
# Found in a group, stop
msg
=
'One of the orders is already in a group'
return
JsonResponse
({
'message'
:
msg
},
status
=
409
)
except
Exception
:
saved_groups
=
[]
# All good, save group
with
open
(
'temp/grouped_order.json'
,
'w+'
)
as
json_file
:
saved_groups
.
append
(
order_ids
)
json
.
dump
(
saved_groups
,
json_file
)
msg
=
'Group saved'
return
JsonResponse
({
'message'
:
msg
})
except
Exception
as
e
:
print
(
str
(
e
))
return
JsonResponse
({
'message'
:
str
(
e
)},
status
=
500
)
def
update_orders
(
request
):
def
update_orders
(
request
):
"""Update orders lines: quantity and unit prices"""
"""Update orders lines: quantity and unit prices"""
...
@@ -130,7 +173,10 @@ def update_orders(request):
...
@@ -130,7 +173,10 @@ def update_orders(request):
print_labels
=
True
print_labels
=
True
if
hasattr
(
settings
,
'RECEPTION_SHELF_LABEL_PRINT'
):
if
hasattr
(
settings
,
'RECEPTION_SHELF_LABEL_PRINT'
):
print_labels
=
settings
.
RECEPTION_SHELF_LABEL_PRINT
print_labels
=
settings
.
RECEPTION_SHELF_LABEL_PRINT
order_ids
=
[]
for
order_id
,
order
in
data
[
'orders'
]
.
items
():
for
order_id
,
order
in
data
[
'orders'
]
.
items
():
order_ids
.
append
(
int
(
order_id
))
answer_data
[
order_id
]
=
{}
answer_data
[
order_id
]
=
{}
errors
=
[]
errors
=
[]
...
@@ -181,11 +227,29 @@ def update_orders(request):
...
@@ -181,11 +227,29 @@ def update_orders(request):
answer_data
[
order_id
][
'order_data'
]
=
order
answer_data
[
order_id
][
'order_data'
]
=
order
answer_data
[
order_id
][
'errors'
]
=
errors
answer_data
[
order_id
][
'errors'
]
=
errors
if
len
(
errors
)
==
0
:
if
len
(
errors
)
==
0
:
m
.
update_order_status
(
order_id
,
data
[
'update_type'
])
m
.
update_order_status
(
order_id
,
data
[
'update_type'
])
if
data
[
'update_type'
]
==
'br_valid'
:
if
data
[
'update_type'
]
==
'br_valid'
:
answer_data
[
order_id
][
'finalyze_result'
]
=
m
.
register_purchase_order_to_finalyze
()
answer_data
[
order_id
][
'finalyze_result'
]
=
m
.
register_purchase_order_to_finalyze
()
# Remove order's group
try
:
with
open
(
'temp/grouped_order.json'
,
'r'
)
as
json_file
:
saved_groups
=
json
.
load
(
json_file
)
for
oi
in
order_ids
:
for
i
,
group
in
enumerate
(
saved_groups
):
if
oi
in
group
:
saved_groups
.
pop
(
i
)
break
with
open
(
'temp/grouped_order.json'
,
'w'
)
as
json_file
:
json
.
dump
(
saved_groups
,
json_file
)
except
Exception
as
e
:
# no saved groups
print
(
str
(
e
))
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
return
rep
return
rep
...
...
templates/reception/index.html
View file @
9e7f5b76
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script type="
text
/
javascript
"
>
<script type="
text
/
javascript
"
>
var
merge_orders_pswd
=
'{{merge_orders_pswd}}'
;
var
merge_orders_pswd
=
'{{merge_orders_pswd}}'
;
var
server_stored_groups
=
{{
server_stored_groups
}};
</script>
</script>
<script
src=
"{% static "
js
/
common
.
js
"
%}?
v=
"></script>
<script
src=
"{% static "
js
/
common
.
js
"
%}?
v=
"></script>
{% endblock %}
{% endblock %}
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