Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
1601 Ansichten

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...

Avatar
Verwerfen
Beste Antwort

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

Avatar
Verwerfen
Autor

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.

Verknüpfte Beiträge Antworten Ansichten Aktivität
4
Mai 24
13701
1
Apr. 24
4098
0
Nov. 23
2777
1
Sept. 23
2889
2
Aug. 23
5549