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

I created a server action I want to show in the Action menu. Is there any way to tell Odoo, that this action should only appear in Action menu when in tree view?

อวตาร
ละทิ้ง

Display multiple form and Tree view: https://goo.gl/8ypbbg

คำตอบที่ดีที่สุด

Yes, you can bind action with the views. Here is an example:

<record id="ir_action_window_view2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="view_window_action_form"/>
<field name="act_window_id" ref="ir_action_window"/>
</record>

Here replace the act_window_id with your action and view_id with your custom model view.



อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I know this is out of context. But since this is top result when searching this case in google, I would like to add an answer if anyone want to do it in Odoo 16


    <record id="action_button" model="ir.actions.server">

        <field name="name">Action Button</field>

        <field name="type">ir.actions.server</field>

        <field name="model_id" ref="model_sale_order" />

        <field name="binding_model_id" ref="model_sale_order" />

        <field name="state">code</field>

        <field name="code">action = python_func()</field>

        <field name="binding_view_types">form</field>

    </record>

Add <field name="binding_view_types">form</field> in the record. You can set it to 'tree,form' if you want to have it in both or remove field binding_view_types if you want the button appear in all view of the same model

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I wrote a module 'web_menu_action_if' to accomplish this task in Odoo 9.0.
See my answer to:

https://www.odoo.com/forum/help-1/question/assign-action-menu-item-to-specific-tree-view-112007

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Marek Jan-Alexander,

You can add through Settings > Technical > Server Actions in that select your action and in form view top right corner there is a button Add in the "More" menu.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
มิ.ย. 25
5616
0
พ.ค. 21
2425
Error to render custom views from menu แก้ไขแล้ว
2
ก.ย. 20
3360
1
ม.ค. 20
4266
0
เม.ย. 25
725