From 449805ba5ce51a5c4a338c521fe067af24ff463d Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Tue, 3 Oct 2017 16:13:09 +0200 Subject: [PATCH] [FIX] calendar: fix read method to avoid to read computed field start_date(time) Read(['start', 'start_datetime', 'start_date']) make the cache corrupt for computed field start_datetime or start_date. Now we don't read (for nothing ?) these 2 fields. We can remove the skip for the test #500fabf1 Before this commit, a simple : x = self.create({'name':'subject', 'allday': False, 'start': foo, 'stop': bar}) create randomly an event withtout start_datetime --- addons/calendar/models/calendar.py | 9 +-------- addons/calendar/tests/test_calendar.py | 3 --- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 6de011b2915..01ad86558dc 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -738,13 +738,6 @@ class Meeting(models.Model): allday = fields.Boolean('All Day', states={'done': [('readonly', True)]}, default=False) start_date = fields.Date('Start Date', compute='_compute_dates', inverse='_inverse_dates', store=True, states={'done': [('readonly', True)]}, track_visibility='onchange') start_datetime = fields.Datetime('Start DateTime', compute='_compute_dates', inverse='_inverse_dates', store=True, states={'done': [('readonly', True)]}, track_visibility='onchange') - # FIXME - # If you wonder why `start_datetime` is sometimes not properly recomputed - # and desperately returns `False`, this is due to the override of `read()` - # hereunder that pollutes the cache at recomputing time. - # According to RCO, fixing this should require a redesing of recurring - # events and is probably not trivial... Use `start` instead! - stop_date = fields.Date('End Date', compute='_compute_dates', inverse='_inverse_dates', store=True, states={'done': [('readonly', True)]}, track_visibility='onchange') stop_datetime = fields.Datetime('End Datetime', compute='_compute_dates', inverse='_inverse_dates', store=True, states={'done': [('readonly', True)]}, track_visibility='onchange') # old date_deadline duration = fields.Float('Duration', states={'done': [('readonly', True)]}) @@ -1538,7 +1531,7 @@ class Meeting(models.Model): if not fields: fields = list(self._fields) fields2 = fields and fields[:] - EXTRAFIELDS = ('privacy', 'user_id', 'duration', 'allday', 'start', 'start_date', 'start_datetime', 'rrule') + EXTRAFIELDS = ('privacy', 'user_id', 'duration', 'allday', 'start', 'rrule') for f in EXTRAFIELDS: if fields and (f not in fields): fields2.append(f) diff --git a/addons/calendar/tests/test_calendar.py b/addons/calendar/tests/test_calendar.py index facdf9f70fd..e10976af980 100644 --- a/addons/calendar/tests/test_calendar.py +++ b/addons/calendar/tests/test_calendar.py @@ -4,8 +4,6 @@ import datetime from datetime import datetime, timedelta -from unittest2 import skip - from odoo import fields from odoo.tests.common import TransactionCase @@ -103,7 +101,6 @@ class TestCalendar(TransactionCase): self.assertEqual(calendar_event_sprint_review.byday, '1', 'rrule_type should be mothly') self.assertEqual(calendar_event_sprint_review.week_list, 'MO', 'rrule_type should be mothly') - @skip('Need to fix why start_datetime is not set randomly') def test_validation_error(self): """ Ideally this should build the base event in such a way that calling