Commit e0b4c3d8 by Damien Moulard

INV: display last product added date

parent 793d102f
Pipeline #2165 passed with stage
in 1 minute 28 seconds
......@@ -58,7 +58,11 @@ def add_products(request):
try:
id = int(request.POST.get('shelf_id'))
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:
result['error'] = str(e)
else:
......
......@@ -180,6 +180,18 @@ class Shelf(models.Model):
res['error'] = "L'enregistrement n'a pas pu se réaliser"
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):
"""Save inventory data in a json temp file"""
......
......@@ -15,6 +15,24 @@ function init_datatable() {
{data:"name", title:"Nom"},
{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",
title:"Date dernier inventaire",
render: function (data, type, full, meta) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment