From cb74aab0cd7686426aa631bf3c108ad8d9bf065f Mon Sep 17 00:00:00 2001 From: Richard deMeester Date: Thu, 31 Aug 2017 01:03:06 +1000 Subject: [PATCH] [FIX] web_widget_x2many_2d_matrix: fixes (#712) * Patches to make module operational. * Minor fix to Readonly Switch * Fix to render to set change attribute. * Totals recompute. Fixes #697 --- web_widget_x2many_2d_matrix/__manifest__.py | 2 +- .../static/src/js/web_widget_x2many_2d_matrix.js | 8 ++++++-- .../static/src/xml/web_widget_x2many_2d_matrix.xml | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web_widget_x2many_2d_matrix/__manifest__.py b/web_widget_x2many_2d_matrix/__manifest__.py index b4651c07..69b703cd 100644 --- a/web_widget_x2many_2d_matrix/__manifest__.py +++ b/web_widget_x2many_2d_matrix/__manifest__.py @@ -5,7 +5,7 @@ { "name": "2D matrix for x2many fields", - "version": "10.0.1.0.0", + "version": "10.0.1.0.1", "author": "Therp BV, " "Tecnativa," "Odoo Community Association (OCA)", diff --git a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js index 43fa84bb..ec88f1ea 100644 --- a/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js +++ b/web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js @@ -131,7 +131,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) { }) .then(function() { - return self.dataset.read_ids(self.dataset.ids).then(function(rows) + return self.dataset.read_ids(self.dataset.ids, self.fields).then(function(rows) { // setup data structure _.each(rows, function(row) @@ -369,6 +369,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) { $this.val(this.format_xy_value(value)); this.dataset.write($this.data('id'), data); + this.by_id[$this.data('id')][this.field_value] = value; $this.parent().removeClass('oe_form_invalid'); this.compute_totals(); } @@ -382,7 +383,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) { effective_readonly_change: function() { this.$el - .find('tbody .read') + .find('tbody .edit') .toggle(!this.get('effective_readonly')); this.$el .find('tbody .read') @@ -404,6 +405,9 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) { return $.when(result).then(function() { self.renderElement(); + self.compute_totals(); + self.$el.find('.edit').on( + 'change', self.proxy(self.xy_value_change)); }); }, }); diff --git a/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml b/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml index a1a0d521..b7aaaefe 100644 --- a/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml +++ b/web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml @@ -16,8 +16,8 @@ - - + +