Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
4 Besvarelser
17709 Visninger

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 . 

Avatar
Kassér

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

Bedste svar

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

 });

Avatar
Kassér

Works well!!! viewType might not be necessary.

Bedste svar

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




Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
2
dec. 18
4319
2
maj 18
4354
0
mar. 21
2401
3
aug. 18
4288
2
jul. 24
2527