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
8a14e906
Commit
8a14e906
authored
May 05, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add change product shelf function
parent
7dfcbf2f
Pipeline
#2188
passed with stage
in 1 minute 32 seconds
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
272 additions
and
10 deletions
+272
-10
models.py
shelfs/models.py
+21
-2
shelfs.css
shelfs/static/css/shelfs.css
+12
-0
shelf_inventory.js
shelfs/static/js/shelf_inventory.js
+206
-5
urls.py
shelfs/urls.py
+2
-1
views.py
shelfs/views.py
+15
-2
shelf_inventory.html
templates/shelfs/shelf_inventory.html
+16
-0
No files found.
shelfs/models.py
View file @
8a14e906
...
...
@@ -505,11 +505,14 @@ class Shelf(models.Model):
class
Shelfs
(
models
.
Model
):
def
get_all
():
def
get_all
(
precision
=
'full'
):
res
=
[]
try
:
api
=
OdooAPI
()
res
=
api
.
execute
(
'product.shelfs'
,
'get'
,
{})
if
precision
==
'simple'
:
res
=
api
.
search_read
(
'product.shelfs'
,
[],
[
'name'
,
'sort_order'
],
order
=
'sort_order asc'
)
else
:
res
=
api
.
execute
(
'product.shelfs'
,
'get'
,
{})
except
Exception
as
e
:
coop_logger
.
error
(
"Rayons, get_all :
%
s"
,
str
(
e
))
return
res
...
...
@@ -529,3 +532,18 @@ class Shelfs(models.Model):
except
Exception
as
e
:
coop_logger
.
error
(
"Rayons, get_shelfs_sortorder :
%
s"
,
str
(
e
))
return
res
@staticmethod
def
make_products_shelf_links
(
data
):
res
=
{}
try
:
api
=
OdooAPI
()
res
[
'done'
]
=
[]
for
elt
in
data
:
f
=
{
'shelf_id'
:
elt
[
'shelf_id'
]}
if
api
.
update
(
'product.product'
,
[
elt
[
'product_id'
]],
f
):
res
[
'done'
]
.
append
(
elt
[
'product_id'
])
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
coop_logger
.
error
(
"Rayons, make_products_shelf_links :
%
s"
,
str
(
e
))
return
res
\ No newline at end of file
shelfs/static/css/shelfs.css
View file @
8a14e906
...
...
@@ -139,6 +139,13 @@ table.dataTable {
padding
:
5px
;
}
#header_container_left
{
float
:
left
;
}
#change_shelf_btn
{
float
:
right
;
}
div
#container_edition
{
padding
:
8px
;
background-color
:
#e7e9ed
;
...
...
@@ -288,3 +295,8 @@ hr {
opacity
:
1
;
}
/* Change shelf modal */
.shelf_selection
{
max-width
:
240px
;
}
shelfs/static/js/shelf_inventory.js
View file @
8a14e906
This diff is collapsed.
Click to expand it.
shelfs/urls.py
View file @
8a14e906
...
...
@@ -9,8 +9,9 @@ urlpatterns = [
url
(
r'^shelf_view/([0-9]+)$'
,
views
.
shelf_view
),
url
(
r'^shelf_inventory/([0-9]+)$'
,
views
.
shelf_inventory
),
url
(
r'^inventory_process_state/([0-9]+)$'
,
views
.
inventory_process_state
),
url
(
r'^all$'
,
views
.
all
),
url
(
r'^all
/?([a-z]*)
$'
,
views
.
all
),
url
(
r'^get_shelves_extra_data$'
,
views
.
get_shelves_extra_data
),
url
(
r'^change_products_shelfs$'
,
views
.
change_products_shelfs
),
url
(
r'^(?P<shelf_id>\d+)$'
,
views
.
shelf_data
),
url
(
r'^(?P<shelf_id>\d+)/products$'
,
views
.
products
),
url
(
r'^(?P<shelf_id>\d+)/add_product$'
,
views
.
add_product
),
...
...
shelfs/views.py
View file @
8a14e906
...
...
@@ -71,9 +71,9 @@ def set_begin_inventory_datetime(request, shelf_id):
return
JsonResponse
({
'res'
:
res
})
def
all
(
request
):
def
all
(
request
,
precision
):
"""Get all shelves data"""
return
JsonResponse
({
'res'
:
Shelfs
.
get_all
()})
return
JsonResponse
({
'res'
:
Shelfs
.
get_all
(
precision
)})
def
get_shelves_extra_data
(
request
):
"""Get data that need calculation, so long execution time"""
...
...
@@ -130,6 +130,19 @@ def inventory_process_state(request, shelf_id):
else
:
return
JsonResponse
({
'res'
:
res
})
def
change_products_shelfs
(
request
):
res
=
{}
try
:
data
=
json
.
loads
(
request
.
body
.
decode
())
res
=
Shelfs
.
make_products_shelf_links
(
data
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
coop_logger
.
error
(
"change_products_shelfs :
%
s"
,
str
(
e
))
if
'error'
in
res
:
return
JsonResponse
(
res
,
status
=
500
)
else
:
return
JsonResponse
({
'res'
:
res
})
def
do_shelf_inventory
(
request
):
"""Process shelf inventory"""
"""
...
...
templates/shelfs/shelf_inventory.html
View file @
8a14e906
...
...
@@ -91,6 +91,9 @@
<div
class=
"container_products"
id=
"container_left"
>
<h4
id=
"header_container_left"
>
Produits à compter
</h4>
<button
style=
"display:none;"
id=
"change_shelf_btn"
class=
"btn btn--primary"
>
Changer de rayon
</button>
<table
id=
"table_to_process"
class=
"display"
cellspacing=
"0"
></table>
</div>
<div
class=
"container_products"
id=
"container_right"
>
...
...
@@ -167,6 +170,19 @@
<input
autocomplete=
"off"
type=
"text"
placeholder=
"Code barre du produit"
class=
"add_product_input"
>
<hr
/>
</div>
<div
id=
"change_shelf_form"
>
<h3>
Changement de rayons
</h3>
<hr
/>
<table>
<thead>
<tr>
<th>
Produit
</th>
<th>
Rayon
</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<script
type=
"text/javascript"
>
...
...
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