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
e0b4c3d8
Commit
e0b4c3d8
authored
May 03, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
INV: display last product added date
parent
793d102f
Pipeline
#2165
passed with stage
in 1 minute 28 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletions
+35
-1
admin.py
shelfs/admin.py
+5
-1
models.py
shelfs/models.py
+12
-0
shelfs_index.js
shelfs/static/js/shelfs_index.js
+18
-0
No files found.
shelfs/admin.py
View file @
e0b4c3d8
...
@@ -58,7 +58,11 @@ def add_products(request):
...
@@ -58,7 +58,11 @@ def add_products(request):
try
:
try
:
id
=
int
(
request
.
POST
.
get
(
'shelf_id'
))
id
=
int
(
request
.
POST
.
get
(
'shelf_id'
))
barcodes
=
json
.
loads
(
request
.
POST
.
get
(
'bc'
))
barcodes
=
json
.
loads
(
request
.
POST
.
get
(
'bc'
))
result
=
Shelf
(
id
)
.
add_products_by_barcodes
(
barcodes
)
m
=
Shelf
(
id
)
result
=
m
.
add_products_by_barcodes
(
barcodes
)
# Update shelf last product added date
result
[
"update_last_product_added_date"
]
=
m
.
update_last_product_added_date
()
except
Exception
as
e
:
except
Exception
as
e
:
result
[
'error'
]
=
str
(
e
)
result
[
'error'
]
=
str
(
e
)
else
:
else
:
...
...
shelfs/models.py
View file @
e0b4c3d8
...
@@ -180,6 +180,18 @@ class Shelf(models.Model):
...
@@ -180,6 +180,18 @@ class Shelf(models.Model):
res
[
'error'
]
=
"L'enregistrement n'a pas pu se réaliser"
res
[
'error'
]
=
"L'enregistrement n'a pas pu se réaliser"
return
res
return
res
def
update_last_product_added_date
(
self
):
res
=
{}
today
=
date
.
today
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
f
=
{
'date_last_product_added'
:
today
}
try
:
res
[
"update"
]
=
self
.
o_api
.
update
(
'product.shelfs'
,
self
.
id
,
f
)
except
Exception
as
e
:
res
[
'error'
]
=
str
(
e
)
return
res
def
save_tmp_inventory
(
self
,
inventory_data
):
def
save_tmp_inventory
(
self
,
inventory_data
):
"""Save inventory data in a json temp file"""
"""Save inventory data in a json temp file"""
...
...
shelfs/static/js/shelfs_index.js
View file @
e0b4c3d8
...
@@ -15,6 +15,24 @@ function init_datatable() {
...
@@ -15,6 +15,24 @@ function init_datatable() {
{
data
:
"name"
,
title
:
"Nom"
},
{
data
:
"name"
,
title
:
"Nom"
},
{
data
:
"description"
,
title
:
"Description"
,
orderable
:
false
},
{
data
:
"description"
,
title
:
"Description"
,
orderable
:
false
},
{
{
data
:
"date_last_product_added"
,
title
:
"Dernier ajout produit"
,
render
:
function
(
data
,
type
)
{
// Sort on data, not rendering
if
(
type
==
"sort"
||
type
==
'type'
)
return
data
;
if
(
data
==
'0001-01-01'
)
return
""
;
else
{
var
date
=
new
Date
(
data
);
return
date
.
toLocaleDateString
(
'fr-FR'
);
}
}
},
{
data
:
"date_last_inventory"
,
data
:
"date_last_inventory"
,
title
:
"Date dernier inventaire"
,
title
:
"Date dernier inventaire"
,
render
:
function
(
data
,
type
,
full
,
meta
)
{
render
:
function
(
data
,
type
,
full
,
meta
)
{
...
...
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