Browse Source

[ADD] Ability to parse * and change boolean True/False

pull/487/head
Sebastian Kennedy 7 years ago
parent
commit
074c83080f
  1. 30
      web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

30
web_widget_x2many_2d_matrix/static/src/js/web_widget_x2many_2d_matrix.js

@ -221,6 +221,12 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
this.by_id[row.id] = row;
},
boolean_is_true: function(x, y)
{
return this.get_field_value(
this.by_x_axis[x][y], this.boolean_field_value);
},
// get x axis values in the correct order
get_x_axis_values: function()
{
@ -324,6 +330,16 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
val, {'type': this.fields[this.field_value].type});
},
// format a value from the database for display
format_xy_cell_value: function(put_special_caracter,val)
{
if (put_special_caracter) {
val = '*'.concat(val)
}
return instance.web.format_value(
val, {'type': "string"});
},
// compute totals
compute_totals: function()
{
@ -411,10 +427,13 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
{
var $this = jQuery(e.currentTarget),
val = $this.val();
val_sub = val.substring(1)
val_pre = val.substring(0,1)
if(this.validate_xy_value(val))
{
var data = {}, value = this.parse_xy_value(val);
data[this.field_value] = value;
data[this.boolean_field_value] = false;
$this.siblings('.read').text(this.format_xy_value(value));
$this.val(this.format_xy_value(value));
@ -423,6 +442,17 @@ openerp.web_widget_x2many_2d_matrix = function(instance)
$this.parent().removeClass('oe_form_invalid');
this.compute_totals();
}
else if(this.validate_xy_value(val_sub) && val_pre == '*'){
var data = {}, value = this.parse_xy_value(val_sub);
data[this.field_value] = value;
data[this.boolean_field_value] = true;
$this.siblings('.read').text(val);
this.dataset.write($this.data('id'), data);
$this.parent().removeClass('oe_form_invalid');
this.compute_totals();
}
else
{
$this.parent().addClass('oe_form_invalid');

Loading…
Cancel
Save