summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-10-18 12:27:14 +0000
committerfw-bot <otis@odoo.com>2019-10-18 19:41:14 +0000
commitbdc8e948d6992fcacaac69de89449ad7e08f0d35 (patch)
tree37fb2b0139e2a42a72d82873691f2b312e9c5d74 /addons
parent5bb8d068ac0b11b33225e81f12ed67da7ba6da0e (diff)
[FIX] event, website_event: timezone timestamp to compute one day
Have an event in Mexico timezone As a begin date, choose something in the morning As a end date, choose 18:00 in that timezone (or later) in the same day The end date will be written as the day after at 00:00 in UTC Before this commit, the event was considered taking more than one day Also, the rendering on the website took the wrong widget, and did not transform the UTC dates into their TZ value After this commit, the event is considered taking place in the same day The rendering on the website is correct OPW 2087828 closes odoo/odoo#39060 X-original-commit: 4514ff30e9cc218474dda4519e36cfc983e49fc8 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/event/models/event.py4
-rw-r--r--addons/event/tests/test_event_flow.py6
-rw-r--r--addons/website_event/views/event_templates.xml16
3 files changed, 17 insertions, 9 deletions
diff --git a/addons/event/models/event.py b/addons/event/models/event.py
index ced20b54b8f..433aaccf7b5 100644
--- a/addons/event/models/event.py
+++ b/addons/event/models/event.py
@@ -241,7 +241,9 @@ class EventEvent(models.Model):
# Need to localize because it could begin late and finish early in
# another timezone
event = event.with_context(tz=event.date_tz)
- event.is_one_day = (event.date_begin.date() == event.date_end.date())
+ begin_tz = fields.Datetime.context_timestamp(event, event.date_begin)
+ end_tz = fields.Datetime.context_timestamp(event, event.date_end)
+ event.is_one_day = (begin_tz.date() == end_tz.date())
@api.onchange('is_online')
def _onchange_is_online(self):
diff --git a/addons/event/tests/test_event_flow.py b/addons/event/tests/test_event_flow.py
index 7a2364ac4c9..8121528596b 100644
--- a/addons/event/tests/test_event_flow.py
+++ b/addons/event/tests/test_event_flow.py
@@ -116,6 +116,12 @@ class TestEventFlow(TestEventCommon):
def test_event_data(self):
self.event_0.write({'registration_ids': [(0, 0, {'partner_id': self.user_eventuser.partner_id.id})]})
self.assertEqual(self.event_0.registration_ids.get_date_range_str(), u'tomorrow')
+ self.event_0.write({
+ 'date_begin': '2019-11-09 14:30:00',
+ 'date_end': '2019-11-10 00:00:00',
+ 'date_tz': 'Mexico/General'
+ })
+ self.assertTrue(self.event_0.is_one_day)
def test_event_date_range(self):
self.event_0.write({'registration_ids': [(0, 0, {'partner_id': self.user_eventuser.partner_id.id})]})
diff --git a/addons/website_event/views/event_templates.xml b/addons/website_event/views/event_templates.xml
index 9f51854ab3c..25b891c6685 100644
--- a/addons/website_event/views/event_templates.xml
+++ b/addons/website_event/views/event_templates.xml
@@ -188,8 +188,8 @@
<!-- Short Date -->
<div class="o_wevent_event_date position-absolute bg-white shadow-sm">
- <span t-esc="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'LLL'}" class="o_wevent_event_month"/>
- <span t-esc="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'dd'}" class="o_wevent_event_day"/>
+ <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'format': 'LLL'}" class="o_wevent_event_month"/>
+ <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'format': 'dd'}" class="o_wevent_event_day"/>
</div>
<!-- Participating -->
<small t-if="event.is_participating" class="o_wevent_participating bg-success">
@@ -220,7 +220,7 @@
<div t-else="" itemprop="location" t-field="event.address_id" t-options="{'widget': 'contact', 'fields': ['city'], 'no_marker': 'true'}"/>
<!-- Start Date & Time -->
<time itemprop="startDate" t-att-datetime="event.date_begin">
- <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'long'}"/> -
+ <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'long'}"/> -
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'time_only': 'true', 'format': 'short'}"/>
</time>
</main>
@@ -433,8 +433,8 @@
<!-- Date & Time -->
<div class="o_wevent_sidebar_block">
<h6 class="o_wevent_sidebar_title">Date &amp; Time</h6>
- <span t-esc="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'EEEE'}"/>
- <h4 class="my-1" t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'long'}" itemprop="startDate" t-att-datetime="event.date_begin"/>
+ <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'EEEE'}"/>
+ <h4 class="my-1" t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'long'}" itemprop="startDate" t-att-datetime="event.date_begin"/>
<t t-if="not event.is_one_day">Start -</t>
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'time_only': 'true', 'format': 'short'}"/>
<t t-if="event.is_one_day">
@@ -443,8 +443,8 @@
</t>
<t t-else="">
<i class="fa fa-long-arrow-down d-block text-muted mx-3 my-2" style="font-size: 1.5rem"/>
- <span t-esc="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'EEEE'}"/>
- <h4 class="my-1" t-field="event.with_context(tz=event.date_tz).date_end" t-options="{'widget': 'date', 'format': 'long'}"/>
+ <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'EEEE'}"/>
+ <h4 class="my-1" t-field="event.with_context(tz=event.date_tz).date_end" t-options="{'date_only': 'true', 'format': 'long'}"/>
<t t-if="not event.is_one_day">End -</t>
<span t-field="event.with_context(tz=event.date_tz).date_end" t-options="{'time_only': 'true', 'format': 'short'}"/>
</t>
@@ -534,7 +534,7 @@
</t>
<t t-if="event.date_begin">
<t t-set="registration_end">
- End on <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'widget': 'date', 'format': 'medium'}"/>
+ End on <span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'medium'}"/>
</t>
</t>
<t t-set="quantity">