添加到 crm 的布尔字段未保存

Boolean field added to crm is not saved

我继承了crm.lead模型并添加了一个计算布尔字段,不幸的是它没有保存在数据库中,因此我无法对视图进行操作。如果该字段为真,则向看板添加一个字符串。

    <record id="crm_case_kanban_view_leads_inherit" model="ir.ui.view">
        <field name="name">crm.lead.kanban (in agreements_crm)</field>
        <field name="model">crm.lead</field>
        <field name="inherit_id" ref="crm.crm_case_kanban_view_leads"/>
        <field name="arch" type="xml">
            <field name="activity_ids" position="after">
                <field name="need_agreements"/>
            </field>

            <xpath expr="//div[@class='oe_kanban_content']" position="after">
                <!-- <t t-if="record.need_agreements.value == false">
                    <p>No Needs Agreement Creation</p>
                </t> -->
                <t t-if="record.need_agreements.value">
                    <p>Needs Agreement Creation</p>
                </t>                
            </xpath>
        </field>
    </record>

我也尝试添加 store = True 但结果是计算方法上的单例错误

    def _compute_need_agreements(self):
        type_id = ''

        for tag in self.tag_ids:
            if self.env['agreements.type'].search([('agreements_label_ids.name', '=', tag.name)]):
                type_id = self.env['agreements.type'].search([('agreements_label_ids.name', '=', tag.name)])
                break


        if self.stage_id.name == "Won" and type_id and self.agreements_count < 1:
            # for record in self:
                # record.need_agreements = True
            record.write({'need_agreements':True})

        else:
            # for record in self:
            record.write({'need_agreements':False})

试了几次还是不能用,第一次遇到这个问题

我通过改变方法解决了这个问题

<p attrs="{'invisible':[('need_agreements', '=', False)]}" style="color:Red;">Needs Agreement Creation</p>

使用 attrs invisible 我能够解决我的问题,我不明白为什么 Qweb 条件没有帮助我