【发布时间】:2020-12-19 13:17:17
【问题描述】:
我想要做的是,我需要根据他们的密码过滤客户/合作伙伴。
因此,我创建了一个名为 is_pincode_present 的布尔字段和一个 compute 函数来计算其值。但它不返回过滤值;相反,它会返回所有客户。
我尝试使用 Xpath 隐藏这些值,但它不起作用。 Xpath 只隐藏字段,而不是进行过滤。
这是我的py.file:
class ResPartner(models.Model):
_inherit = "res.partner"
is_pincode_present = fields.Boolean('zip', compute="_is_pincodes_present")
def _is_pincodes_present(self):
pin_lists = self.env['franchise.pincode.master'].search([('name','=',self.env.user.partner_id.id)],limit=1).mapped("franchise_pincode_line.pincode.pincode") //list of pincodes
for i in self:
if i.zip in pin_lists:
i.is_pincode_present = True
这是我的 XML 文件,继承自 res.partner 树视图的 xml 文件:
<record id="action_view_partner_form_one" model="ir.actions.act_window">
<field name="name">Customers/Suppliers</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree,form,pivot</field>
<field name="view_id" ref="view_partner_tree"/>
**<field name="domain">[('is_pincode_present','=',1)]</field>** // domain
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
</p>
</field>
</record>
快速修复帮助我完成任务。 is_pincode_present 正在数据库中设置正确的值,当应用其他过滤器时它工作正常。只有布尔过滤器不起作用。
【问题讨论】: