Browse Source

[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
pull/713/head
Richard deMeester 7 years ago
committed by Pedro M. Baeza
parent
commit
6005607727
  1. 2
      web_widget_x2many_2d_matrix/__manifest__.py
  2. 8
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js
  3. 4
      web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml

2
web_widget_x2many_2d_matrix/__manifest__.py

@ -5,7 +5,7 @@
{ {
"name": "2D matrix for x2many fields", "name": "2D matrix for x2many fields",
"version": "10.0.1.0.0",
"version": "10.0.1.0.1",
"author": "Therp BV, " "author": "Therp BV, "
"Tecnativa," "Tecnativa,"
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",

8
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() .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 // setup data structure
_.each(rows, function(row) _.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.val(this.format_xy_value(value));
this.dataset.write($this.data('id'), data); this.dataset.write($this.data('id'), data);
this.by_id[$this.data('id')][this.field_value] = value;
$this.parent().removeClass('oe_form_invalid'); $this.parent().removeClass('oe_form_invalid');
this.compute_totals(); this.compute_totals();
} }
@ -382,7 +383,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
effective_readonly_change: function() effective_readonly_change: function()
{ {
this.$el this.$el
.find('tbody .read')
.find('tbody .edit')
.toggle(!this.get('effective_readonly')); .toggle(!this.get('effective_readonly'));
this.$el this.$el
.find('tbody .read') .find('tbody .read')
@ -404,6 +405,9 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
return $.when(result).then(function() return $.when(result).then(function()
{ {
self.renderElement(); self.renderElement();
self.compute_totals();
self.$el.find('.edit').on(
'change', self.proxy(self.xy_value_change));
}); });
}, },
}); });

4
web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml

@ -16,8 +16,8 @@
<th><t t-esc="widget.get_y_axis_label(y)" /></th> <th><t t-esc="widget.get_y_axis_label(y)" /></th>
<td t-foreach="widget.get_x_axis_values()" t-as="x" t-att-class="'' + (widget.is_numeric ? ' oe_number' : '')" t-att-data-x="x"> <td t-foreach="widget.get_x_axis_values()" t-as="x" t-att-class="'' + (widget.is_numeric ? ' oe_number' : '')" t-att-data-x="x">
<span t-att-class="widget.get_xy_value_class()"> <span t-att-class="widget.get_xy_value_class()">
<input class="edit o_form_input" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" t-att="widget.get_xy_att(x, y)"/>
<span class="read"><t t-esc="widget.format_xy_value(widget.get_xy_value(x, y))" /></span>
<input class="edit o_form_input oe_edit_only" t-att-data-id="widget.get_xy_id(x, y)" t-att-value="widget.format_xy_value(widget.get_xy_value(x, y))" t-att="widget.get_xy_att(x, y)"/>
<span class="read oe_read_only"><t t-esc="widget.format_xy_value(widget.get_xy_value(x, y))" /></span>
</span> </span>
</td> </td>
<td t-if="widget.show_row_totals" class="row_total oe_number" t-att-data-y="y"/> <td t-if="widget.show_row_totals" class="row_total oe_number" t-att-data-y="y"/>

Loading…
Cancel
Save