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
e84f47f2
Commit
e84f47f2
authored
Jun 24, 2021
by
Damien Moulard
Browse files
Options
Browse Files
Download
Plain Diff
merge couchdb in reception
parents
ac8536c7
983b0430
Pipeline
#1105
passed with stage
in 1 minute 22 seconds
Changes
8
Pipelines
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
59 deletions
+60
-59
settings_secret_example.py
outils/settings_secret_example.py
+2
-1
reception_style.css
reception/static/css/reception_style.css
+13
-0
reception_index.js
reception/static/js/reception_index.js
+0
-0
reception_produits.js
reception/static/js/reception_produits.js
+0
-0
urls.py
reception/urls.py
+1
-2
views.py
reception/views.py
+19
-50
index.html
templates/reception/index.html
+19
-4
reception_produits.html
templates/reception/reception_produits.html
+6
-2
No files found.
outils/settings_secret_example.py
View file @
e84f47f2
...
...
@@ -20,7 +20,8 @@ COUCHDB = {
'inventory'
:
'inventory'
,
'envelops'
:
'envelop'
,
'shop'
:
'shopping_carts'
,
'orders'
:
'orders_test'
'orders'
:
'orders_test'
,
'reception'
:
'reception_test'
,
}
}
...
...
reception/static/css/reception_style.css
View file @
e84f47f2
...
...
@@ -11,6 +11,10 @@ input[type="number"] {
}
/* INDEX */
.group_line
{
margin-bottom
:
5px
;
}
#orders
tbody
tr
{
cursor
:
pointer
;
}
...
...
@@ -31,6 +35,15 @@ input[type="number"] {
margin-bottom
:
1em
;
}
.order_last_update
{
font-weight
:
bold
;
}
.order_modified_msg
{
font-size
:
2rem
;
color
:
#e62720
;
}
/* PRODUITS */
.page_body
{
height
:
100%
;
...
...
reception/static/js/reception_index.js
View file @
e84f47f2
This diff is collapsed.
Click to expand it.
reception/static/js/reception_produits.js
View file @
e84f47f2
This diff is collapsed.
Click to expand it.
reception/urls.py
View file @
e84f47f2
...
...
@@ -16,6 +16,5 @@ urlpatterns = [
url
(
r'^reception_qtiesValidated'
,
views
.
reception_qtiesValidated
),
url
(
r'^reception_pricesValidated'
,
views
.
reception_pricesValidated
),
# url(r'^update_order_status/([0-9]+)$', views.tmp_update_order_status),
url
(
r'^po_process_picking$'
,
views
.
po_process_picking
),
url
(
r'^save_order_group$'
,
views
.
save_order_group
)
url
(
r'^po_process_picking$'
,
views
.
po_process_picking
)
]
reception/views.py
View file @
e84f47f2
...
...
@@ -27,17 +27,12 @@ def as_text(value):
def
home
(
request
):
"""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
=
{
'title'
:
'Reception'
,
'merge_orders_pswd'
:
settings
.
RECEPTION_MERGE_ORDERS_PSWD
,
'server_stored_groups'
:
saved_groups
'couchdb_server'
:
settings
.
COUCHDB
[
'url'
],
'db'
:
settings
.
COUCHDB
[
'dbs'
][
'reception'
],
'POUCHDB_VERSION'
:
getattr
(
settings
,
'POUCHDB_VERSION'
,
''
)
}
template
=
loader
.
get_template
(
'reception/index.html'
)
...
...
@@ -75,10 +70,14 @@ def get_list_orders(request):
def
produits
(
request
,
id
):
""" Gets Order details """
context
=
{
'title'
:
'Réception des produits'
,
"TOOLS_SERVER"
:
settings
.
TOOLS_SERVER
,
"DISPLAY_AUTRES"
:
getattr
(
settings
,
'DISPLAY_COL_AUTRES'
,
True
),
}
context
=
{
'title'
:
'Réception des produits'
,
"TOOLS_SERVER"
:
settings
.
TOOLS_SERVER
,
'couchdb_server'
:
settings
.
COUCHDB
[
'url'
],
'db'
:
settings
.
COUCHDB
[
'dbs'
][
'reception'
],
'POUCHDB_VERSION'
:
getattr
(
settings
,
'POUCHDB_VERSION'
,
''
),
"DISPLAY_AUTRES"
:
getattr
(
settings
,
'DISPLAY_COL_AUTRES'
,
True
),
}
fixed_barcode_prefix
=
'0490'
if
hasattr
(
settings
,
'RECEPTION_PB'
):
...
...
@@ -133,40 +132,6 @@ def data_validation(request):
coop_logger
.
error
(
"Orders data validation :
%
s"
,
str
(
e
))
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
):
"""Update orders lines: quantity and unit prices"""
...
...
@@ -257,6 +222,7 @@ def update_orders(request):
# Remove order's group
try
:
# TODO remove from couchdb orders & group (here?)
if
os
.
path
.
exists
(
'temp/grouped_order.json'
):
with
open
(
'temp/grouped_order.json'
,
'r'
)
as
json_file
:
saved_groups
=
json
.
load
(
json_file
)
...
...
@@ -272,6 +238,7 @@ def update_orders(request):
except
Exception
as
e
:
# no saved groups
print
(
str
(
e
))
# TODO else if first step, save first step data (here?)
else
:
coop_logger
.
error
(
"update_orders errors :
%
s"
,
str
(
errors
))
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
...
...
@@ -281,7 +248,7 @@ def update_orders(request):
# """ Method used for tests purposes: Reset an order status """
# m = CagetteReception(id_po)
# m.update_order_status(id_po, False)
#
# return JsonResponse({'id_po': id_po})
def
save_error_report
(
request
):
...
...
@@ -300,7 +267,7 @@ def save_error_report(request):
orders_partner
=
""
group_ids
=
[]
for
i
,
order
in
enumerate
(
data
[
'orders'
])
:
# list of temp files: 1 report per
reception
# list of temp files: 1 report per
order & group
data
[
'orders'
][
i
][
'temp_file_name'
]
=
"temp/"
+
order
[
'name'
]
+
"_rapport-reception_temp.xlsx"
group_ids
.
append
(
order
[
'id'
])
...
...
@@ -391,7 +358,7 @@ def save_error_report(request):
# Create report with data from steps 1 & 2
el
se
:
el
if
data
[
'update_type'
]
==
'br_valid'
:
for
order
in
data
[
'orders'
]:
# Read step 1 data from temp file
data_qties
=
{}
...
...
@@ -423,7 +390,8 @@ def save_error_report(request):
# Clear step 1 temp file
os
.
remove
(
order
[
'temp_file_name'
])
except
:
data_comment_s1
=
"Rapport de la première étape absent !"
data_comment_s1
=
"Données de la première étape absentes !"
# Add data from step 2
data_full
=
[]
error_total
=
0
...
...
@@ -484,6 +452,7 @@ def save_error_report(request):
# no updated products, do nothing
print
(
"Error while updating products"
)
print
(
exp
)
# Add remaining products, the ones edited only in step 1
for
product
in
data_qties
.
values
():
item
=
{
...
...
templates/reception/index.html
View file @
e84f47f2
...
...
@@ -11,7 +11,6 @@
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/dataTables.plugins.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/moment.min.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/datatables/dataTables.plugin.moment_sorting.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% static 'js/reception_index.js' %}?v="
></script>
{% endblock %}
{% block content %}
...
...
@@ -31,7 +30,6 @@
<div
id=
"groups_items"
></div>
</div>
<br>
<div
id=
"grouped_action"
>
<button
type=
"button"
class=
'btn--primary'
id=
'group_action'
onclick=
"group_action()"
hidden
>
Compter les produits des commandes sélectionnées
</button>
</div>
...
...
@@ -48,13 +46,30 @@
<p>
Êtez-vous sûr ?
</p>
<hr
/>
</div>
<div
id=
"modal_order_access"
>
<h3>
Attention !
</h3>
<br/>
<p
class=
"order_modified_msg"
>
Un autre navigateur a commencé à réceptionner cette commande il y a
<span
class=
"order_last_update"
></span>
.
</p><br/>
<p>
Si quelqu'un d'autre que vous est à l'origine de cette opération et que celle-ci est récente,
nous conseillons fortement de ne pas accéder à la commande afin d'éviter les conflits.
</p><br/>
<p>
Voulez-vous quand même y accéder ?
</p>
<hr/>
</div>
</div>
<br/>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script src="
{%
static
'
js
/
pouchdb
.
min
'|
add:POUCHDB_VERSION
|
add:
'.
js
'
%}"
></script>
<script
type=
"text/javascript"
>
var
merge_orders_pswd
=
'{{merge_orders_pswd}}'
;
var
server_stored_groups
=
{{
server_stored_groups
}};
var
couchdb_dbname
=
'{{db}}'
;
var
couchdb_server
=
'{{couchdb_server}}'
+
couchdb_dbname
;
</script>
<script
src=
"{% static "
js
/
common
.
js
"
%}?
v=
"></script>
<script
type=
"text/javascript"
src=
"{% static 'js/reception_index.js'
%}?v="
></script>
{% endblock %}
templates/reception/reception_produits.html
View file @
e84f47f2
...
...
@@ -19,7 +19,7 @@
{% endif %}
<div
class=
"page_body"
>
<header
class=
"flex-container"
>
<button
class=
"right btn--danger"
onclick=
"back()
"
>
Retour
</button>
<button
class=
"right btn--danger"
id=
"back_button
"
>
Retour
</button>
<div
class=
"w33 arrow-block txtcenter"
id=
"header_step_one"
>
<h4
id=
"header_step_one_content"
>
Produits à compter
</h4>
</div>
...
...
@@ -180,10 +180,14 @@
</div>
<br/>
</div>
<script
src=
"{% static 'js/pouchdb.min'|add:POUCHDB_VERSION|add:'.js' %}"
></script>
<script
type=
"text/javascript"
>
var
tools_server
=
'{{TOOLS_SERVER}}'
var
fixed_barcode_prefix
=
'{{FIXED_BARCODE_PREFIX}}'
var
display_autres
=
{{
DISPLAY_AUTRES
}};
var
couchdb_dbname
=
'{{db}}'
;
var
couchdb_server
=
'{{couchdb_server}}'
+
couchdb_dbname
;
var
display_autres
=
"{{DISPLAY_AUTRES}}"
;
</script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script src='{% static "
js
/
barcodes
.
js
"
%}?
v=
'></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