diff options
| author | Martin Geubelle <mge@odoo.com> | 2017-05-29 17:07:28 +0200 |
|---|---|---|
| committer | Martin Geubelle <mge@odoo.com> | 2017-05-31 14:10:12 +0200 |
| commit | e3fdce964357a0bf38b3925637da2ed712e8e315 (patch) | |
| tree | 320342e59814170021409126ddc5a346378bbd30 /addons/web/static/src/js | |
| parent | 07e1bf78500625471acf0b9d75af9e8793fa0160 (diff) | |
[FIX] web: add parent in context after 'Save & New'
When clicking on 'Save & New' in the form view dialog, a new default record
is created. The parent was not correctly set in this record, which causes an
error if `parent` was used in context.
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/form/form_controller.js | 5 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/view_dialogs.js | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 1833d263082..8ae66848b75 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -50,9 +50,11 @@ var FormController = BasicController.extend({ * This method switches the form view in edit mode, with a new record. * * @todo make record creation a basic controller feature + * @param {string} [parentID] if given, the parentID will be used as parent + * for the new record. * @returns {Deferred} */ - createRecord: function () { + createRecord: function (parentID) { var self = this; var record = this.model.get(this.handle, {raw: true}); return this.model.load({ @@ -60,6 +62,7 @@ var FormController = BasicController.extend({ fields: record.fields, fieldsInfo: record.fieldsInfo, modelName: this.modelName, + parentID: parentID, res_ids: record.res_ids, type: 'record', viewType: 'form', diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index 956886910ce..b84d60d5b7c 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -133,7 +133,7 @@ var FormViewDialog = ViewDialog.extend({ text: _t("Save & New"), classes: "btn-primary", click: function () { - this._save().then(self.form_view.createRecord.bind(self.form_view)); + this._save().then(self.form_view.createRecord.bind(self.form_view, self.parentID)); }, }); } |
