diff --git a/tryton/gui/window/view_form/view/calendar_.py b/tryton/gui/window/view_form/view/calendar_.py index f1818d5220..628722e6b5 100644 --- a/tryton/gui/window/view_form/view/calendar_.py +++ b/tryton/gui/window/view_form/view/calendar_.py @@ -82,8 +82,8 @@ class ViewCalendar(View): self.screen.switch_view('form') def on_event_released(self, goocalendar, event): - dtstart = self.attributes.get('dtstart') - dtend = self.attributes.get('dtend') or dtstart + dtstart = self.attributes['dtstart'] + dtend = self.attributes.get('dtend') record = event.record group = record.group previous_start = record[dtstart].get(record) @@ -93,12 +93,12 @@ class ViewCalendar(View): new_start = event.start.date() new_end = event.end.date() if event.end else None if previous_start <= new_start: - if new_end: + if dtend: group.fields[dtend].set_client(record, new_end) group.fields[dtstart].set_client(record, new_start) else: group.fields[dtstart].set_client(record, new_start) - if new_end: + if dtend: group.fields[dtend].set_client(record, new_end) goocalendar.select(new_start) record.save() 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 65798e7389..3a90ee5668 100644 --- a/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py +++ b/tryton/gui/window/view_form/view/calendar_gtk/calendar_.py @@ -19,7 +19,7 @@ class Calendar_(goocalendar.Calendar): self.current_domain_period = self.get_displayed_period() def set_default_date(self, record, selected_date): - dtstart = self.attrs.get('dtstart') + dtstart = self.attrs['dtstart'] record[dtstart].set(record, datetime.datetime.combine(selected_date, datetime.time(0))) @@ -50,7 +50,7 @@ class Calendar_(goocalendar.Calendar): def current_domain(self): first_datetime, last_datetime = \ self.current_domain_period.get_dates(True) - dtstart = self.attrs.get('dtstart') + dtstart = self.attrs['dtstart'] dtend = self.attrs.get('dtend') or dtstart domain = ['OR', ['AND', (dtstart, '>=', first_datetime), @@ -62,8 +62,8 @@ class Calendar_(goocalendar.Calendar): return domain def display(self, group): - dtstart = self.attrs.get('dtstart') - dtend = self.attrs.get('dtend') or dtstart + dtstart = self.attrs['dtstart'] + dtend = self.attrs.get('dtend') if self.screen.current_record: record = self.screen.current_record date = record[dtstart].get(record) @@ -81,7 +81,10 @@ class Calendar_(goocalendar.Calendar): continue start = record[dtstart].get_client(record) - end = record[dtend].get_client(record) + if dtend: + end = record[dtend].get_client(record) + else: + end = None midnight = datetime.time(0) all_day = False if not isinstance(start, datetime.datetime):