[MERGE] forward port of branch 8.0 up to e883193
[odoo/odoo.git] / addons / web / static / src / js / view_list.js
index 359aa28..d7e867a 100644 (file)
@@ -1622,6 +1622,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
                     self.setup_resequence_rows(list, dataset);
                 }).always(function() {
                     if (post_render) { post_render(); }
+                    self.view.trigger('view_list_rendered');
                 });
             });
         return $el;
@@ -2153,7 +2154,8 @@ instance.web.list.columns = new instance.web.Registry({
     'button': 'instance.web.list.Button',
     'field.many2onebutton': 'instance.web.list.Many2OneButton',
     'field.reference': 'instance.web.list.Reference',
-    'field.many2many': 'instance.web.list.Many2Many'
+    'field.many2many': 'instance.web.list.Many2Many',
+    'button.toggle_button': 'instance.web.list.toggle_button',
 });
 instance.web.list.columns.for_ = function (id, field, node) {
     var description = _.extend({tag: node.tag}, field, node.attrs);
@@ -2392,5 +2394,18 @@ instance.web.list.Reference = instance.web.list.Column.extend({
         return this._super(row_data, options);
     }
 });
+instance.web.list.toggle_button = instance.web.list.Column.extend({
+    format: function (row_data, options) {
+        this._super(row_data, options);
+        var button_tips = JSON.parse(this.options);
+        var fieldname = this.field_name;
+        var has_value = row_data[fieldname] && !!row_data[fieldname].value;
+        this.icon = has_value ? 'gtk-yes' : 'gtk-normal';
+        this.string = has_value ? _t(button_tips ? button_tips['active']: ''): _t(button_tips ? button_tips['inactive']: '');
+        return QWeb.render('toggle_button', {
+            widget: this,
+            prefix: instance.session.prefix,
+        });
+    },
+});
 })();
-// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: