1
1
/* Copyright 2016 0k.io,ACSONE SA/NV
2
2
* * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
3
3
4
- odoo . define ( "web_m2x_options.web_m2x_options" , function ( require ) {
4
+ odoo . define ( "web_m2x_options.web_m2x_options" , function ( require ) {
5
5
"use strict" ;
6
6
7
7
var core = require ( "web.core" ) ,
@@ -23,7 +23,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
23
23
24
24
var M2ODialog = Dialog . extend ( {
25
25
template : "M2ODialog" ,
26
- init : function ( parent , name , value ) {
26
+ init : function ( parent , name , value ) {
27
27
this . name = name ;
28
28
this . value = value ;
29
29
this . _super ( parent , {
@@ -33,8 +33,8 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
33
33
{
34
34
text : _t ( "Create" ) ,
35
35
classes : "btn-primary" ,
36
- click : function ( ) {
37
- if ( this . $ ( "input" ) . val ( ) !== "" ) {
36
+ click : function ( ) {
37
+ if ( this . $ ( "input" ) . val ( ) ) {
38
38
this . trigger_up ( "quick_create" , {
39
39
value : this . $ ( "input" ) . val ( ) ,
40
40
} ) ;
@@ -48,7 +48,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
48
48
text : _t ( "Create and edit" ) ,
49
49
classes : "btn-primary" ,
50
50
close : true ,
51
- click : function ( ) {
51
+ click : function ( ) {
52
52
this . trigger_up ( "search_create_popup" , {
53
53
view_type : "form" ,
54
54
value : this . $ ( "input" ) . val ( ) ,
@@ -62,7 +62,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
62
62
] ,
63
63
} ) ;
64
64
} ,
65
- start : function ( ) {
65
+ start : function ( ) {
66
66
this . $ ( "p" ) . text (
67
67
_ . str . sprintf (
68
68
_t (
@@ -77,14 +77,14 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
77
77
* @override
78
78
* @param {Boolean } isSet
79
79
*/
80
- close : function ( isSet ) {
80
+ close : function ( isSet ) {
81
81
this . isSet = isSet ;
82
82
this . _super . apply ( this , arguments ) ;
83
83
} ,
84
84
/**
85
85
* @override
86
86
*/
87
- destroy : function ( ) {
87
+ destroy : function ( ) {
88
88
if ( ! this . isSet ) {
89
89
this . trigger_up ( "closed_unset" ) ;
90
90
}
@@ -93,18 +93,18 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
93
93
} ) ;
94
94
95
95
FieldMany2One . include ( {
96
- start : function ( ) {
96
+ start : function ( ) {
97
97
this . _super . apply ( this , arguments ) ;
98
98
return this . get_options ( ) ;
99
99
} ,
100
100
101
- get_options : function ( ) {
101
+ get_options : function ( ) {
102
102
var self = this ;
103
103
if ( _ . isUndefined ( this . ir_options_loaded ) ) {
104
104
this . ir_options_loaded = $ . Deferred ( ) ;
105
105
this . ir_options = { } ;
106
- web_m2x_options . then ( function ( records ) {
107
- _ ( records ) . each ( function ( record ) {
106
+ web_m2x_options . then ( function ( records ) {
107
+ _ ( records ) . each ( function ( record ) {
108
108
self . ir_options [ record . key ] = record . value ;
109
109
} ) ;
110
110
self . ir_options_loaded . resolve ( ) ;
@@ -113,15 +113,15 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
113
113
return $ . when ( ) ;
114
114
} ,
115
115
116
- is_option_set : function ( option ) {
116
+ is_option_set : function ( option ) {
117
117
if ( _ . isUndefined ( option ) ) return false ;
118
118
if ( typeof option === "string" )
119
119
return option === "true" || option === "True" ;
120
120
if ( typeof option === "boolean" ) return option ;
121
121
return false ;
122
122
} ,
123
123
124
- _onInputFocusout : function ( ) {
124
+ _onInputFocusout : function ( ) {
125
125
var m2o_dialog_opt =
126
126
this . is_option_set ( this . nodeOptions . m2o_dialog ) ||
127
127
( _ . isUndefined ( this . nodeOptions . m2o_dialog ) &&
@@ -135,12 +135,12 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
135
135
}
136
136
} ,
137
137
138
- _search : function ( search_val ) {
138
+ _search : function ( search_val ) {
139
139
var self = this ;
140
140
if ( search_val === undefined ) {
141
141
return this . _super . apply ( this , arguments ) ;
142
142
}
143
- var def = new Promise ( resolve => {
143
+ var def = new Promise ( ( resolve ) => {
144
144
// Add options limit used to change number of selections record
145
145
// returned.
146
146
if ( ! _ . isUndefined ( self . ir_options [ "web_m2x_options.limit" ] ) ) {
@@ -173,9 +173,9 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
173
173
limit : self . limit + 1 ,
174
174
context : context ,
175
175
} ,
176
- } ) . then ( result => {
176
+ } ) . then ( ( result ) => {
177
177
// Possible selections for the m2o
178
- var values = _ . map ( result , x => {
178
+ var values = _ . map ( result , ( x ) => {
179
179
x [ 1 ] = self . _getDisplayName ( x [ 1 ] ) ;
180
180
return {
181
181
label :
@@ -197,7 +197,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
197
197
method : "search_read" ,
198
198
fields : [ self . field_color ] ,
199
199
domain : [ [ "id" , "in" , value_ids ] ] ,
200
- } ) . then ( objects => {
200
+ } ) . then ( ( objects ) => {
201
201
for ( var index in objects ) {
202
202
for ( var index_value in values ) {
203
203
if ( values [ index_value ] . id === objects [ index ] . id ) {
@@ -240,7 +240,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
240
240
if ( can_search_more || search_more_undef || search_more ) {
241
241
values . push ( {
242
242
label : _t ( "Search More..." ) ,
243
- action : function ( ) {
243
+ action : function ( ) {
244
244
var prom = [ ] ;
245
245
if ( search_val !== "" ) {
246
246
prom = self . _rpc ( {
@@ -255,10 +255,10 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
255
255
} ,
256
256
} ) ;
257
257
}
258
- Promise . resolve ( prom ) . then ( function ( results ) {
258
+ Promise . resolve ( prom ) . then ( function ( results ) {
259
259
var dynamicFilters = [ ] ;
260
260
if ( results ) {
261
- var ids = _ . map ( results , function ( x ) {
261
+ var ids = _ . map ( results , function ( x ) {
262
262
return x [ 0 ] ;
263
263
} ) ;
264
264
if ( search_val ) {
@@ -290,7 +290,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
290
290
291
291
var create_enabled = self . can_create && ! self . nodeOptions . no_create ;
292
292
// Quick create
293
- var raw_result = _ . map ( result , function ( x ) {
293
+ var raw_result = _ . map ( result , function ( x ) {
294
294
return x [ 1 ] ;
295
295
} ) ;
296
296
var quick_create = self . is_option_set ( self . nodeOptions . create ) ,
@@ -317,9 +317,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
317
317
values . push ( {
318
318
label : _ . str . sprintf (
319
319
_t ( 'Create "<strong>%s</strong>"' ) ,
320
- $ ( "<span />" )
321
- . text ( search_val )
322
- . html ( )
320
+ $ ( "<span />" ) . text ( search_val ) . html ( )
323
321
) ,
324
322
action : self . _quickCreate . bind ( self , search_val ) ,
325
323
classname : "o_m2o_dropdown_option" ,
@@ -351,7 +349,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
351
349
! self . nodeOptions . no_create_edit &&
352
350
show_create_edit
353
351
) {
354
- var createAndEditAction = function ( ) {
352
+ var createAndEditAction = function ( ) {
355
353
// Clear the value in case the user clicks on discard
356
354
self . $ ( "input" ) . val ( "" ) ;
357
355
return self . _searchCreatePopup (
@@ -386,21 +384,21 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
386
384
"click .badge" : "_onOpenBadge" ,
387
385
} ) ,
388
386
389
- _onDeleteTag : function ( event ) {
387
+ _onDeleteTag : function ( event ) {
390
388
var result = this . _super . apply ( this , arguments ) ;
391
389
event . stopPropagation ( ) ;
392
390
return result ;
393
391
} ,
394
392
395
- is_option_set : function ( option ) {
393
+ is_option_set : function ( option ) {
396
394
if ( _ . isUndefined ( option ) ) return false ;
397
395
if ( typeof option === "string" )
398
396
return option === "true" || option === "True" ;
399
397
if ( typeof option === "boolean" ) return option ;
400
398
return false ;
401
399
} ,
402
400
403
- _onOpenBadge : function ( event ) {
401
+ _onOpenBadge : function ( event ) {
404
402
var self = this ;
405
403
var open = self . nodeOptions && self . is_option_set ( self . nodeOptions . open ) ;
406
404
if ( open ) {
@@ -415,7 +413,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
415
413
method : "get_formview_action" ,
416
414
args : [ [ id ] ] ,
417
415
context : context ,
418
- } ) . then ( function ( action ) {
416
+ } ) . then ( function ( action ) {
419
417
self . trigger_up ( "do_action" , { action : action } ) ;
420
418
} ) ;
421
419
} else {
@@ -431,7 +429,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
431
429
method : "check_access_rights" ,
432
430
kwargs : { operation : "write" , raise_exception : false } ,
433
431
} )
434
- ) . then ( function ( view_id , write_access ) {
432
+ ) . then ( function ( view_id , write_access ) {
435
433
var can_write =
436
434
"can_write" in self . attrs
437
435
? JSON . parse ( self . attrs . can_write )
@@ -443,7 +441,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
443
441
title : _t ( "Open: " ) + self . string ,
444
442
view_id : view_id ,
445
443
readonly : ! can_write || ! write_access ,
446
- on_saved : function ( record , changed ) {
444
+ on_saved : function ( record , changed ) {
447
445
if ( changed ) {
448
446
self . _setValue ( self . value . data , {
449
447
forceChange : true ,
@@ -463,7 +461,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
463
461
"click .badge" : "_onOpenBadge" ,
464
462
} ) ,
465
463
466
- _onOpenBadge : function ( event ) {
464
+ _onOpenBadge : function ( event ) {
467
465
var open = this . is_option_set ( this . nodeOptions . open ) ;
468
466
var no_color_picker = this . is_option_set ( this . nodeOptions . no_color_picker ) ;
469
467
this . _super . apply ( this , arguments ) ;
0 commit comments