From 40971b1b4f56d19357190331cd01f675660ba01a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 12 Aug 2015 14:32:53 +0200 Subject: [PATCH] [FIX] calendar,web_calendar: calendar.event: start field readonly The start field is a computed field but it doesn't have any inverse function (write() is overridden in calendar.event to, among other things, play the role of the missing inverse function). It is thus automatically set as readonly, and the events can't be dragged and dropped in the calendar view, since rev. d6d3d098 in which we start checking if the start_date is readonly or not before allowing the drag and drop. This rev. simply adds a "do_nothing" inverse function so that the date field is not readonly. In web_calendar, the date_start attribute is mandatory so fallbacking on date_end and date_delay is unnecessary. --- addons/calendar/calendar.py | 2 +- addons/web_calendar/static/src/js/web_calendar.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/calendar/calendar.py b/addons/calendar/calendar.py index 7b25aaafc9e..a3adfcf243b 100644 --- a/addons/calendar/calendar.py +++ b/addons/calendar/calendar.py @@ -889,7 +889,7 @@ class calendar_event(osv.Model): 'display_time': fields.function(_compute, string='Event Time', type="char", multi='attendee'), 'display_start': fields.function(_compute, string='Date', type="char", multi='attendee', store=True), 'allday': fields.boolean('All Day', states={'done': [('readonly', True)]}), - 'start': fields.function(_compute, string='Start', type="datetime", multi='attendee', store=True, required=True, help="Start date of an event, without time for full days events"), + 'start': fields.function(_compute, fnct_inv=lambda *args: None, string='Start', type="datetime", multi='attendee', store=True, required=True, help="Start date of an event, without time for full days events"), 'stop': fields.function(_compute, string='Stop', type="datetime", multi='attendee', store=True, required=True, help="Stop date of an event, without time for full days events"), 'start_date': fields.date('Start Date', states={'done': [('readonly', True)]}, track_visibility='onchange'), 'start_datetime': fields.datetime('Start DateTime', states={'done': [('readonly', True)]}, track_visibility='onchange'), diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index f002111fa09..7fdb96f0c7c 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -127,8 +127,7 @@ var CalendarView = View.extend({ this.attendee_people = attrs.attendee; // Check whether the date field is editable (i.e. if the events can be dragged and dropped) - var main_date_field = this.date_start || this.date_end || this.date_delay; - this.editable = !this.options.read_only_mode && !this.fields_view.fields[main_date_field].readonly; + this.editable = !this.options.read_only_mode && !this.fields_view.fields[this.date_start].readonly; //if quick_add = False, we don't allow quick_add //if quick_add = not specified in view, we use the default quick_create_instance