Skip to content
Snippets Groups Projects
Commit 449805ba authored by Jeremy Kersten's avatar Jeremy Kersten
Browse files

[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
parent 360bfb7a
No related branches found
No related tags found
No related merge requests found
...@@ -738,13 +738,6 @@ class Meeting(models.Model): ...@@ -738,13 +738,6 @@ class Meeting(models.Model):
allday = fields.Boolean('All Day', states={'done': [('readonly', True)]}, default=False) 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_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') 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_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 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)]}) duration = fields.Float('Duration', states={'done': [('readonly', True)]})
...@@ -1538,7 +1531,7 @@ class Meeting(models.Model): ...@@ -1538,7 +1531,7 @@ class Meeting(models.Model):
if not fields: if not fields:
fields = list(self._fields) fields = list(self._fields)
fields2 = fields and 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: for f in EXTRAFIELDS:
if fields and (f not in fields): if fields and (f not in fields):
fields2.append(f) fields2.append(f)
......
...@@ -4,8 +4,6 @@ import datetime ...@@ -4,8 +4,6 @@ import datetime
from datetime import datetime, timedelta from datetime import datetime, timedelta
from unittest2 import skip
from odoo import fields from odoo import fields
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
...@@ -103,7 +101,6 @@ class TestCalendar(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.byday, '1', 'rrule_type should be mothly')
self.assertEqual(calendar_event_sprint_review.week_list, 'MO', '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): def test_validation_error(self):
""" """
Ideally this should build the base event in such a way that calling Ideally this should build the base event in such a way that calling
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment