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

Hello friends,

I want to add a new item in drop menu in Odoo 13 like a "Cancel" for changing status from active to cancel. It is work like a "Delete" in drop menu without calling a form view.

So I need to execute one method in my model for just changing a status, but I can not!

Can you help me...

아바타
취소
베스트 답변

Hi,

For this you can add/write a server action, that executes python code and perform the necessary operation from it.

See sample:  

<record id="action_sale_confirm" model="ir.actions.server">
<field name="name">Confirm Quotationfield>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="binding_model_id" ref="sale.model_sale_order"/>
<field name="state">codefield>
<field name="code">
if records:
for rec in records:
rec.action_confirm()
field>
record>



Thanks

아바타
취소
작성자

Interesting, I had done the same thing before, but nothing was added to the menu, and it didn't work properly. But it worked with your code! I must have made a mistake somewhere.

<record id="action_cancel_form_link" model="ir.actions.server">
<field name="name">Cancel</field>
<field name="model_id" ref="termin.model_anlage"/>
<field name="binding_model_id" ref="termin.model_anlage"/>
<field name="state">code</field>
<field name="code">
if records:
for rec in records:
rec.cancel_link()
</field>
</record>

Thankful.

관련 게시물 답글 화면 활동
4
5월 24
12941
1
4월 24
3523
0
11월 23
2196
1
9월 23
2374
2
8월 23
4830