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
93ac4b05
Commit
93ac4b05
authored
Jun 21, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use couch db for reception reports
parent
4f582f12
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
74 deletions
+55
-74
reception_produits.js
reception/static/js/reception_produits.js
+2
-1
views.py
reception/views.py
+53
-73
No files found.
reception/static/js/reception_produits.js
View file @
93ac4b05
...
@@ -1589,7 +1589,8 @@ function send() {
...
@@ -1589,7 +1589,8 @@ function send() {
// Save current step updated data
// Save current step updated data
orders
[
order_id
].
previous_steps_data
=
{};
orders
[
order_id
].
previous_steps_data
=
{};
orders
[
order_id
].
previous_steps_data
[
reception_status
]
=
{
orders
[
order_id
].
previous_steps_data
[
reception_status
]
=
{
updated_products
:
orders
[
order_id
].
updated_products
||
[]
updated_products
:
orders
[
order_id
].
updated_products
||
[],
user_comments
:
user_comments
};
};
orders
[
order_id
].
reception_status
=
updateType
;
orders
[
order_id
].
reception_status
=
updateType
;
...
...
reception/views.py
View file @
93ac4b05
...
@@ -13,6 +13,7 @@ from openpyxl.styles import Alignment
...
@@ -13,6 +13,7 @@ from openpyxl.styles import Alignment
from
reception.models
import
CagetteReception
from
reception.models
import
CagetteReception
from
outils.common
import
OdooAPI
from
outils.common
import
OdooAPI
from
outils.common
import
CouchDB
from
members.models
import
CagetteUser
from
members.models
import
CagetteUser
from
products.models
import
CagetteProduct
from
products.models
import
CagetteProduct
...
@@ -290,36 +291,50 @@ def save_error_report(request):
...
@@ -290,36 +291,50 @@ def save_error_report(request):
'group_ids'
:
group_ids
'group_ids'
:
group_ids
}
}
data
[
'orders'
]
.
append
(
group_order
)
data
[
'orders'
]
.
append
(
group_order
)
# group "order" has to be last in orders list
else
:
else
:
coop_logger
.
info
(
"data['orders'] is a single PO (not inside group)"
)
coop_logger
.
info
(
"data['orders'] is a single PO (not inside group)"
)
except
Exception
as
e2
:
except
Exception
as
e2
:
coop_logger
.
error
(
"Save reception report : Error while create group_order
%
s"
,
str
(
e2
))
coop_logger
.
error
(
"Save reception report : Error while create group_order
%
s"
,
str
(
e2
))
#
Save qties & comments
after step 1
#
no action needed
after step 1
if
data
[
'update_type'
]
==
'qty_valid'
:
if
data
[
'update_type'
]
==
'qty_valid'
:
pass
# removed, keep check to ensure transition process
# Create report with data from steps 1 & 2
elif
data
[
'update_type'
]
==
'br_valid'
:
c_db
=
CouchDB
(
arg_db
=
'reception'
)
concat_updated_products
=
[]
concat_user_comments
=
''
for
order
in
data
[
'orders'
]:
for
order
in
data
[
'orders'
]:
try
:
try
:
wb
=
Workbook
()
data_qties
=
{}
ws
=
wb
.
active
data_comment_s1
=
""
ws
.
title
=
"Commande "
+
order
[
'name'
]
ws
.
append
([
'type'
,
if
'group_ids'
in
order
:
'nom_contenu'
,
# For groups, concatenate orders step 1 data
'supplier_code'
,
step_1_data
=
{
'barcode'
,
'updated_products'
:
concat_updated_products
,
'old_qty'
,
'user_comments'
:
concat_user_comments
'product_qty'
,
}
'price_unit'
,
else
:
'supplier_shortage'
])
# Read step 1 data from couch db document
order_id
=
f
"order_{order['name'].split('PO')[1]}"
order_doc
=
c_db
.
getDocById
(
order_id
)
# If in group add group name
if
len
(
data
[
'orders'
])
>
1
:
ws
.
append
([
'group'
,
orders_name
])
try
:
try
:
if
'updated_products'
in
order
:
step_1_data
=
order_doc
[
'previous_steps_data'
][
'False'
]
for
product
in
order
[
'updated_products'
]:
except
KeyError
:
# Don't store products with same qties
continue
# No step 1 data
if
'updated_products'
in
step_1_data
:
# Concatenate updated products from all orders
if
'group_ids'
not
in
order
:
concat_updated_products
=
concat_updated_products
+
step_1_data
[
'updated_products'
]
for
product
in
step_1_data
[
'updated_products'
]:
# Don't store products with unchanged qties in step 1 data
if
product
[
'old_qty'
]
!=
product
[
'product_qty'
]:
if
product
[
'old_qty'
]
!=
product
[
'product_qty'
]:
if
'supplier_code'
in
product
:
if
'supplier_code'
in
product
:
supplier_code
=
str
(
product
[
'supplier_code'
])
supplier_code
=
str
(
product
[
'supplier_code'
])
...
@@ -331,63 +346,28 @@ def save_error_report(request):
...
@@ -331,63 +346,28 @@ def save_error_report(request):
else
:
else
:
supplier_shortage
=
''
supplier_shortage
=
''
ws
.
append
([
'produit'
,
product_name
=
product
[
'product_id'
][
1
]
product
[
'product_id'
][
1
],
data_qties
[
product_name
]
=
{
supplier_code
,
'nom_contenu'
:
product_name
,
str
(
product
[
'barcode'
]),
'supplier_code'
:
supplier_code
,
product
[
'old_qty'
],
'barcode'
:
str
(
product
[
'barcode'
]),
product
[
'product_qty'
],
'old_qty'
:
product
[
'old_qty'
],
product
[
'price_unit'
],
'product_qty'
:
product
[
'product_qty'
],
supplier_shortage
])
'price_unit'
:
product
[
'price_unit'
],
except
Exception
as
exp
:
'supplier_shortage'
:
supplier_shortage
coop_logger
.
error
(
"Error while updating products in report :
%
s"
,
str
(
exp
))
}
if
(
'user_comments'
in
data
)
and
data
[
'user_comments'
]
!=
""
:
ws
.
append
(
[
'commentaire'
,
data
[
'user_comments'
]]
)
else
:
ws
.
append
(
[
'commentaire'
,
'Aucun commentaire.'
]
)
# Save file
if
'user_comments'
in
step_1_data
:
wb
.
save
(
filename
=
order
[
'temp_file_name'
])
# Get user comments from all orders (same for all group orders)
except
Exception
as
e3
:
if
'group_ids'
not
in
order
\
coop_logger
.
error
(
"Save reception report : Error while create order Workbook
%
s"
,
str
(
e3
))
and
step_1_data
[
'user_comments'
]
!=
""
\
and
concat_user_comments
!=
step_1_data
[
'user_comments'
]:
concat_user_comments
=
step_1_data
[
'user_comments'
]
data_comment_s1
=
step_1_data
[
'user_comments'
]
if
step_1_data
[
'user_comments'
]
!=
""
else
'Aucun commentaire.'
# Create report with data from steps 1 & 2
except
Exception
as
e
:
elif
data
[
'update_type'
]
==
'br_valid'
:
data_comment_s1
=
"Données de l'étape 1 manquantes (erreur : "
+
str
(
e
)
+
")"
for
order
in
data
[
'orders'
]:
# Read step 1 data from temp file
data_qties
=
{}
data_comment_s1
=
""
group_name
=
""
# Try to find temp file
try
:
wb2
=
load_workbook
(
order
[
'temp_file_name'
])
ws
=
wb2
.
active
for
row
in
ws
.
iter_rows
(
min_row
=
2
,
values_only
=
True
):
if
row
[
0
]
==
'produit'
:
# products info
data_qties
[
row
[
1
]]
=
{
'nom_contenu'
:
row
[
1
],
'supplier_code'
:
row
[
2
],
'barcode'
:
row
[
3
],
'old_qty'
:
row
[
4
],
'product_qty'
:
row
[
5
],
'price_unit'
:
row
[
6
],
'supplier_shortage'
:
row
[
7
]
}
elif
row
[
0
]
==
'group'
:
group_name
=
row
[
1
]
# group's orders name : Unused
elif
row
[
0
]
==
'commentaire'
:
data_comment_s1
=
row
[
1
]
# user comments
# Clear step 1 temp file
os
.
remove
(
order
[
'temp_file_name'
])
except
Exception
as
e4
:
coop_logger
.
error
(
"Save reception report : reloading first step xlsx file
%
s"
,
str
(
e4
))
data_comment_s1
=
"Données de la première étape absentes !"
# Add data from step 2
# Add data from step 2
data_full
=
[]
data_full
=
[]
...
...
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