From f711e6d6a2a37f52dac050caa14efc004c350918 Mon Sep 17 00:00:00 2001 From: Hetal Dhanak Date: Fri, 11 Jan 2019 04:38:02 +0000 Subject: [PATCH] [IMP] calendar: Improve calendar alarm computed name Improve usability of fields 'reminder_ids' (calendar.appointment.type) and 'alarm_ids' (calendar.event) If the user does not set a meaningful 'name' on a newly created calendar.alarm, it is a pain to select the desired record from those fields. (Also, user should be able to edit existing calendar.alarm) Related Task ID: 1923205 closes odoo/odoo#30129 --- addons/calendar/data/calendar_data.xml | 14 +++++++------- addons/calendar/models/calendar.py | 5 +++-- addons/calendar/views/calendar_views.xml | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/calendar/data/calendar_data.xml b/addons/calendar/data/calendar_data.xml index a6bdafed7a6..5485326fd14 100644 --- a/addons/calendar/data/calendar_data.xml +++ b/addons/calendar/data/calendar_data.xml @@ -8,43 +8,43 @@ - 15 Minute(s) + Notification - 15 Minute(s) minutes notification - 30 Minute(s) + Notification - 30 Minute(s) minutes notification - 1 Hour(s) + Notification - 1 Hour(s) hours notification - 2 Hour(s) + Notification - 2 Hour(s) hours notification - 1 Day(s) + Notification - 1 Day(s) days notification - 3 Hour(s), by e-mail + Email - 3 Hour(s) hours email - 6 Hour(s), by e-mail + Email - 6 Hour(s) hours email diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 1e51c5fa521..a8830712b16 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -492,10 +492,11 @@ class Alarm(models.Model): interval = fields.Selection(list(_interval_selection.items()), 'Unit', required=True, default='hours') duration_minutes = fields.Integer('Duration in minutes', compute='_compute_duration_minutes', store=True, help="Duration in minutes") - @api.onchange('duration', 'interval') + @api.onchange('duration', 'interval', 'alarm_type') def _onchange_duration_interval(self): display_interval = self._interval_selection.get(self.interval, '') - self.name = str(self.duration) + ' ' + display_interval + display_alarm_type = {key: value for key, value in self._fields['alarm_type']._description_selection(self.env)}[self.alarm_type] + self.name = "%s - %s %s" % (display_alarm_type, self.duration, display_interval) def _update_cron(self): try: diff --git a/addons/calendar/views/calendar_views.xml b/addons/calendar/views/calendar_views.xml index a59e24fb855..e106534bdac 100644 --- a/addons/calendar/views/calendar_views.xml +++ b/addons/calendar/views/calendar_views.xml @@ -25,7 +25,7 @@ calendar.alarm - + @@ -40,8 +40,8 @@
- - + +