跳至內容
選單
此問題已被標幟
2 回覆
3250 瀏覽次數

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



頭像
捨棄
最佳答案

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.

頭像
捨棄
最佳答案

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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
10月 25
234
1
10月 25
297
0
10月 25
2
0
10月 25
2
0
10月 25
2