콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
2126 화면
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

아바타
취소
관련 게시물 답글 화면 활동
1
4월 25
1387
Odoo App 해결 완료
1
11월 23
1955
0
5월 24
1684
0
9월 23
2639
0
9월 23
2253