mirror of https://github.com/OCA/web.git
[IMP] web_widget_many2one_simple: isort, black, prettier.
parent
f82fade4ae
commit
9e039a114f
|
@ -1,4 +1,4 @@
|
||||||
odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require) {
|
odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const core = require("web.core");
|
const core = require("web.core");
|
||||||
|
@ -28,7 +28,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
init: function(parent, name, record, options) {
|
init: function (parent, name, record, options) {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
this.can_create =
|
this.can_create =
|
||||||
|
@ -57,7 +57,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
*/
|
*/
|
||||||
start: function() {
|
start: function () {
|
||||||
this.$input = this.$("input");
|
this.$input = this.$("input");
|
||||||
this.$external_button = this.$(".o_external_button");
|
this.$external_button = this.$(".o_external_button");
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
|
@ -67,7 +67,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @param {Object} value (format: {id: ..., display_name: ...})
|
* @param {Object} value (format: {id: ..., display_name: ...})
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
reinitialize: function(value) {
|
reinitialize: function (value) {
|
||||||
this.isDirty = false;
|
this.isDirty = false;
|
||||||
return this._setValue(value).then(() => {
|
return this._setValue(value).then(() => {
|
||||||
const formatted_value = this._formatValue(this.value);
|
const formatted_value = this._formatValue(this.value);
|
||||||
|
@ -78,7 +78,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
_search: function() {
|
_search: function () {
|
||||||
if (!this.isDirty) {
|
if (!this.isDirty) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
domain: _.union(domain, this._getDomain()),
|
domain: _.union(domain, this._getDomain()),
|
||||||
limit: 1,
|
limit: 1,
|
||||||
kwargs: {context: context},
|
kwargs: {context: context},
|
||||||
}).then(results => {
|
}).then((results) => {
|
||||||
if (_.isEmpty(results)) {
|
if (_.isEmpty(results)) {
|
||||||
if (this.can_create) {
|
if (this.can_create) {
|
||||||
const create_context = _.extend({}, this.attrs.context);
|
const create_context = _.extend({}, this.attrs.context);
|
||||||
|
@ -134,7 +134,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_renderEdit: function() {
|
_renderEdit: function () {
|
||||||
const value = this._formatValue(this.value);
|
const value = this._formatValue(this.value);
|
||||||
this.$input.val(value);
|
this.$input.val(value);
|
||||||
this._updateExternalButton();
|
this._updateExternalButton();
|
||||||
|
@ -143,12 +143,12 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_renderReadonly: function() {
|
_renderReadonly: function () {
|
||||||
const value = this._formatValue(this.value);
|
const value = this._formatValue(this.value);
|
||||||
const escapedValue = _.escape((value || "").trim());
|
const escapedValue = _.escape((value || "").trim());
|
||||||
const mapvalue = escapedValue
|
const mapvalue = escapedValue
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map(function(line) {
|
.map(function (line) {
|
||||||
return "<span>" + line + "</span>";
|
return "<span>" + line + "</span>";
|
||||||
})
|
})
|
||||||
.join("<br/>");
|
.join("<br/>");
|
||||||
|
@ -172,7 +172,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @private
|
* @private
|
||||||
* @param {String} error
|
* @param {String} error
|
||||||
*/
|
*/
|
||||||
_showErrorMessage: function(error) {
|
_showErrorMessage: function (error) {
|
||||||
Dialog.alert(this, error, {
|
Dialog.alert(this, error, {
|
||||||
title: _t("Many2One Simple"),
|
title: _t("Many2One Simple"),
|
||||||
});
|
});
|
||||||
|
@ -186,7 +186,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @param {Object} context
|
* @param {Object} context
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
_getCreatePopupOptions: function(view, context) {
|
_getCreatePopupOptions: function (view, context) {
|
||||||
return {
|
return {
|
||||||
res_model: this.field.relation,
|
res_model: this.field.relation,
|
||||||
domain: this.record.getDomain({fieldName: this.name}),
|
domain: this.record.getDomain({fieldName: this.name}),
|
||||||
|
@ -201,7 +201,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
disable_multiple_selection: true,
|
disable_multiple_selection: true,
|
||||||
no_create: !this.can_create,
|
no_create: !this.can_create,
|
||||||
kanban_view_ref: this.attrs.kanban_view_ref,
|
kanban_view_ref: this.attrs.kanban_view_ref,
|
||||||
on_selected: records => this.reinitialize(records[0]),
|
on_selected: (records) => this.reinitialize(records[0]),
|
||||||
on_closed: () => this.activate(),
|
on_closed: () => this.activate(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -214,7 +214,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @param {any} context
|
* @param {any} context
|
||||||
* @returns {DialogClass}
|
* @returns {DialogClass}
|
||||||
*/
|
*/
|
||||||
_createPopup: function(view, context) {
|
_createPopup: function (view, context) {
|
||||||
const options = this._getCreatePopupOptions(view, context);
|
const options = this._getCreatePopupOptions(view, context);
|
||||||
return new dialogs.SelectCreateDialog(
|
return new dialogs.SelectCreateDialog(
|
||||||
this,
|
this,
|
||||||
|
@ -228,7 +228,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @private
|
* @private
|
||||||
* @returns {Array}
|
* @returns {Array}
|
||||||
*/
|
*/
|
||||||
_getDomain: function() {
|
_getDomain: function () {
|
||||||
return [[this.search.field, this.search.oper, this.$input.val()]];
|
return [[this.search.field, this.search.oper, this.$input.val()]];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @private
|
* @private
|
||||||
* @param {OdooEvent} event 'field_changed' event
|
* @param {OdooEvent} event 'field_changed' event
|
||||||
*/
|
*/
|
||||||
_onFieldChanged: function(event) {
|
_onFieldChanged: function (event) {
|
||||||
this.$input.val(event.data.changes[this.name].display_name);
|
this.$input.val(event.data.changes[this.name].display_name);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onExternalButtonClick: function() {
|
_onExternalButtonClick: function () {
|
||||||
if (!this.value) {
|
if (!this.value) {
|
||||||
this.activate();
|
this.activate();
|
||||||
return;
|
return;
|
||||||
|
@ -258,7 +258,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
method: "get_formview_id",
|
method: "get_formview_id",
|
||||||
args: [[this.value.res_id]],
|
args: [[this.value.res_id]],
|
||||||
context: context,
|
context: context,
|
||||||
}).then(view_id => {
|
}).then((view_id) => {
|
||||||
new dialogs.FormViewDialog(this, {
|
new dialogs.FormViewDialog(this, {
|
||||||
res_model: this.field.relation,
|
res_model: this.field.relation,
|
||||||
res_id: this.value.res_id,
|
res_id: this.value.res_id,
|
||||||
|
@ -290,7 +290,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
* @private
|
* @private
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
_onClick: function(event) {
|
_onClick: function (event) {
|
||||||
if (this.mode === "readonly" && !this.noOpen) {
|
if (this.mode === "readonly" && !this.noOpen) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
@ -299,7 +299,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
method: "get_formview_action",
|
method: "get_formview_action",
|
||||||
args: [[this.value.res_id]],
|
args: [[this.value.res_id]],
|
||||||
context: this.record.getContext(this.recordParams),
|
context: this.record.getContext(this.recordParams),
|
||||||
}).then(action => {
|
}).then((action) => {
|
||||||
this.trigger_up("do_action", {action: action});
|
this.trigger_up("do_action", {action: action});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onInputFocusout: function() {
|
_onInputFocusout: function () {
|
||||||
this._search();
|
this._search();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
*
|
*
|
||||||
* @param {OdooEvent} ev
|
* @param {OdooEvent} ev
|
||||||
*/
|
*/
|
||||||
_onInputKeyup: function(ev) {
|
_onInputKeyup: function (ev) {
|
||||||
if (ev.which === $.ui.keyCode.ENTER || ev.which === $.ui.keyCode.TAB) {
|
if (ev.which === $.ui.keyCode.ENTER || ev.which === $.ui.keyCode.TAB) {
|
||||||
this._search();
|
this._search();
|
||||||
} else {
|
} else {
|
||||||
|
@ -328,7 +328,7 @@ odoo.define("web_widget_many2one_simple.FieldMany2OneSimple", function(require)
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_updateExternalButton: function() {
|
_updateExternalButton: function () {
|
||||||
const has_external_button = !this.noOpen && !this.floating && this.isSet();
|
const has_external_button = !this.noOpen && !this.floating && this.isSet();
|
||||||
this.$external_button.toggle(has_external_button);
|
this.$external_button.toggle(has_external_button);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue