本文介绍了继承后,CRM-Lead无法隐藏字段或将字段添加到Openerp中的“自定义"模块中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个新的自定义模块并继承了CRM-LEAD.我正在尝试添加新字段并隐藏现有字段.我做不到.任何人都可以告诉我我该怎么做.我的代码是
I have created a new custom module and inherited CRM-LEAD. I'm trying add new fields and hide existing fields.I couldn't do it.Can anyone please tell me how can I do it.My code is
__init__.py
:
__init__.py
:
import lead
__openerp__.py
:
__openerp__.py
:
{
'name': 'Lead Information',
'version': '0.1',
'category': 'Tools',
'description': """This module is Lead information.""",
'author': 'Nitesh',
'website': '',
'depends': ['crm'],
'init_xml': ['lead_view.xml'],
'update_xml': [],
'demo_xml': [],
'installable': True,
'active': True,
'application': True
}
lead.py
:
lead.py
:
from osv import osv
from osv import fields
class crm_lead(osv.osv):
_name = 'bala.lead'
_inherit = 'crm.lead'
_description = "adding fields to crm.lead"
_coloumns = {
'nitesh_lead': fields.char('Nitesh Lead',size=64)
}
lead_view.xml
:
lead_view.xml
:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="email_from" postion="replace"/>
<field name="partner_name" postion="after">
<field name="nitesh_lead"/>
</field>
</field>
</record>
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Lead</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.lead</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_leads_extended"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" action="new_lead"/>
</data>
</openerp>
谁能告诉我我哪里出问题了?
Can anyone please say me where did I go wrong?
推荐答案
更新您的xml文件,
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">bala.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="email_from" postion="replace"/>
<xpath expr="//label[@for='contact_name']" position="before">
<field name="nitesh_lead"/>
</xpath>
<field name="function" position="replace"/>
<field name="partner_name" position="replace"/>
<field name="priority" position="replace"/>
<field name="partner_id" position="replace"/>
</field>
</record>
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Lead</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_case_form_view_leads_extended"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" action="new_lead"/>
</data>
</openerp>
您的py文件应该是
from openerp.osv import fields, osv
class crm_lead(osv.osv):
_name = 'bala.lead'
_inherit = 'crm.lead'
_description = "adding fields to crm.lead"
_columns = {
'nitesh_lead': fields.char('Nitesh Lead',size=64)
}
crm_lead()
希望这将为您提供所需的输出.并且不要忘记在更改后更新您的模块.
Hope this will give you desired output. and don't forget to update your module after this changes.
这篇关于继承后,CRM-Lead无法隐藏字段或将字段添加到Openerp中的“自定义"模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!