From 07bf7bf4f3af49f18a06000ef50ef90d8ad90224 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 3 Jan 2017 11:50:08 -0800 Subject: [PATCH] [FIX] odoo-bin: server UTC timezone on windows On UNIX, the timezone modules conversions can be reset by using `time.tzset()`. On windows this is not available and the timezone (TZ) environment variable must be set before the first import of time module. If not, all datetime gotten in python without specifying UTC (such as datetime.datetime.now) could be wrong. This was fixed with 4a77c6a0 in 2013, but has come back since 389c2ba97b imported pkg_resources (which do a `time` module import) before that. closes #14926 opw-693764 --- addons/point_of_sale/models/pos_order.py | 1 + addons/web/static/src/js/views/form_widgets.js | 1 + odoo-bin | 3 +++ odoo/__init__.py | 13 +++++-------- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index f06b7d5b8df..8f9474c2b81 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -908,5 +908,6 @@ class ReportSaleDetails(models.AbstractModel): def render_html(self, docids, data=None): data = dict(data or {}) configs = self.env['pos.config'].browse(data['config_ids']) + print(data['config_ids']) data.update(self.get_sale_details(data['date_start'], data['date_stop'], configs)) return self.env['report'].render('point_of_sale.report_saledetails', data) diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index c5987ed838c..ceadce4946d 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -426,6 +426,7 @@ var FieldCharDomain = common.AbstractField.extend(common.ReinitializeFieldMixin, this.do_warn(_t('Error: Bad domain'), _t('The domain is wrong.')); return; } + debugger; // EAADD var ds = new data.DataSetStatic(self, model, self.build_context()); ds.call('search_count', [domain]).then(function (results) { self.$('.o_count').text(results + _t(' selected records')); diff --git a/odoo-bin b/odoo-bin index b2a0e17ff83..2670299b150 100755 --- a/odoo-bin +++ b/odoo-bin @@ -1,4 +1,7 @@ #!/usr/bin/env python + +# set server timezone in UTC before time module imported +__import__('os').environ['TZ'] = 'UTC' __import__('pkg_resources').declare_namespace('odoo.addons') import odoo diff --git a/odoo/__init__.py b/odoo/__init__.py index a16b371ebe7..11f7a734c14 100644 --- a/odoo/__init__.py +++ b/odoo/__init__.py @@ -27,15 +27,12 @@ multi_process = False #---------------------------------------------------------- # libc UTC hack #---------------------------------------------------------- -# Make sure the OpenERP server runs in UTC. This is especially necessary -# under Windows as under Linux it seems the real import of time is -# sufficiently deferred so that setting the TZ environment variable -# in odoo.cli.server was working. +# Make sure the OpenERP server runs in UTC. import os -os.environ['TZ'] = 'UTC' # Set the timezone... -import time # ... *then* import time. -del os -del time +os.environ['TZ'] = 'UTC' # Set the timezone +import time +if hasattr(time, 'tzset'): + time.tzset() #---------------------------------------------------------- # Shortcuts