Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1424 Представления

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
12913
1
апр. 24
3506
0
нояб. 23
2183
1
сент. 23
2350
2
авг. 23
4805