未添加到crm的布尔字段

问题描述 投票:2回答:1

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

    <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})

经过几次测试,我仍然无法使用它,这是我第一次遇到此问题。

python crm odoo-11
1个回答
0
投票

我通过更改方法解决了

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

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

© www.soinside.com 2019 - 2024. All rights reserved.