Reputation: 3
I'm trying to create a simple many2one field in ODOO 8, in crm.lead view
This is my code:
campo_regione.py
from openerp import models, fields, osv
class nome_regione(models.Model):
_name = "nome_regione"
_inherit = "crm.lead"
name = fields.Char('Nome', size=20, required=True)
class campo_regione(models.Model):
_name = "campo_regione"
_inherit = "crm.lead"
_description = "Regione"
campo_regione_id = fields.Many2one('nome_regione', 'Nome Regione')
campo_regione.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model = "ir.ui.view" id = "campo_regione">
<field name ="name">crm.regione.inherit</field>
<field name = "model">crm.lead</field>
<field name = "inherit_id" ref="crm.crm_case_form_view_leads"></field>
<field name="arch" type="xml">
<xpath expr="//field[@name='country_id']" position="after">
<field name="campo_regione_id">Regione</field>
</xpath>
</field>
</record>
</data>
</openerp>
Now, after the module installs, odoo stops responding, even if I restart it, it goes on loop.
I'm able to login only by renaming or deleting the new module.
What am I wrong? thank you.
Upvotes: 0
Views: 5113
Reputation: 1
I'm trying to add custom field to crm.lead
class Lead(models.Model):
_inherits = 'crm.lead'
x_facturation = fields.Boolean("x_facturation", default=False)
<record model="ir.ui.view" id="devis_form_view">
<field name="name">lead.facturation</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Factures">
<group>
<field name="x_facturation"/>
</group>
</page>
</notebook>
</field>
</record>
But I got error while installing : Field x_facturation does not exist When I try with else model (ex : res.partner) it work fine
Upvotes: 0
Reputation: 133
When a model is changed (add, remove, rename, whatever..) you MUST restart service.
sudo service odoo restart
Upvotes: 1
Reputation: 14746
I have changed few things into your code just try following.
from openerp import models, fields
class nome_regione(models.Model):
_name = "nome_regione"
name = fields.Char('Nome', size=20, required=True)
class campo_regione(models.Model):
_inherit = "crm.lead"
_description = "Regione"
campo_regione_id = fields.Many2one('nome_regione', 'Nome Regione')
Upvotes: 1