跳至內容
選單
此問題已被標幟
4 回覆
17570 瀏覽次數

odoo.define('my_module', function (require)

{

"use strict";

function myFunction() {

    var x = 'hello'

    console.log(x)

  });

i have my javascript in static/src/js folder

i want to get this "hello" in my form view char field . 

頭像
捨棄

//I haven't known your event, so i used "field changed" event.

odoo.define('my_module', function (require)

{

"use strict";

var FormRenderer = require('web.FormRenderer');

FormRenderer.include({

confirmChange: function (state, id, fields, e) {

if(this.state.model == 'your_model')

{

//your code here

}

return this._super.apply(this, arguments);

},

});

});

//https://pastebin.com/Ch0kJ0Kq

var data = e.data.changes.name;

//I haven't test this code

最佳答案

you can use field change trigger

var values ={}                    

values ['your_field'] = 'his value';                    

this.trigger_up('field_changed',

 {                        

dataPointID: this.dataPointID, 

 changes: values,                        

viewType: this.viewType

 });

頭像
捨棄

Works well!!! viewType might not be necessary.

最佳答案

You can send values to python function and recieve return value like below

your_function: function(param1,param2) { 
var variable = new instance.web.Model('model').call('test',[param1,param2]).then(function(result){  
$(".class").text(result);   
}); 
 },.




頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
12月 18
4168
2
5月 18
4205
0
3月 21
2237
3
8月 18
4148
2
7月 24
2322