Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
1425 Vizualizări

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

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
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.

Related Posts Răspunsuri Vizualizări Activitate
4
mai 24
12914
1
apr. 24
3506
0
nov. 23
2183
1
sept. 23
2351
2
aug. 23
4806