summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-07-20 11:48:49 +0200
committerChristophe Simonis <chs@odoo.com>2017-07-20 11:48:49 +0200
commitfa3e89064a503c95ab2b283e5d5b39ca182f8f47 (patch)
treed638f0cb99fc973169d670ff0bafd1b9474b4771 /addons/web/static/src/js/fields
parent0ae679e433ee4c5ca32ae1302d87d7fb33e0c78d (diff)
parent104dfe3c07d36a6487f045f31d0999cc429cb5bb (diff)
[MERGE] forward port branch saas-16 up to 104dfe3c07d
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/abstract_field.js9
-rw-r--r--addons/web/static/src/js/fields/field_utils.js14
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js32
3 files changed, 37 insertions, 18 deletions
diff --git a/addons/web/static/src/js/fields/abstract_field.js b/addons/web/static/src/js/fields/abstract_field.js
index 4ae4eec9c05..fa2f37a123f 100644
--- a/addons/web/static/src/js/fields/abstract_field.js
+++ b/addons/web/static/src/js/fields/abstract_field.js
@@ -65,9 +65,12 @@ var AbstractField = Widget.extend({
* @constructor
* @param {Widget} parent
* @param {string} name The field name defined in the model
- * @param {Object} record A record object (result of the get method of a basic model)
+ * @param {Object} record A record object (result of the get method of
+ * a basic model)
* @param {Object} [options]
* @param {string} [options.mode=readonly] should be 'readonly' or 'edit'
+ * @param {string} [options.standalone=false] this flag indicates that the
+ * field does not have a controller to delegate to
*/
init: function (parent, name, record, options) {
this._super(parent);
@@ -157,6 +160,10 @@ var AbstractField = Widget.extend({
// calls to the format (resp. parse) function.
this.formatOptions = {};
this.parseOptions = {};
+
+ // standalone is a flag indicating that the field does not have a
+ // controller to delegate actions to
+ this.standalone = options.standalone;
},
/**
* When a field widget is appended to the DOM, its start method is called,
diff --git a/addons/web/static/src/js/fields/field_utils.js b/addons/web/static/src/js/fields/field_utils.js
index ac4c06454ea..0a44a52e315 100644
--- a/addons/web/static/src/js/fields/field_utils.js
+++ b/addons/web/static/src/js/fields/field_utils.js
@@ -29,12 +29,20 @@ var _t = core._t;
/**
* @todo Really? it returns a jqueryElement... We should try to move this to a
* module with dom helpers functions, such as web.dom, maybe. And replace this
- * with a function that returns a string
+ * with a function that returns a string so we can get rid of the forceString.
*
* @param {boolean} value
- * @returns {jQueryElement}
+ * @param {Object} [field]
+ * a description of the field (note: this parameter is ignored)
+ * @param {Object} [options] additional options
+ * @param {boolean} [options.forceString=false] if true, returns a string
+* representation of the boolean rather than a jQueryElement
+ * @returns {jQueryElement | string}
*/
-function formatBoolean(value) {
+function formatBoolean(value, field, options) {
+ if (options && options.forceString) {
+ return value ? _t('True') : _t('False');
+ }
var $input = $('<input/>', {
type: 'checkbox',
}).prop({
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 14512c02912..7522bb3bc37 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -223,21 +223,25 @@ var FieldMany2One = AbstractField.extend({
_quickCreate: function (name) {
var self = this;
var slowCreate = this._searchCreatePopup.bind(this, "form", false, this._createContext(name));
+ var action = function () {
+ return self._rpc({
+ model: self.field.relation,
+ method: 'name_create',
+ args: [name],
+ context: self.record.getContext(self.recordParams),
+ }).then(function (result) {
+ if (self.mode === "edit") {
+ self.reinitialize({id: result[0], display_name: result[1]});
+ }
+ }, slowCreate);
+ };
+
if (this.nodeOptions.quick_create) {
- this.trigger_up('mutexify', {
- action: function () {
- return self._rpc({
- model: self.field.relation,
- method: 'name_create',
- args: [name],
- context: self.record.getContext(self.recordParams),
- }).then(function (result) {
- if (self.mode === "edit") {
- self.reinitialize({id: result[0], display_name: result[1]});
- }
- }, slowCreate);
- },
- });
+ if (this.standalone) {
+ action();
+ } else {
+ this.trigger_up('mutexify', {action: action});
+ }
} else {
slowCreate();
}