[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
This commit is contained in:
Jeremy Kersten
2017-10-03 23:35:31 +02:00
parent 360bfb7a52
commit 449805ba5c
2 changed files with 1 additions and 11 deletions
+1 -8
View File
@@ -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)
-3
View File
@@ -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