Skip to content

Commit ef297b6

Browse files
[IMP] web_m2x_options: black, isort, prettier
1 parent 976e223 commit ef297b6

File tree

3 files changed

+39
-34
lines changed

3 files changed

+39
-34
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../web_m2x_options

setup/web_m2x_options/setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

web_m2x_options/static/src/js/form.js

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* Copyright 2016 0k.io,ACSONE SA/NV
22
* * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). */
33

4-
odoo.define("web_m2x_options.web_m2x_options", function(require) {
4+
odoo.define("web_m2x_options.web_m2x_options", function (require) {
55
"use strict";
66

77
var core = require("web.core"),
@@ -23,7 +23,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
2323

2424
var M2ODialog = Dialog.extend({
2525
template: "M2ODialog",
26-
init: function(parent, name, value) {
26+
init: function (parent, name, value) {
2727
this.name = name;
2828
this.value = value;
2929
this._super(parent, {
@@ -33,8 +33,8 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
3333
{
3434
text: _t("Create"),
3535
classes: "btn-primary",
36-
click: function() {
37-
if (this.$("input").val() !== "") {
36+
click: function () {
37+
if (this.$("input").val()) {
3838
this.trigger_up("quick_create", {
3939
value: this.$("input").val(),
4040
});
@@ -48,7 +48,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
4848
text: _t("Create and edit"),
4949
classes: "btn-primary",
5050
close: true,
51-
click: function() {
51+
click: function () {
5252
this.trigger_up("search_create_popup", {
5353
view_type: "form",
5454
value: this.$("input").val(),
@@ -62,7 +62,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
6262
],
6363
});
6464
},
65-
start: function() {
65+
start: function () {
6666
this.$("p").text(
6767
_.str.sprintf(
6868
_t(
@@ -77,14 +77,14 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
7777
* @override
7878
* @param {Boolean} isSet
7979
*/
80-
close: function(isSet) {
80+
close: function (isSet) {
8181
this.isSet = isSet;
8282
this._super.apply(this, arguments);
8383
},
8484
/**
8585
* @override
8686
*/
87-
destroy: function() {
87+
destroy: function () {
8888
if (!this.isSet) {
8989
this.trigger_up("closed_unset");
9090
}
@@ -93,18 +93,18 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
9393
});
9494

9595
FieldMany2One.include({
96-
start: function() {
96+
start: function () {
9797
this._super.apply(this, arguments);
9898
return this.get_options();
9999
},
100100

101-
get_options: function() {
101+
get_options: function () {
102102
var self = this;
103103
if (_.isUndefined(this.ir_options_loaded)) {
104104
this.ir_options_loaded = $.Deferred();
105105
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) {
108108
self.ir_options[record.key] = record.value;
109109
});
110110
self.ir_options_loaded.resolve();
@@ -113,15 +113,15 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
113113
return $.when();
114114
},
115115

116-
is_option_set: function(option) {
116+
is_option_set: function (option) {
117117
if (_.isUndefined(option)) return false;
118118
if (typeof option === "string")
119119
return option === "true" || option === "True";
120120
if (typeof option === "boolean") return option;
121121
return false;
122122
},
123123

124-
_onInputFocusout: function() {
124+
_onInputFocusout: function () {
125125
var m2o_dialog_opt =
126126
this.is_option_set(this.nodeOptions.m2o_dialog) ||
127127
(_.isUndefined(this.nodeOptions.m2o_dialog) &&
@@ -135,12 +135,12 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
135135
}
136136
},
137137

138-
_search: function(search_val) {
138+
_search: function (search_val) {
139139
var self = this;
140140
if (search_val === undefined) {
141141
return this._super.apply(this, arguments);
142142
}
143-
var def = new Promise(resolve => {
143+
var def = new Promise((resolve) => {
144144
// Add options limit used to change number of selections record
145145
// returned.
146146
if (!_.isUndefined(self.ir_options["web_m2x_options.limit"])) {
@@ -173,9 +173,9 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
173173
limit: self.limit + 1,
174174
context: context,
175175
},
176-
}).then(result => {
176+
}).then((result) => {
177177
// Possible selections for the m2o
178-
var values = _.map(result, x => {
178+
var values = _.map(result, (x) => {
179179
x[1] = self._getDisplayName(x[1]);
180180
return {
181181
label:
@@ -197,7 +197,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
197197
method: "search_read",
198198
fields: [self.field_color],
199199
domain: [["id", "in", value_ids]],
200-
}).then(objects => {
200+
}).then((objects) => {
201201
for (var index in objects) {
202202
for (var index_value in values) {
203203
if (values[index_value].id === objects[index].id) {
@@ -240,7 +240,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
240240
if (can_search_more || search_more_undef || search_more) {
241241
values.push({
242242
label: _t("Search More..."),
243-
action: function() {
243+
action: function () {
244244
var prom = [];
245245
if (search_val !== "") {
246246
prom = self._rpc({
@@ -255,10 +255,10 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
255255
},
256256
});
257257
}
258-
Promise.resolve(prom).then(function(results) {
258+
Promise.resolve(prom).then(function (results) {
259259
var dynamicFilters = [];
260260
if (results) {
261-
var ids = _.map(results, function(x) {
261+
var ids = _.map(results, function (x) {
262262
return x[0];
263263
});
264264
if (search_val) {
@@ -290,7 +290,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
290290

291291
var create_enabled = self.can_create && !self.nodeOptions.no_create;
292292
// Quick create
293-
var raw_result = _.map(result, function(x) {
293+
var raw_result = _.map(result, function (x) {
294294
return x[1];
295295
});
296296
var quick_create = self.is_option_set(self.nodeOptions.create),
@@ -317,9 +317,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
317317
values.push({
318318
label: _.str.sprintf(
319319
_t('Create "<strong>%s</strong>"'),
320-
$("<span />")
321-
.text(search_val)
322-
.html()
320+
$("<span />").text(search_val).html()
323321
),
324322
action: self._quickCreate.bind(self, search_val),
325323
classname: "o_m2o_dropdown_option",
@@ -351,7 +349,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
351349
!self.nodeOptions.no_create_edit &&
352350
show_create_edit
353351
) {
354-
var createAndEditAction = function() {
352+
var createAndEditAction = function () {
355353
// Clear the value in case the user clicks on discard
356354
self.$("input").val("");
357355
return self._searchCreatePopup(
@@ -386,21 +384,21 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
386384
"click .badge": "_onOpenBadge",
387385
}),
388386

389-
_onDeleteTag: function(event) {
387+
_onDeleteTag: function (event) {
390388
var result = this._super.apply(this, arguments);
391389
event.stopPropagation();
392390
return result;
393391
},
394392

395-
is_option_set: function(option) {
393+
is_option_set: function (option) {
396394
if (_.isUndefined(option)) return false;
397395
if (typeof option === "string")
398396
return option === "true" || option === "True";
399397
if (typeof option === "boolean") return option;
400398
return false;
401399
},
402400

403-
_onOpenBadge: function(event) {
401+
_onOpenBadge: function (event) {
404402
var self = this;
405403
var open = self.nodeOptions && self.is_option_set(self.nodeOptions.open);
406404
if (open) {
@@ -415,7 +413,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
415413
method: "get_formview_action",
416414
args: [[id]],
417415
context: context,
418-
}).then(function(action) {
416+
}).then(function (action) {
419417
self.trigger_up("do_action", {action: action});
420418
});
421419
} else {
@@ -431,7 +429,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
431429
method: "check_access_rights",
432430
kwargs: {operation: "write", raise_exception: false},
433431
})
434-
).then(function(view_id, write_access) {
432+
).then(function (view_id, write_access) {
435433
var can_write =
436434
"can_write" in self.attrs
437435
? JSON.parse(self.attrs.can_write)
@@ -443,7 +441,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
443441
title: _t("Open: ") + self.string,
444442
view_id: view_id,
445443
readonly: !can_write || !write_access,
446-
on_saved: function(record, changed) {
444+
on_saved: function (record, changed) {
447445
if (changed) {
448446
self._setValue(self.value.data, {
449447
forceChange: true,
@@ -463,7 +461,7 @@ odoo.define("web_m2x_options.web_m2x_options", function(require) {
463461
"click .badge": "_onOpenBadge",
464462
}),
465463

466-
_onOpenBadge: function(event) {
464+
_onOpenBadge: function (event) {
467465
var open = this.is_option_set(this.nodeOptions.open);
468466
var no_color_picker = this.is_option_set(this.nodeOptions.no_color_picker);
469467
this._super.apply(this, arguments);

0 commit comments

Comments
 (0)