Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

I want to replace the functionality of the js file. As we have widget many2many in relation_field.js in that there is one function search, that contains code for creating and edit option. I want to change this functionality as per my needs. Following is the main code that I want to change

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: createAndEditAction,
classname: 'o_m2o_dropdown_option',
});
} else if (values.length === 0) {
values.push({
label: _t("No results to show..."),
});
}

following is my code. Bold part i want to achive


odoo.define('survey_inherit.create_record',function(require){
"use strict";
console.log("In js file");


var relationalField = require('web.relational_fields');

var FieldMany2One = relationalField.FieldMany2One.include({
_search: function (search_val) {
var create_enabled = self.can_create && !self.nodeOptions.no_create;
if (create_enabled && !self.nodeOptions.no_create_edit) {
var createAndEditAction = function () {
// Clear the value in case the user clicks on discard
self.$('input').val('');
alert(‘Test’);
//return self._searchCreatePopup("form", false, self._createContext(search_val));
};
this.values.push({
label: _t("Create and Edit..."),
action: createAndEditAction,
classname: 'o_m2o_dropdown_option',
});
} else if (this.values.length === 0) {
this.values.push({
label: _t("No results to show..."),
});
}
}
});
});

Can anyplease help or any other suggestion appriciated.

Thanks in advance.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 23
1795
2
thg 2 23
2608
0
thg 12 19
4205
2
thg 6 24
3285
3
thg 11 23
17305