Skip to Content
Menu
This question has been flagged
2 Replies
1768 Views

Odoo 16

I defined a List view which every row has a button, the type is 'action', and set the record id as the active_id in context.

Then I defined the action as ir.actions.act_window use xml, I want set the res_id with the active_id in context, how to define it in xml?

below is the list view

Invoice List fppool.history_claimer

and the action

 Invoice Detail fppool.invoice form get the active id from context



Avatar
Discard
Best Answer

This setup ensures that the action will reference the currently selected record’s ID when triggered from the list view. The default_res_model is specified as fppool.history_claimer, indicating the database model associated with the action. To tailor this action to your needs, you may need to adjust the res_model to point to the appropriate model if fppool.history_claimer isn’t the one you intend to use.

Avatar
Discard
Best Answer

Hi,


To define an action in Odoo 16 that sets the res_id using the active_id from the context, use the following XML definition:

<record id="action_invoice_detail" model="ir.actions.act_window">

    <field name="name">Invoice Detail</field>

    <field name="res_model">fppool.invoice</field>

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

    <field name="target">current</field>

    <field name="context">{

        'default_res_id': active_id,

        'default_res_model': 'fppool.history_claimer'

    }</field>

</record>


The default_res_id is set to active_id in this XML, which means that when the action is initiated from the list view, the context's active_id will be used. The default_res_model is set to fppool.history_claimer, which is the model used in your list view. Adjust the res_model and other fields to meet your specific requirements.


Hope it helps

Avatar
Discard
Related Posts Replies Views Activity
4
May 25
1048
1
May 25
254
1
May 25
278
0
May 25
258
0
May 25
189