summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorAurélien Warnon <awa@odoo.com>2018-08-31 15:06:38 +0200
committerAurélien Warnon <awa@odoo.com>2018-09-25 18:39:32 +0200
commitd3fbd102694bedaedac7016022a7f08d95a10553 (patch)
treee228be08de8360779c80745208a0410d65c919ed /addons/web/static/src/js/fields
parent57ffbe89ef62760c9a2a4224d4389b320fb7dfab (diff)
[IMP] framework js: improve X2Many 'CREATE' operation to handle multiple records
Purpose ======= The 'CREATE' operation lacked the possibility to handle multiple records. The 'context' parameter is now an array of dict that contains the context for each new record. This is usefull when you want to create multiple records into a list in a single call. Please note that the 'default_get' is still called once for each record in an async way.
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 3f64c0249cb..6c6919cce4d 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -1453,6 +1453,15 @@ var FieldOne2Many = FieldX2Many.extend({
* @param {OdooEvent|MouseEvent} ev this event comes either from the 'Add
* record' link in the list editable renderer, or from the 'Create' button
* in the kanban view
+ * @param {Array} ev.data.context additional context for the added records,
+ * if several contexts are provided, multiple records will be added
+ * (form dialog will only use the context at index 0 if provided)
+ * @param {boolean} ev.data.forceEditable this is used to bypass the dialog opening
+ * in case you want to add record(s) to a list
+ * @param {function} ev.data.onSuccess called when the records are correctly created
+ * (not supported by form dialog)
+ * @param {boolean} ev.data.allowWarning defines if the records can be added
+ * to the list even if warnings are triggered (e.g: stock warning for product availability)
*/
_onAddRecord: function (ev) {
var self = this;
@@ -1485,7 +1494,7 @@ var FieldOne2Many = FieldX2Many.extend({
}
} else {
this._openFormDialog({
- context: data.context,
+ context: data.context && data.context[0],
on_saved: function (record) {
self._setValue({ operation: 'ADD', id: record.id });
},