A.kenzo
A.kenzo

Reputation: 3

creating new module that inherits from custom modules

I was trying to add some fields to my new module which contains 5 classes 2 of them inherit from custom modules ( product.template/res.partner) those classes are related with relational fields, I have tried so many ways to make it work and correct many errors but now stuck with this one

ParseError: "Invalid view definition

details of error :
the field `date_intv` doesn't existe 
Contexte de l'erreur :
Vue `intervention.form`
[view_id: 2592, xml_id: n/a, model: c.intervention, parent_id: n/a]
None" while parsing file:///C:/Program Files (x86)/Odoo 9.0-20151125/server/openerp/addons/Gestion_CVT/fileds_intervention.xml:5, near
<record model="ir.ui.view" id="intervention_form">
            <field name="name">intervention.form</field>
            <field name="model">c.intervention</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="formulaire">
                    <field name="type_int"/>
                    <field name="properties4"/>
                    <field name="date_intv"/>
                </form>
            </field>
        </record>

manchening also that I have already used the osv.osv but didn't work with the equipement class because I was adding class by class so now I changed them all to models.Model so here is my .py file

# -*- coding: utf-8 -*-
from openerp import models, fields, api
class centre(models.Model):
   _name = 'res.partner'
   _inherit = ['res.partner']
   rs_ctr = fields.Char(string='Réseau')
   nb_ligne = fields.Integer(string='Lignes')
   n_agr = fields.Integer(string='N° d\'agrèment')
   chef = fields.Char(string='Chef centre')
   prp = fields.Char(string='Propriétaire')
   equipement_id = fields.Many2one('product.template','Equipements',select=True)
   properties1 = fields.One2many('product.template','centre_id','Centres')
centre() 
class equipement(models.Model):
   _name = 'product.template'
   _inherit = ['product.template']
   num_ligne = fields.Integer(string='N° ligne')
   model_mat = fields.Char(string='Model de materiel')
   centre_id = fields.Many2one('res.partner','Centres',select=True) 
   marque_id = fields.Many2one('c.marque','Marques',select=True)
   properties2 = fields.One2many('c.eptinv','equipement_id','Equipements')
equipement()    
class marque(models.Model):
   _name = 'c.marque'
   _description = 'Marques' 
   name = fields.Char(string='Nom')
   nom_four = fields.Char(string='Fournisseur')  
   properties3 = fields.One2many('product.template','marque_id','Marques')
marque()
class intervention(models.Model):
   _name = 'c.intervention'
   _inherits = {'c.eptinv': 'date_intv'}
   STATE_SELECTION =  [('c','Corrective'),('p','Préventive')]
   _description = 'Interventions'
   name = fields.Char(string='Nom')
   type_int = fields.Selection(STATE_SELECTION,'Type d\'intervention')
   properties4 = fields.One2many('c.eptinv','intervention_id','Interventions')
intervention()      
class eptinv(models.Model):
   _name = 'c.eptinv'
   _description = 'EptInv' 
   date_intv = fields.Date(string='Date d\'intervention')
   equipement_id = fields.Many2one('product.template','Equipements')  
   intervention_id = fields.Many2one('c.intervention','Interventions')
eptinv()

Upvotes: 0

Views: 727

Answers (1)

Manali Kalariya
Manali Kalariya

Reputation: 71

The field date_intv doesn't exist this error occurs because of, you inherit class eptinv into the class intervention .. which is not the Right Way...Take 1 Example..

Suppose If you want to inherit class A into the class B then Class A Must Be define before the Class B then and then you can use the Mechanism of Class A into the Class B. Now you have to change the Sequence of your class Defination which is shown in below Image.

enter image description here

code --->

class eptinv(models.Model):
    _name = 'c.eptinv'
    _description = 'EptInv' 
    date_intv = fields.Date(string='Date d\'intervention')
    equipement_id = fields.Many2one('product.template','Equipements')  
    intervention_id = fields.Many2one('c.intervention','Interventions')
class intervention(models.Model):
    _name = 'c.intervention'
    _inherits = {'c.eptinv': 'date_intv'}
    STATE_SELECTION =  [('c','Corrective'),('p','Préventive')]
    _description = 'Interventions'
    name = fields.Char(string='Nom')
    type_int = fields.Selection(STATE_SELECTION,'Type d\'intervention')
    properties4 = fields.One2many('c.eptinv','intervention_id','Interventions')

I hope this Answer is helpful for You.

Upvotes: 2

Related Questions