From 1bbb7d62410d0fef9304c32b62a8aef032f97af8 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Tue, 3 Oct 2017 16:52:08 +0200 Subject: [FIX] web: clear input on clicking 'Create and Edit' from many2one fields We clear the input field when clicking 'Create and Edit' to ensure that the field is empty if the user chooses to cancel the record creation. If a record is indeed created, then the field value will still be updated. --- addons/web/static/src/js/fields/relational_fields.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/fields') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 4cbbf498e82..194165b2206 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -371,9 +371,14 @@ var FieldMany2One = AbstractField.extend({ } // create and edit ... if (create_enabled && !self.nodeOptions.no_create_edit) { + var createAndEditAction = function () { + // Clear the value in case the user clicks on discard + self.$('input').val(''); + return self._searchCreatePopup("form", false, self._createContext(search_val)); + }; values.push({ label: _t("Create and Edit..."), - action: self._searchCreatePopup.bind(self, "form", false, self._createContext(search_val)), + action: createAndEditAction, classname: 'o_m2o_dropdown_option', }); } else if (values.length === 0) { -- cgit v1.2.3