如何显示/限制在odoo中列出的many2one记录的一部分?

时间:2022-07-14 20:23:56

view.xml

view.xml用

<field name="planning_id"/>
<field name="employee"/>
<field name="job_position" />

I want to display the job_position which is matched with the similar companies of planning_id(job_position.company_id=planning_id.company). I tried with domain but its not working.

我想显示与planning_id(job_position.company_id = planning_id.company)的类似公司匹配的job_position。我尝试使用域名,但它不起作用。

<field name="job_position" domain="'company_id'=planning_id.company_id"/>

1 个解决方案

#1


0  

First of all you need to create a related field to have the company in the same model, so, in the .py of your model:

首先,您需要创建一个相关字段,以使公司处于同一模型中,因此,在模型的.py中:

company_id = fields.Many2one(related='planning_id.company_id')

Then, in the view:

然后,在视图中:

<field name="job_position" domain="[('company_id', '=', company_id)]"/>

#1


0  

First of all you need to create a related field to have the company in the same model, so, in the .py of your model:

首先,您需要创建一个相关字段,以使公司处于同一模型中,因此,在模型的.py中:

company_id = fields.Many2one(related='planning_id.company_id')

Then, in the view:

然后,在视图中:

<field name="job_position" domain="[('company_id', '=', company_id)]"/>