This question has been flagged
4 Replies
15739 Views

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
Discard

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

Best Answer

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
Discard

Works well!!! viewType might not be necessary.

Best Answer

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
Discard