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
e42f5e6f
Commit
e42f5e6f
authored
May 06, 2022
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modifications (see PR 175 comments)
parent
e501da63
Pipeline
#2195
passed with stage
in 1 minute 30 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
60 additions
and
7 deletions
+60
-7
views.py
inventory/views.py
+1
-0
config.md
outils/config.md
+6
-0
models.py
shelfs/models.py
+12
-3
shelf_inventory.js
shelfs/static/js/shelf_inventory.js
+36
-2
views.py
shelfs/views.py
+3
-1
shelf_inventory.html
templates/shelfs/shelf_inventory.html
+2
-1
No files found.
inventory/views.py
View file @
e42f5e6f
...
@@ -47,6 +47,7 @@ def custom_list_inventory(request, id):
...
@@ -47,6 +47,7 @@ def custom_list_inventory(request, id):
context
=
{
'title'
:
'Inventaire'
,
context
=
{
'title'
:
'Inventaire'
,
'products'
:
json
.
dumps
(
products
[
'data'
]),
'products'
:
json
.
dumps
(
products
[
'data'
]),
'ahead_shelfs_ids'
:
json
.
dumps
(
getattr
(
settings
,
'SHELFS_TO_BE_AHEAD_IN_SELECT_LIST'
,
[]))
}
}
# Reuse shelf inventory template: same process
# Reuse shelf inventory template: same process
...
...
outils/config.md
View file @
e42f5e6f
...
@@ -377,6 +377,12 @@
...
@@ -377,6 +377,12 @@
-
MEALS_PICKING_TYPE_ID = 10
-
MEALS_PICKING_TYPE_ID = 10
### Inventory
-
SHELFS_TO_BE_AHEAD_IN_SELECT_LIST =
[
90,74
]
These shelfs (odoo ids) will be shown first in select list
### New members space
### New members space
-
USE_NEW_MEMBERS_SPACE = True
-
USE_NEW_MEMBERS_SPACE = True
...
...
shelfs/models.py
View file @
e42f5e6f
...
@@ -540,10 +540,19 @@ class Shelfs(models.Model):
...
@@ -540,10 +540,19 @@ class Shelfs(models.Model):
try
:
try
:
api
=
OdooAPI
()
api
=
OdooAPI
()
res
[
'done'
]
=
[]
res
[
'done'
]
=
[]
# First of all, group product by shelf_id to save api server calls
products_shelf
=
{}
for
elt
in
data
:
for
elt
in
data
:
f
=
{
'shelf_id'
:
elt
[
'shelf_id'
]}
if
elt
[
'shelf_id'
]
not
in
products_shelf
:
if
api
.
update
(
'product.product'
,
[
elt
[
'product_id'
]],
f
):
products_shelf
[
elt
[
'shelf_id'
]]
=
[]
res
[
'done'
]
.
append
(
elt
[
'product_id'
])
products_shelf
[
elt
[
'shelf_id'
]]
.
append
(
int
(
elt
[
'product_id'
]))
# iterate on each shelf element to record changes
for
shelf_id
,
product_ids
in
products_shelf
.
items
():
f
=
{
'shelf_id'
:
shelf_id
}
if
api
.
update
(
'product.product'
,
product_ids
,
f
):
res
[
'done'
]
+=
product_ids
except
Exception
as
e
:
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
res
[
'error'
]
=
str
(
e
)
coop_logger
.
error
(
"Rayons, make_products_shelf_links :
%
s"
,
str
(
e
))
coop_logger
.
error
(
"Rayons, make_products_shelf_links :
%
s"
,
str
(
e
))
...
...
shelfs/static/js/shelf_inventory.js
View file @
e42f5e6f
...
@@ -387,13 +387,39 @@ async function open_change_shelf_modal() {
...
@@ -387,13 +387,39 @@ async function open_change_shelf_modal() {
But, with CSS changes, it could happen that length == 0
But, with CSS changes, it could happen that length == 0
*/
*/
cons
t
shelfs
=
await
get_all_shelfs
();
le
t
shelfs
=
await
get_all_shelfs
();
if
(
shelfs
!==
null
)
{
if
(
shelfs
!==
null
)
{
let
modal_content
=
$
(
'#templates #change_shelf_form'
).
clone
(),
let
modal_content
=
$
(
'#templates #change_shelf_form'
).
clone
(),
shelf_selector
=
$
(
'<select>'
).
addClass
(
'shelf_selection'
),
shelf_selector
=
$
(
'<select>'
).
addClass
(
'shelf_selection'
),
table
=
modal_content
.
find
(
'table tbody'
).
empty
();
table
=
modal_content
.
find
(
'table tbody'
).
empty
();
//construct shelfs selector
/* construct shelfs selector */
// first of all, sort by name
shelfs
.
sort
((
a
,
b
)
=>
(
a
.
name
>
b
.
name
)
?
1
:
((
b
.
name
>
a
.
name
)
?
-
1
:
0
));
// if ahead_shelfs_ids is not empty, put them ahead
if
(
ahead_shelfs_ids
.
length
>
0
)
{
let
to_move
=
{},
idx
=
0
;
// find index of shelfs to move
shelfs
.
forEach
((
shelf
)
=>
{
if
(
ahead_shelfs_ids
.
indexOf
(
shelf
.
id
)
>
-
1
)
{
to_move
[
shelf
.
id
]
=
idx
;
}
idx
+=
1
;
});
// Respecting ahead_shelfs_ids order, move shelf ahead
// splice can not be used, since more than 1 elt could be involved
let
ahead_elts
=
[];
ahead_shelfs_ids
.
forEach
((
shelf_id
)
=>
{
let
shelf
=
shelfs
[
to_move
[
shelf_id
]];
ahead_elts
.
push
(
shelf
);
});
//remove ahead elts
shelfs
=
shelfs
.
filter
((
item
)
=>
{
return
!
ahead_elts
.
includes
(
item
.
id
)});
// put them ahead by concatenation
shelfs
=
ahead_elts
.
concat
(
shelfs
);
}
shelfs
.
forEach
(
shelfs
.
forEach
(
(
shelf
)
=>
{
(
shelf
)
=>
{
let
option
=
$
(
'<option>'
)
let
option
=
$
(
'<option>'
)
...
@@ -401,6 +427,7 @@ async function open_change_shelf_modal() {
...
@@ -401,6 +427,7 @@ async function open_change_shelf_modal() {
.
text
(
shelf
.
name
+
' ('
+
shelf
.
sort_order
+
')'
);
.
text
(
shelf
.
name
+
' ('
+
shelf
.
sort_order
+
')'
);
shelf_selector
.
append
(
option
);
shelf_selector
.
append
(
option
);
});
});
/* add product rows */
selected_products_for_shelf_change
.
forEach
(
selected_products_for_shelf_change
.
forEach
(
(
product
)
=>
{
(
product
)
=>
{
let
tr
=
$
(
'<tr>'
).
attr
(
'data-id'
,
product
.
id
)
let
tr
=
$
(
'<tr>'
).
attr
(
'data-id'
,
product
.
id
)
...
@@ -429,6 +456,13 @@ async function open_change_shelf_modal() {
...
@@ -429,6 +456,13 @@ async function open_change_shelf_modal() {
(
product_id
)
=>
{
(
product_id
)
=>
{
remove_from_toProcess
(
table_to_process
.
row
(
$
(
'tr#'
+
product_id
)));
remove_from_toProcess
(
table_to_process
.
row
(
$
(
'tr#'
+
product_id
)));
});
});
let
message
=
"L'opération a bien réussi."
;
if
(
update_result
.
length
!==
data
.
length
)
{
message
=
"L'opération a partiellement réussi.
\
n"
;
message
+=
(
data
.
length
-
update_result
.
length
)
+
" produit(s) non déplacé(s)."
;
//TODO: display which products changes were in error
}
alert
(
message
);
}
}
}
}
make_change
();
make_change
();
...
...
shelfs/views.py
View file @
e42f5e6f
...
@@ -47,7 +47,9 @@ def shelf_inventory(request, id):
...
@@ -47,7 +47,9 @@ def shelf_inventory(request, id):
shelf_products
=
Shelf
(
id
)
.
get_products
()
shelf_products
=
Shelf
(
id
)
.
get_products
()
context
=
{
'title'
:
'Inventaire du rayon'
,
context
=
{
'title'
:
'Inventaire du rayon'
,
'products'
:
json
.
dumps
(
shelf_products
[
'data'
])}
'products'
:
json
.
dumps
(
shelf_products
[
'data'
]),
'ahead_shelfs_ids'
:
json
.
dumps
(
getattr
(
settings
,
'SHELFS_TO_BE_AHEAD_IN_SELECT_LIST'
,
[]))
}
template
=
loader
.
get_template
(
'shelfs/shelf_inventory.html'
)
template
=
loader
.
get_template
(
'shelfs/shelf_inventory.html'
)
return
HttpResponse
(
template
.
render
(
context
,
request
))
return
HttpResponse
(
template
.
render
(
context
,
request
))
...
...
templates/shelfs/shelf_inventory.html
View file @
e42f5e6f
...
@@ -186,7 +186,8 @@
...
@@ -186,7 +186,8 @@
</div>
</div>
</div>
</div>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
products
=
{{
products
|
safe
}}
const
ahead_shelfs_ids
=
{{
ahead_shelfs_ids
|
safe
}};
var
products
=
{{
products
|
safe
}};
</script>
</script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script
src=
"{% static "
js
/
all_common
.
js
"
%}?
v=
"></script>
<script src="
{%
static
"
js
/
common
.
js
"
%}?
v=
"></script>
<script src="
{%
static
"
js
/
common
.
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