继承CRM-Lead后无法隐藏或添加字段到Openerp中的自定义模块

时间:2014-02-03 12:50:41

标签: python openerp openerp-7

我创建了一个新的自定义模块并继承了CRM-LEAD。我正在尝试添加新字段并隐藏现有字段。我无法做到。任何人都可以告诉我我该怎么做。 我的代码是

__init__.py

import lead

__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

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

<?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>

有谁能说我哪里出错了?

1 个答案:

答案 0 :(得分:1)

更新你的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()

希望这会给你想要的输出。并且不要忘记在此更改后更新您的模块。 Check this