diff --git a/CHANGELOG b/CHANGELOG index 95725ae3cf..c7af7ca883 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +* Manage readonly dates in calendar view +* Manage editable on calendar view +* Manage model access on calendar view * Set client title at the end of header bar * Manage named separator as label * Add MultiSelection entry to Dict field diff --git a/setup.py b/setup.py index 9a10b6f1d5..63a2d60656 100755 --- a/setup.py +++ b/setup.py @@ -141,7 +141,7 @@ dist = setup(name=name, 'PyGObject', ], extras_require={ - 'calendar': ['GooCalendar>=0.5'], + 'calendar': ['GooCalendar>=0.7'], }, zip_safe=False, test_suite='tryton.tests', diff --git a/tryton/gui/window/view_form/view/calendar_.py b/tryton/gui/window/view_form/view/calendar_.py index c3a4ccb474..ca537cf9e9 100644 --- a/tryton/gui/window/view_form/view/calendar_.py +++ b/tryton/gui/window/view_form/view/calendar_.py @@ -15,6 +15,8 @@ except ImportError as e: Calendar_ = None Toolbar = None +from tryton.common import MODELACCESS + _ = gettext.gettext @@ -120,7 +122,10 @@ class ViewCalendar(View): self.record = None def on_day_activated(self, goocalendar, day): - self.screen.new() + model_access = MODELACCESS[self.screen.model_name] + if (bool(int(self.attributes.get('editable', 1))) + and model_access['create']): + self.screen.new() def __getitem__(self, name): return None diff --git a/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py b/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py index 2e563181f6..f5f5cbdaea 100644 --- a/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py +++ b/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py @@ -5,6 +5,8 @@ import datetime import goocalendar from .dates_period import DatesPeriod +from tryton.common import MODELACCESS + class Calendar_(goocalendar.Calendar): 'Calendar' @@ -90,13 +92,20 @@ class Calendar_(goocalendar.Calendar): event_store = goocalendar.EventStore() + model_access = MODELACCESS[self.view_calendar.screen.model_name] + editable = ( + bool(int(self.view_calendar.attributes.get('editable', 1))) + and model_access['write']) + for record in group: if not record[dtstart].get(record): continue start = record[dtstart].get_client(record) + record[dtstart].state_set(record) if dtend: end = record[dtend].get_client(record) + record[dtend].state_set(record) else: end = None midnight = datetime.time(0) @@ -113,8 +122,15 @@ class Calendar_(goocalendar.Calendar): text_color, bg_color = self.get_colors(record) label = '\n'.join(record[attrs['name']].get_client(record) for attrs in self.fields).rstrip() + event_editable = ( + editable + and not record[dtstart].get_state_attrs(record).get( + 'readonly', False) + and (not dtend + or not record[dtend].get_state_attrs(record).get( + 'readonly', False))) event = goocalendar.Event(label, start, end, text_color=text_color, - bg_color=bg_color, all_day=all_day) + bg_color=bg_color, all_day=all_day, editable=event_editable) event.record = record event_store.add(event) self.event_store = event_store