Browse Source

Merge 6a25acf6fc into ad79aa45cf

pull/818/merge
Houzéfa Abbasbhay 5 years ago
committed by GitHub
parent
commit
57429d971e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      web_widget_x2many_2d_matrix/__manifest__.py
  2. 8
      web_widget_x2many_2d_matrix/static/src/css/web_widget_x2many_2d_matrix.css
  3. 41
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js
  4. 18
      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",
"version": "10.0.1.0.1",
"version": "10.0.1.0.2",
"author": "Therp BV, "
"Tecnativa,"
"Odoo Community Association (OCA)",

8
web_widget_x2many_2d_matrix/static/src/css/web_widget_x2many_2d_matrix.css

@ -1,8 +1,10 @@
.oe_form_field_x2many_2d_matrix th.oe_link
.o_form_field_x2many_2d_matrix th.oe_link
{
cursor: pointer;
}
.oe_form_field_x2many_2d_matrix .oe_list_content > tbody > tr > td.oe_list_field_cell
/* Reset the background color of disabled input fields in the matrix. */
.o_form_field_x2many_2d_matrix input.o_form_input:disabled
{
white-space: normal;
background-color: lightgrey;
}

41
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -14,7 +14,7 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
var WidgetX2Many2dMatrix = FieldOne2Many.extend({
template: 'FieldX2Many2dMatrix',
widget_class: 'oe_form_field_x2many_2d_matrix',
widget_class: 'o_form_field_x2many_2d_matrix',
// those will be filled with rows from the dataset
by_x_axis: {},
@ -145,7 +145,6 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
self.setup_many2one_axes();
self.$el.find('.edit').on(
'change', self.proxy(self.xy_value_change));
self.effective_readonly_change();
}
});
});
@ -207,13 +206,27 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
this.field_label_y_axis, true);
},
// return the class(es) the inputs should have
// return the class(es) inputs should have
get_xy_value_class: function()
{
var classes = 'oe_form_field oe_form_required';
if(this.is_numeric)
{
classes += ' oe_form_field_float';
var classes = 'edit o_form_input o_form_required oe_edit_only';
if (this.is_numeric) {
classes += ' o_form_field_number';
}
return classes;
},
// return the class(es) read-only inputs should have
get_xy_value_read_only_class: function()
{
var classes = 'read o_form_input';
if (this.is_numeric) {
classes += ' o_form_field_number';
}
if (!this.get('effective_readonly')) {
// When the whole matrix is read-only but shown inside of an editable form, don't
// add "oe_read_only" so our read-only <span>s always show up.
classes += ' oe_read_only';
}
return classes;
},
@ -350,9 +363,6 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
'change', self.proxy(this.xy_value_change));
this.compute_totals();
this.setup_many2one_axes();
this.on("change:effective_readonly",
this, this.proxy(this.effective_readonly_change));
this.effective_readonly_change();
return this._super();
},
@ -380,17 +390,6 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
},
effective_readonly_change: function()
{
this.$el
.find('tbody .edit')
.toggle(!this.get('effective_readonly'));
this.$el
.find('tbody .read')
.toggle(this.get('effective_readonly'));
this.$el.find('.edit').first().focus();
},
is_syntax_valid: function()
{
return this.$el.find('.oe_form_invalid').length == 0;

18
web_widget_x2many_2d_matrix/static/src/xml/web_widget_x2many_2d_matrix.xml

@ -14,20 +14,22 @@
<tbody>
<tr t-foreach="widget.get_y_axis_values()" t-as="y" t-att-data-y="y">
<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">
<span t-att-class="widget.get_xy_value_class()">
<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>
<td t-foreach="widget.get_x_axis_values()" t-as="x" t-att-data-x="x" t-att-class="'' + (widget.is_numeric ? ' o_list_number' : '')">
<input type="text" t-att-class="widget.get_xy_value_class()"
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)"
t-if="!widget.get('effective_readonly')" />
<span t-att-class="widget.get_xy_value_read_only_class()"><t t-esc="widget.format_xy_value(widget.get_xy_value(x, y))" /></span>
</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 o_form_field_number" t-att-data-y="y"/>
</tr>
</tbody>
<tfoot t-if="widget.show_column_totals">
<tr>
<th>Total</th>
<td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_footer oe_number column_total" t-att-data-x="x" />
<td class="grand_total oe_number" />
<td t-foreach="widget.get_x_axis_values()" t-as="x" class="oe_list_footer o_form_field_number column_total" t-att-data-x="x" />
<td class="grand_total o_form_field_number" />
</tr>
</tfoot>
</table>

Loading…
Cancel
Save