diff options
| author | Aaron Bohy <aab@odoo.com> | 2020-03-06 12:51:34 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-03-09 10:31:01 +0000 |
| commit | f692a396778392212c624cf05c57f262ca671f21 (patch) | |
| tree | 83b5febf7998aff6cadabdd584f974f9de42791a /addons/web/static/src/js/fields/relational_fields.js | |
| parent | d07066bd116e85070b40244beb83b3e98316977a (diff) | |
[FIX] web: FieldMany2ManyTags: failing quick create record
The FieldMany2One allows to quick create record (name_create).
However, sometimes, required fields on the co-model make the
name_create crash. In this case, the FieldMany2one opens a form
view in a dialog to let the user specify those fields, and create
a new record with the 'create' method. This was working fine.
The FieldMany2ManyTags embeds a FieldMany2One to let the user
search for and select or (quick) create tags. In this case, failing
quick creation didn't fallback on the dialog form view, but
displayed a server error instead. This commit fixes this issue.
Bug introduced by 50bf8309f88fb6c8d8e27b14d40450e92e5a4e4e
Task 2192754
closes odoo/odoo#47183
X-original-commit: 63ab065f3298c13bb19ae1245d7fd2652581b254
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 8aa894307d1..705a0c872fa 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -2332,14 +2332,16 @@ var FieldMany2ManyTags = AbstractField.extend({ /** * @private * @param {any} data + * @returns {Promise} */ _addTag: function (data) { if (!_.contains(this.value.res_ids, data.id)) { - this._setValue({ + return this._setValue({ operation: 'ADD_M2M', ids: data }); } + return Promise.resolve(); }, /** * @private @@ -2459,7 +2461,9 @@ var FieldMany2ManyTags = AbstractField.extend({ ev.stopPropagation(); var newValue = ev.data.changes[this.name]; if (newValue) { - this._addTag(newValue); + this._addTag(newValue) + .then(ev.data.onSuccess || function () {}) + .guardedCatch(ev.data.onFailure || function () {}); this.many2one.reinitialize(false); } }, |
