Browse Source

[IMP] web_widget_x2many_2d_matrix: Include x_axis_clickable and y_axis_clickable attrs

XML attributes for the widget that allows to configure if the axis will be clickable
or not in case the source field is a many2one field.
pull/1106/head
Pedro M. Baeza 8 years ago
committed by Jairo Llopis
parent
commit
9a2abbc479
  1. 12
      web_widget_x2many_2d_matrix/README.rst
  2. 20
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

12
web_widget_x2many_2d_matrix/README.rst

@ -52,12 +52,20 @@ field_label_x_axis
Use another field to display in the table header
field_label_y_axis
Use another field to display in the table header
x_axis_clickable
It indicates if the X axis allows to be clicked for navigating to the field
(if it's a many2one field). True by default
y_axis_clickable
It indicates if the Y axis allows to be clicked for navigating to the field
(if it's a many2one field). True by default
field_value
Show this field as value
show_row_totals
If field_value is a numeric field, calculate row totals
If field_value is a numeric field, it indicates if you want to calculate
row totals. True by default
show_column_totals
If field_value is a numeric field, calculate column totals
If field_value is a numeric field, it indicates if you want to calculate
column totals. True by default
field_att_<name>
Declare as many options prefixed with this string as you need for binding
a field value with an HTML node attribute (disabled, class, style...)

20
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -27,6 +27,8 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
field_y_axis: 'y',
field_label_y_axis: 'y',
field_value: 'value',
x_axis_clickable: true,
y_axis_clickable: true,
// information about our datatype
is_numeric: false,
show_row_totals: true,
@ -36,6 +38,14 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
// Store fields used to fill HTML attributes
fields_att: {},
parse_boolean: function(val)
{
if (val.toLowerCase() === 'true' || val === '1') {
return true;
}
return false;
},
// read parameters
init: function(field_manager, node)
{
@ -43,6 +53,8 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
this.field_y_axis = node.attrs.field_y_axis || this.field_y_axis;
this.field_label_x_axis = node.attrs.field_label_x_axis || this.field_x_axis;
this.field_label_y_axis = node.attrs.field_label_y_axis || this.field_y_axis;
this.x_axis_clickable = node.attrs.x_axis_clickable != undefined ? this.parse_boolean(node.attrs.x_axis_clickable) : this.x_axis_clickable;
this.y_axis_clickable = node.attrs.y_axis_clickable != undefined ? this.parse_boolean(node.attrs.y_axis_clickable) : this.y_axis_clickable;
this.field_value = node.attrs.field_value || this.field_value;
for (var property in node.attrs) {
if (property.startsWith("field_att_")) {
@ -50,8 +62,8 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
}
}
this.field_editability = node.attrs.field_editability || this.field_editability;
this.show_row_totals = node.attrs.show_row_totals || this.show_row_totals;
this.show_column_totals = node.attrs.show_column_totals || this.show_column_totals;
this.show_row_totals = node.attrs.show_row_totals != undefined ? this.parse_boolean(node.attrs.show_row_totals) : this.show_row_totals;
this.show_column_totals = node.attrs.show_column_totals != undefined ? this.parse_boolean(node.attrs.show_column_totals) : this.show_column_totals;
return this._super(field_manager, node);
},
@ -349,14 +361,14 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
setup_many2one_axes: function()
{
if(this.fields[this.field_x_axis].type == 'many2one')
if(this.fields[this.field_x_axis].type == 'many2one' && this.x_axis_clickable)
{
this.$el.find('th[data-x]').addClass('oe_link')
.click(_.partial(
this.proxy(this.many2one_axis_click),
this.field_x_axis, 'x'));
}
if(this.fields[this.field_y_axis].type == 'many2one')
if(this.fields[this.field_y_axis].type == 'many2one' && this.y_axis_clickable)
{
this.$el.find('tr[data-y] th').addClass('oe_link')
.click(_.partial(

Loading…
Cancel
Save