DEV Community 👩‍💻👨‍💻

Mossie Chao
Mossie Chao

Posted on

Server Action in Odoo 11

Server Action

View -> Python -> act_window
ตัวอย่าง

<record id="action_server_demo" model="ir.action">
    <field name="name">Test Action Server</field>
    <field name="type">ir.actions.server</field>
    <field name="state">code</field>
    <field name="model_id" ref="my_module.my_model" />
    <field name="binding_model_id" ref="my_module.my_model" />
    <field name="code">records.my_function()</field>
</record>
Enter fullscreen mode Exit fullscreen mode
def my_function(self):
    show_ids = [1,2,3,4,5,6]
    return {
        'type': 'ir.actions.act_window',
        'res_model': 'destination_model',
        'views': [[False, 'tree'], [False, 'form']],
        'domain': [['id', 'in', show_ids ]],
        'target': 'new',
    }
Enter fullscreen mode Exit fullscreen mode

Oldest comments (1)

Collapse
 
songwutk profile image
songwutk

ช่วยอธิบายเพิ่มเติมด้วยครับ

  • แต่ละบรรทัดมันคืออะไร
  • ทำแล้วหน้าตา Output มันจะเป็นยังไง

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.