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
6aa391b6
Commit
6aa391b6
authored
Jun 10, 2021
by
François C.
Committed by
Alexis Aoun
Jul 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve Reception errors tracking and received data backup
parent
de06a817
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 @
6aa391b6
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 @
6aa391b6
...
@@ -34,11 +34,11 @@ class CagetteReception(models.Model):
...
@@ -34,11 +34,11 @@ class CagetteReception(models.Model):
f
=
[
"id"
,
"name"
,
"date_order"
,
"partner_id"
,
"date_planned"
,
"amount_untaxed"
,
"amount_total"
,
"x_reception_status"
]
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
# 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
)
orders
=
api
.
search_read
(
'purchase.order'
,
c
,
f
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
str
(
e
))
print
(
str
(
e
))
return
orders
return
orders
def
get_order_unprocessable_products
(
id_po
):
def
get_order_unprocessable_products
(
id_po
):
...
@@ -63,7 +63,7 @@ class CagetteReception(models.Model):
...
@@ -63,7 +63,7 @@ class CagetteReception(models.Model):
"""Update purchase.order.line with qty data and/or price"""
"""Update purchase.order.line with qty data and/or price"""
result
=
None
result
=
None
try
:
try
:
f
=
{}
f
=
{}
if
updateType
==
"qty_valid"
or
updateType
==
"br_valid"
:
if
updateType
==
"qty_valid"
or
updateType
==
"br_valid"
:
f
[
'package_qty'
]
=
pakageQty
f
[
'package_qty'
]
=
pakageQty
...
@@ -76,7 +76,8 @@ class CagetteReception(models.Model):
...
@@ -76,7 +76,8 @@ class CagetteReception(models.Model):
res
=
self
.
o_api
.
update
(
'purchase.order.line'
,
idOnLine
,
f
)
res
=
self
.
o_api
.
update
(
'purchase.order.line'
,
idOnLine
,
f
)
result
=
True
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
result
=
False
return
result
return
result
...
...
reception/views.py
View file @
6aa391b6
...
@@ -179,6 +179,16 @@ def update_orders(request):
...
@@ -179,6 +179,16 @@ def update_orders(request):
if
request
.
is_ajax
():
if
request
.
is_ajax
():
if
request
.
method
==
'PUT'
:
if
request
.
method
==
'PUT'
:
data
=
json
.
loads
(
request
.
body
.
decode
())
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
=
{}
answer_data
=
{}
print_labels
=
True
print_labels
=
True
if
hasattr
(
settings
,
'RECEPTION_SHELF_LABEL_PRINT'
):
if
hasattr
(
settings
,
'RECEPTION_SHELF_LABEL_PRINT'
):
...
@@ -234,6 +244,8 @@ def update_orders(request):
...
@@ -234,6 +244,8 @@ def update_orders(request):
except
KeyError
:
except
KeyError
:
coop_logger
.
info
(
"No line to update."
)
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
][
'order_data'
]
=
order
answer_data
[
order_id
][
'errors'
]
=
errors
answer_data
[
order_id
][
'errors'
]
=
errors
...
@@ -260,7 +272,8 @@ def update_orders(request):
...
@@ -260,7 +272,8 @@ def update_orders(request):
except
Exception
as
e
:
except
Exception
as
e
:
# no saved groups
# no saved groups
print
(
str
(
e
))
print
(
str
(
e
))
else
:
coop_logger
.
error
(
"update_orders errors :
%
s"
,
str
(
errors
))
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
rep
=
JsonResponse
(
answer_data
,
safe
=
False
)
return
rep
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