Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1436 มุมมอง

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.

Related Posts ตอบกลับ มุมมอง กิจกรรม
4
พ.ค. 24
12978
1
เม.ย. 24
3530
0
พ.ย. 23
2204
Blank White Page After log in to Odoo13 แก้ไขแล้ว
1
ก.ย. 23
2381
2
ส.ค. 23
4844