Reputation: 266
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
:
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>
Can anyone please say me where did I go wrong?
Upvotes: 1
Views: 460
Reputation: 656
update your xml file,
<?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>
you py file should be,
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.
Upvotes: 1