Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
17716 Lượt xem

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 . 

Ảnh đại diện
Huỷ bỏ

//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

Câu trả lời hay nhất

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

 });

Ảnh đại diện
Huỷ bỏ

Works well!!! viewType might not be necessary.

Câu trả lời hay nhất

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);   
}); 
 },.




Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 18
4324
2
thg 5 18
4358
0
thg 3 21
2404
3
thg 8 18
4298
2
thg 7 24
2528