@@ -6,13 +6,15 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
66 "use strict" ;
77
88 var core = require ( 'web.core' ) ;
9- var formats = require ( 'web.formats' ) ;
10- var FieldOne2Many = core . form_widget_registry . get ( 'one2many' ) ;
11- var Model = require ( 'web.Model' ) ;
9+ var FieldManagerMixin = require ( 'web.FieldManagerMixin' ) ;
10+ var Widget = require ( 'web.Widget' ) ;
11+ var fieldRegistry = require ( 'web.field_registry' ) ;
12+ var widgetRegistry = require ( 'web.widget_registry' ) ;
13+ var widgetOne2many = widgetRegistry . get ( 'one2many' ) ;
1214 var data = require ( 'web.data' ) ;
1315 var $ = require ( 'jquery' ) ;
1416
15- var WidgetX2Many2dMatrix = FieldOne2Many . extend ( {
17+ var WidgetX2Many2dMatrix = widgetOne2Many . extend ( FieldManagerMixin , {
1618 template : 'FieldX2Many2dMatrix' ,
1719 widget_class : 'oe_form_field_x2many_2d_matrix' ,
1820
@@ -46,28 +48,39 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
4648 } ,
4749
4850 // read parameters
49- init : function ( field_manager , node )
50- {
51- this . field_x_axis = node . attrs . field_x_axis || this . field_x_axis ;
52- this . field_y_axis = node . attrs . field_y_axis || this . field_y_axis ;
53- this . field_label_x_axis = node . attrs . field_label_x_axis || this . field_x_axis ;
54- this . field_label_y_axis = node . attrs . field_label_y_axis || this . field_y_axis ;
55- this . x_axis_clickable = this . parse_boolean ( node . attrs . x_axis_clickable || '1' ) ;
56- this . y_axis_clickable = this . parse_boolean ( node . attrs . y_axis_clickable || '1' ) ;
57- this . field_value = node . attrs . field_value || this . field_value ;
58- for ( var property in node . attrs ) {
51+ init : function ( parent , fieldname , record , therest ) {
52+ var res = this . _super ( parent , fieldname , record , therest ) ;
53+ FieldManagerMixin . init . call ( this ) ;
54+ var node = record . fieldsInfo [ therest . viewType ] [ fieldname ] ;
55+
56+ this . field_x_axis = node . field_x_axis || this . field_x_axis ;
57+ this . field_y_axis = node . field_y_axis || this . field_y_axis ;
58+ this . field_label_x_axis = node . field_label_x_axis || this . field_x_axis ;
59+ this . field_label_y_axis = node . field_label_y_axis || this . field_y_axis ;
60+ this . x_axis_clickable = this . parse_boolean ( node . x_axis_clickable || '1' ) ;
61+ this . y_axis_clickable = this . parse_boolean ( node . y_axis_clickable || '1' ) ;
62+ this . field_value = node . field_value || this . field_value ;
63+ for ( var property in node ) {
5964 if ( property . startsWith ( "field_att_" ) ) {
60- this . fields_att [ property . substring ( 10 ) ] = node . attrs [ property ] ;
65+ this . fields_att [ property . substring ( 10 ) ] = node [ property ] ;
6166 }
6267 }
63- this . field_editability = node . attrs . field_editability || this . field_editability ;
64- this . show_row_totals = this . parse_boolean ( node . attrs . show_row_totals || '1' ) ;
65- this . show_column_totals = this . parse_boolean ( node . attrs . show_column_totals || '1' ) ;
66- return this . _super ( field_manager , node ) ;
68+ this . field_editability = node . field_editability || this . field_editability ;
69+ this . show_row_totals = this . parse_boolean ( node . show_row_totals || '1' ) ;
70+ this . show_column_totals = this . parse_boolean ( node . show_column_totals || '1' ) ;
71+ this . init_fields ( ) ;
72+ // this.set_value(undefined);
73+
74+ return res ;
75+ } ,
76+
77+ init_fields : function ( ) {
78+ return ;
6779 } ,
6880
6981 // return a field's value, id in case it's a one2many field
7082 get_field_value : function ( row , field , many2one_as_name )
83+ // FIXME looks silly
7184 {
7285 if ( this . fields [ field ] . type == 'many2one' && _ . isArray ( row [ field ] ) )
7386 {
@@ -262,15 +275,13 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
262275 // parse a value from user input
263276 parse_xy_value : function ( val )
264277 {
265- return formats . parse_value (
266- val , { 'type' : this . fields [ this . field_value ] . type } ) ;
278+ return val ;
267279 } ,
268280
269281 // format a value from the database for display
270282 format_xy_value : function ( val )
271283 {
272- return formats . format_value (
273- val , { 'type' : this . fields [ this . field_value ] . type } ) ;
284+ return val ;
274285 } ,
275286
276287 // compute totals
@@ -412,7 +423,11 @@ odoo.define('web_widget_x2many_2d_matrix.widget', function (require) {
412423 } ,
413424 } ) ;
414425
415- core . form_widget_registry . add ( 'x2many_2d_matrix' , WidgetX2Many2dMatrix ) ;
426+ fieldRegistry . add (
427+ 'x2many_2d_matrix' , WidgetX2Many2dMatrix
428+ ) ;
416429
417- return WidgetX2Many2dMatrix ;
430+ return {
431+ WidgetX2Many2dMatrix : WidgetX2Many2dMatrix
432+ } ;
418433} ) ;
0 commit comments