Commit f8b23369 by Damien Moulard

INV: save UTC time & display according to locale timezone (+ linting)

parent 4f963d49
Pipeline #2211 passed with stage
in 3 minutes 48 seconds
......@@ -6,7 +6,7 @@ from products.models import CagetteProducts
from inventory.models import CagetteInventory
import os
from datetime import date, datetime
from datetime import date, datetime, timezone
from openpyxl import Workbook
from openpyxl.styles import Alignment, Font
from statistics import *
......@@ -196,7 +196,7 @@ class Shelf(models.Model):
def set_begin_inventory_datetime(self):
res = {}
now = datetime.now().isoformat()
now = datetime.now(timezone.utc).isoformat() # save UTC time
f = {'ongoing_inv_start_datetime': now}
try:
......
......@@ -355,36 +355,37 @@ var is_product_in_shelf_adding_queue_list = function(testing_pid) {
};
var printProduct = function () {
let clicked = $(this);
let tr_to_print = clicked.closest('tr');
let barcode = tr_to_print.data('bc')
openModal();
try {
$.ajax({
url: '/products/get_product_data',
data: {'barcode': barcode}
})
.done(function(res) {
var product = res.product
var product_tmpl_id = product.product_tmpl_id[0]
let clicked = $(this);
let tr_to_print = clicked.closest('tr');
let barcode = tr_to_print.data('bc');
openModal();
try {
$.ajax({
url: '/products/label_print/' + product_tmpl_id
})
.done(function(res_print) {
closeModal();
if ("error" in res_print.res) {
console.log(res_print.res);
alert('Une erreur est survenue...');
} else {
alert('Impression lancée');
}
url: '/products/get_product_data',
data: {'barcode': barcode}
})
})
} catch(e) {
closeModal();
alert('Une erreur est survenue...');
}
.done(function(res) {
var product = res.product;
var product_tmpl_id = product.product_tmpl_id[0];
$.ajax({
url: '/products/label_print/' + product_tmpl_id
})
.done(function(res_print) {
closeModal();
if ("error" in res_print.res) {
console.log(res_print.res);
alert('Une erreur est survenue...');
} else {
alert('Impression lancée');
}
});
});
} catch (e) {
closeModal();
alert('Une erreur est survenue...');
}
};
......
......@@ -29,6 +29,13 @@ function init_datatable() {
else {
var date = new Date(data);
// Get local timezone offset in minutes
const offset = date.getTimezoneOffset();
// Add offset to saved time.
// offset is negative if the local time zone is ahead of UTC.
date.setTime(date.getTime() - offset * 60 * 1000);
return `${date.toLocaleDateString('fr-FR')} ${date.toLocaleTimeString('fr-FR')}`;
}
}
......
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