我想根据 get_loc_user 字段中的 location_id 过滤 get_parts_locations_rel_ids...但我无法获取它。
我使用了 odoo 8 和旧的 api
# this is my python code
_columns = {
'get_loc_user': fields.function(check_location_user, string="loc_user", type="char"),
'get_parts_locations_rel_ids': fields.one2many('parts.locations_rel','product_id','Locations'),
}
# field 'get_loc_user' is a function that will return a list result such [1,2,3]
#-------------------------------
# in xml
<record id="product_normal_form_view_inherit" model="ir.ui.view">
<field name="name">product.product.form</field>
<field name="model">product.product</field>
<field name="mode">primary</field>
<field eval="7" name="priority"/>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='categ_id']" position="after">
<field name="get_loc_user" />
</xpath>
<xpath expr="//field[@name='asset_ids']" position="after">
<field name="get_parts_locations_rel_ids">
<tree string="Locations" >
<field name="loc_case"/>
<field name="loc_row" />
<field name="loc_rack" />
<field name="location_id" />
</tree >
</field>
</xpath>
</field>
</record>
我希望 one2many 字段 get_parts_locations_rel_ids 中的结果是根据 get_loc_user 字段按字段 location_id 进行过滤,但我不知道该怎么做
如果您想为get_loc_user
设置域,您可以在树和表单 View
中访问它,如下所示parent.get_loc_user
<field name="location_id" domain="parent.get_loc_user and [('your_field_domain', '=', parent.get_loc_user)] or []"/>
我不知道你到底需要什么,但我想你明白了
我是一名优秀的程序员,十分优秀!