2016-01-20 56 views
0

我試圖添加一些字段到我的新模塊,其中包含5個類2他們繼承自定義模塊(product.template/res.partner)這些類與相關字段相關,我已經試了很多方法,使工作和糾正許多錯誤,但現在仍堅持這一一個創建新的模塊,繼承自定製模塊

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還我已經使用了osv.osv但與設備公司類,因爲我沒有工作現在我將它們全部更改爲models.Model所以這裏是我的.py文件

# -*- 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() 

回答

1

date_intv不存在,因爲發生這個錯誤,你繼承類eptinv到類干預..這是不正確的做法......以1例..

假設如果你想繼承A級進入B級,那麼A級必須在B級之前定義,然後你可以使用A級機制進入B級。 現在你必須改變你的類定義的序列,它顯示在下面圖片。

enter image description here

代碼 --->

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') 

我希望這個答案對你有幫助。

+0

謝謝你的回覆真正有用的筆記 –