【问题标题】:Boolean field added to crm is not saved添加到 crm 的布尔字段未保存
【发布时间】:2020-02-24 19:40:09
【问题描述】:

我继承了 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】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-12-09
      • 2011-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多