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
f8b23369
Commit
f8b23369
authored
May 23, 2022
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
INV: save UTC time & display according to locale timezone (+ linting)
parent
4f963d49
Pipeline
#2211
passed with stage
in 3 minutes 48 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
30 deletions
+38
-30
models.py
shelfs/models.py
+2
-2
shelf_inventory.js
shelfs/static/js/shelf_inventory.js
+0
-0
shelfs_admin.js
shelfs/static/js/shelfs_admin.js
+29
-28
shelfs_index.js
shelfs/static/js/shelfs_index.js
+7
-0
No files found.
shelfs/models.py
View file @
f8b23369
...
@@ -6,7 +6,7 @@ from products.models import CagetteProducts
...
@@ -6,7 +6,7 @@ from products.models import CagetteProducts
from
inventory.models
import
CagetteInventory
from
inventory.models
import
CagetteInventory
import
os
import
os
from
datetime
import
date
,
datetime
from
datetime
import
date
,
datetime
,
timezone
from
openpyxl
import
Workbook
from
openpyxl
import
Workbook
from
openpyxl.styles
import
Alignment
,
Font
from
openpyxl.styles
import
Alignment
,
Font
from
statistics
import
*
from
statistics
import
*
...
@@ -196,7 +196,7 @@ class Shelf(models.Model):
...
@@ -196,7 +196,7 @@ class Shelf(models.Model):
def
set_begin_inventory_datetime
(
self
):
def
set_begin_inventory_datetime
(
self
):
res
=
{}
res
=
{}
now
=
datetime
.
now
(
)
.
isoformat
()
now
=
datetime
.
now
(
timezone
.
utc
)
.
isoformat
()
# save UTC time
f
=
{
'ongoing_inv_start_datetime'
:
now
}
f
=
{
'ongoing_inv_start_datetime'
:
now
}
try
:
try
:
...
...
shelfs/static/js/shelf_inventory.js
View file @
f8b23369
This diff is collapsed.
Click to expand it.
shelfs/static/js/shelfs_admin.js
View file @
f8b23369
...
@@ -355,36 +355,37 @@ var is_product_in_shelf_adding_queue_list = function(testing_pid) {
...
@@ -355,36 +355,37 @@ var is_product_in_shelf_adding_queue_list = function(testing_pid) {
};
};
var
printProduct
=
function
()
{
var
printProduct
=
function
()
{
let
clicked
=
$
(
this
);
let
clicked
=
$
(
this
);
let
tr_to_print
=
clicked
.
closest
(
'tr'
);
let
tr_to_print
=
clicked
.
closest
(
'tr'
);
let
barcode
=
tr_to_print
.
data
(
'bc'
)
let
barcode
=
tr_to_print
.
data
(
'bc'
);
openModal
();
openModal
();
try
{
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
]
$
.
ajax
({
$
.
ajax
({
url
:
'/products/label_print/'
+
product_tmpl_id
url
:
'/products/get_product_data'
,
})
data
:
{
'barcode'
:
barcode
}
.
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'
);
}
})
})
})
.
done
(
function
(
res
)
{
}
catch
(
e
)
{
var
product
=
res
.
product
;
closeModal
();
var
product_tmpl_id
=
product
.
product_tmpl_id
[
0
];
alert
(
'Une erreur est survenue...'
);
}
$
.
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...'
);
}
};
};
...
...
shelfs/static/js/shelfs_index.js
View file @
f8b23369
...
@@ -29,6 +29,13 @@ function init_datatable() {
...
@@ -29,6 +29,13 @@ function init_datatable() {
else
{
else
{
var
date
=
new
Date
(
data
);
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'
)}
`
;
return
`
${
date
.
toLocaleDateString
(
'fr-FR'
)}
${
date
.
toLocaleTimeString
(
'fr-FR'
)}
`
;
}
}
}
}
...
...
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