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
9426d217
Commit
9426d217
authored
Jun 10, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Reception errors tracking and received data backup
parent
26a8c1ff
Pipeline
#1053
passed with stage
in 23 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
5 deletions
+21
-5
readme.txt
data/receptions_backup/readme.txt
+2
-0
models.py
reception/models.py
+5
-4
views.py
reception/views.py
+14
-1
No files found.
data/receptions_backup/readme.txt
0 → 100644
View file @
9426d217
Received reception data are stored in this directory (could be desactivated if RECEPTION_DATA_BACKUP is set to False in config.py)
\ No newline at end of file
reception/models.py
View file @
9426d217
...
...
@@ -34,11 +34,11 @@ class CagetteReception(models.Model):
f
=
[
"id"
,
"name"
,
"date_order"
,
"partner_id"
,
"date_planned"
,
"amount_untaxed"
,
"amount_total"
,
"x_reception_status"
]
# Only get orders that need to be treated in Reception
c
=
[[
'id'
,
'in'
,
pids
],
[
"x_reception_status"
,
"in"
,
[
False
,
'qty_valid'
,
'valid_pending'
,
'br_valid
'
,
'error_pack_op'
,
'uprice_valid'
]]]
c
=
[[
'id'
,
'in'
,
pids
],
[
"x_reception_status"
,
"in"
,
[
False
,
'qty_valid'
,
'valid_pending
'
,
'error_pack_op'
,
'uprice_valid'
]]]
orders
=
api
.
search_read
(
'purchase.order'
,
c
,
f
)
except
Exception
as
e
:
print
(
str
(
e
))
print
(
str
(
e
))
return
orders
def
get_order_unprocessable_products
(
id_po
):
...
...
@@ -63,7 +63,7 @@ class CagetteReception(models.Model):
"""Update purchase.order.line with qty data and/or price"""
result
=
None
try
:
f
=
{}
f
=
{}
if
updateType
==
"qty_valid"
or
updateType
==
"br_valid"
:
f
[
'package_qty'
]
=
pakageQty
...
...
@@ -76,7 +76,8 @@ class CagetteReception(models.Model):
res
=
self
.
o_api
.
update
(
'purchase.order.line'
,
idOnLine
,
f
)
result
=
True
except
:
except
Exception
as
e
:
coop_logger
.
error
(
"update_line :
%
s (fields values =
%
s, line_id =
%
s)"
,
str
(
e
),
str
(
f
),
str
(
idOnLine
))
result
=
False
return
result
...
...
reception/views.py
View file @
9426d217
...
...
@@ -177,6 +177,16 @@ def update_orders(request):
if
request
.
is_ajax
():
if
request
.
method
==
'PUT'
:
data
=
json
.
loads
(
request
.
body
.
decode
())
if
getattr
(
settings
,
'RECEPTION_DATA_BACKUP'
,
True
)
is
True
:
try
:
file_name
=
''
for
order_id
,
order
in
data
[
'orders'
]
.
items
():
file_name
+=
str
(
order_id
)
+
'_'
file_name
+=
data
[
'update_type'
]
+
'_'
+
str
(
round
(
time
.
time
()
*
1000
))
+
'.json'
with
open
(
'data/receptions_backup/'
+
file_name
,
'w'
)
as
data_file
:
json
.
dump
(
data
,
data_file
)
except
Exception
as
ef
:
coop_logger
.
error
(
"Enable to save data :
%
s (data =
%
s)"
,
str
(
ef
),
str
(
data
))
answer_data
=
{}
print_labels
=
True
if
hasattr
(
settings
,
'RECEPTION_SHELF_LABEL_PRINT'
):
...
...
@@ -232,6 +242,8 @@ def update_orders(request):
except
KeyError
:
coop_logger
.
info
(
"No line to update."
)
except
Exception
as
e
:
coop_logger
.
error
(
"update_orders :
%
s"
,
str
(
e
))
answer_data
[
order_id
][
'order_data'
]
=
order
answer_data
[
order_id
][
'errors'
]
=
errors
...
...
@@ -258,7 +270,8 @@ def update_orders(request):
except
Exception
as
e
:
# no saved groups
print
(
str
(
e
))
else
:
coop_logger
.
error
(
"update_orders errors :
%
s"
,
str
(
errors
))
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
return
rep
...
...
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