我试图在crm.lead模型中进行一些更改,或者更确切地说是在机会的表单视图中。在原版中,我有2个按钮,如" Mark as Win"并且"标记为Lost"。我用其他4个按钮替换了这些按钮,例如" FFS - Win"," FFS - Lost"," Package - Win"和" Package - Lost& #34 ;.现在我想取代标签"赢得"和" Lost",显示在绿色或红色背景上,带有4个其他标签,等于按钮。
此刻我做了:
继承视图(XML)
<record id="cmp_crm_lead_form" model="ir.ui.view">
<field name="name">cmp.crm.lead.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<button name="action_set_won" position="replace">
<button name="ffs_set_won" string="FFS - Success" type="object" class="oe_highlight o_wow" attrs="{'invisible': ['|', ('active','=',False), ('probability', '=', 100)]}"/>
<button name="package_set_won" string="Package - success" type="object" class="oe_highlight o_wow" attrs="{'invisible': ['|', ('active','=',False), ('probability', '=', 100)]}"/>
</button>
<xpath expr="//form/header/button[2]" position="replace">
<button name="ffs_set_lost" string="FFS - Lost" type="action" class="oe_highlight" context="{'default_lead_id': active_id}" attrs="{'invisible': [('active', '=', False),('probability', '<', 100)]}"/>
<button name="package_set_lost" string="Package - Lost" type="action" class="oe_highlight" context="{'default_lead_id': active_id}" attrs="{'invisible': [('active', '=', False),('probability', '<', 100)]}"/>
</xpath>
<xpath expr="//form/sheet/div[2]" position="replace">
<div class="label label-danger pull-right" attrs="{'invisible': [('ffs_lost', '=', False)]}">FFS - Lost</div>
<div class="label label-danger pull-right" attrs="{'invisible': [('package_lost', '=', False)]}">Package - Lost</div>
</xpath>
<xpath expr="//form/sheet/div[3]" position="replace">
<div class="label label-success pull-right" attrs="{'invisible': [('ffs_success', '=', False)]}">FFS - Success</div>
<div class="label label-success pull-right" attrs="{'invisible': [('package_success', '=', False)]}">Package - Success</div>
</xpath>
</data>
</field>
</record>
模型(Python)的
class CrmLead(models.Model):
_inherit = 'crm.lead'
ffs_success = fields.Boolean(default=False, readonly=True)
ffs_lost = fields.Boolean(default=False, readonly=True)
package_success = fields.Boolean(default=False, readonly=True)
package_lost = fields.Boolean(default=False, readonly=True)
直到我添加了隐形属性才有效。现在我无法进入表单视图,因为我收到错误:
Uncaught Error: Unknown field ffs_lost in domain [["ffs_lost","=",false]]
该问题涉及模型中这四个字段中的每一个。 模块已更新,数据库中存在字段,我可以在开发人员模式下看到它们,但是odoo仍然无法识别它们。