From 54a90ca91910ea4345cf4261b80ea1cb7cfbae9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Sun, 23 Apr 2017 21:03:52 +0200 Subject: [PATCH] [FIX] hr_holidays,web: proper use of toggle_boolean in list view hr_holiday was the only module that used a widget=toggle_boolean on a button in a list view. That behaviour was implemented as a column widget in the previous list view, and was not reimplemented in the new views. The feature is useful, but this was not done properly: it is better to use a widget on a field (that was the intent) instead of doing a weird hack like it was done. With this commit, we update hr_holidays to use the ToggleBoolean widget, which is supposed to work on every views. Also, we fix the toggleboolean widget (it was not properly rendering tooltips, and changes were not saved in readonly list view). Note that it as the side effect of being better from the point of rpcs: before, the list view had to reload itself. Also, another advantage is that models do not need to implement custom methods (such as toggle_payslip_status) just to toggle a boolean... --- addons/hr_holidays/models/hr_holidays.py | 6 -- .../hr_holidays/views/hr_holidays_views.xml | 12 +--- .../web/static/src/js/fields/basic_fields.js | 58 ++++++++++++++----- .../src/js/views/list/list_controller.js | 14 +++++ .../static/tests/fields/basic_fields_tests.js | 37 ++++++++++++ 5 files changed, 98 insertions(+), 29 deletions(-) diff --git a/addons/hr_holidays/models/hr_holidays.py b/addons/hr_holidays/models/hr_holidays.py index 0b66bbf4f06..083d0d4e15a 100644 --- a/addons/hr_holidays/models/hr_holidays.py +++ b/addons/hr_holidays/models/hr_holidays.py @@ -530,12 +530,6 @@ class Holidays(models.Model): self._remove_resource_leave() return True - @api.multi - def toggle_payslip_status(self): - record_to_set_true = self.search([('id', 'in', self.ids), ('payslip_status', '=', False)]) - record_to_set_false = self - record_to_set_true - return record_to_set_true.write({'payslip_status': True}) and record_to_set_false.write({'payslip_status': False}) - #################################################### # Messaging methods #################################################### diff --git a/addons/hr_holidays/views/hr_holidays_views.xml b/addons/hr_holidays/views/hr_holidays_views.xml index 2d6f7da7055..34636085377 100644 --- a/addons/hr_holidays/views/hr_holidays_views.xml +++ b/addons/hr_holidays/views/hr_holidays_views.xml @@ -166,10 +166,8 @@ -