콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
4993 화면

Hello,

Can i please avoid calling the write method of the model when i click on a button ?

Thanks,

아바타
취소

On which method you want to do this, can you explain your requirement?

작성자

Hello, When i click on any button in Openerp , it call before the write method of the model to save the record. I want only call the button function.

베스트 답변

This is an old question, and the exact context is not given, still here's how I managed to achieve that in 12.0:

First, the button should look like a button but not be an actual button tag so Odoo won't attach a click listener to it:

<a class="btn btn-primary myapp-dothis" tabindex="0" role="button">Do this!</a>

tabindex is necessary for Bootstrap CSS to correctly apply, and role is to avoid XML validation warnings.

Then use your favorite way of attaching your event to the button. Could be an onclick attribute, or if your button is in a view used in a JS widget, use the events property:

const MyEditor = dialogs.FormViewDialog.extend({
    events: {
        'click .myapp-dothis': 'onDoItClick'
    },
    onDoItClick(ev) {
        ...
    },
아바타
취소