[英]how to apply domain on One2many field in xml view in odoo 10?
I am having records need to filter based on condition in xml view. 我有记录需要根据xml视图中的条件进行过滤。
Model A (reg.customers): 模型A(常规客户):
field_a_id = fields.One2many('reg.customers', 'customer_id')
Model B (customers): B型(客户):
customer_id = fields.Many2one('customers')
status = fields.Selection([('option_a', 'Option A'), ('option_b', 'Option B')])
<separator string="Customers" colspan="4" />
<group colspan="4" col="4">
<field name="field_a_id" nolabel="1" >
<tree delete="false" create="false">
<field name="name" />
<field name="father_name" />
<field name="contact" />
<field name="cnic" />
</tree>
</field>
</group>
If I understood right I think that you would like to show inside a form view related to a certain customer_id a tree view with the values of field_a_id related to that customer_id. 如果我理解正确,我认为您想在与某个customer_id相关的表单视图中显示一个树视图,其中包含与该customer_id相关的field_a_id的值。
If so, you may try to apply a domain filter to the field_a_id field, like: 如果是这样,您可以尝试将域过滤器应用于field_a_id字段,例如:
<field name="field_a_id" domain="[('customer_id', '=', id)]" nolabel="1" options="{'no_create':True, 'no_delete': True}">
<tree>
<field name="name" />
<field name="father_name" />
<field name="contact" />
<field name="cnic" />
</tree>
</field>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.