在 odoo 9 中使用上下文

Use context in odoo 9

我有两种形式。首先 task_view.xml 显示所有用户的所有任务。在第二种形式 user_view.xml 打开一个用户后我添加 按钮

<button class="oe_inline oe_stat_button" style="float:right;" type="action" icon="fa-folder" name="%(task_view_form)d"
    context="{'??????}">
    <field string="total" name=total_qty" widget="statinfo" />
</button>

现在,当单击按钮时,我会获得所有用户的所有任务,单击按钮后如何使用上下文或任何其他解决方案,我只需要(过滤)该用户的任务。

我需要过滤器 project_task_user_id = id user from form where is placed button.

我认为要实现此目的,您需要将域添加到您的操作中:

<record id="task_view_form" ...>
    ...
    ...
    <field name="domain">[('project_task_user_id','=' , uid)] </field>
</record>

试试这个:

context="{'search_default_project_task_user_id ': active_id}"