如何在 Odoo 8 中从另一个函数字段域 one2many 字段



我想根据字段中location_id get_loc_user过滤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是根据字段按字段location_id过滤get_loc_user但我不知道该怎么做

如果要为get_loc_user设置域,则可以像这样tree & form view访问它parent.get_loc_user

 <field name="location_id" domain="parent.get_loc_user and [('your_field_domain', '=', parent.get_loc_user)] or []"/>

我不知道你到底需要什么,但我想你明白了

最新更新