Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2076 มุมมอง
odoo.define('ecare_medical_history.EditPatientProfile', function (require) {
"use strict";
self = this;
var rpc = require('web.rpc');
var AbstractAction = require('web.AbstractAction');
var servicesMixin = require('web.ServicesMixin');
var core = require('web.core');

$(document).on('click', '.editPatientProfile', async function() {

try {
var result = await rpc.query({
model: 'ec.patient.timeline',
method: 'action_open_patient_time_view',
args: [],
});

alert("test");
console.log(result);

// Check if the result is valid before calling do_action
if (result) {
return await this.do_action(result);
} else {
console.error('RPC call did not return a valid result.');
}
} catch (error) {
console.error('Error while making the RPC call:', error);
}
});




});


อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

Can you try to write your function like this:


odoo.define('ecare_medical_history.EditPatientProfile', function (require) {

"use strict";

        self = this;

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

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

        var servicesMixin = require('web.ServicesMixin');

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


        $(document).on('click', '.editPatientProfile', async function() {


            try {

                var result = await rpc.query({

                    model: 'ec.patient.timeline',

                    method: 'action_open_patient_time_view',

                    args: [],

                });


                alert("test");

                console.log(result);


                // Check if the result is valid before calling do_action

                if (result) {

                    return await self.do_action(result);

                } else {

                    console.error('RPC call did not return a valid result.');

                }

            } catch (error) {

                console.error('Error while making the RPC call:', error);

            }

        });

}); 

Use self instead of this.


Hope it helps

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
เม.ย. 25
1351
Odoo App แก้ไขแล้ว
1
พ.ย. 23
1919
0
พ.ค. 24
1655
0
ก.ย. 23
2602
0
ก.ย. 23
2218