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()
4

1 回答 1

2

该字段date_intv不存在此错误发生的原因是,您将类 eptinv 继承到类干预中..这不是正确的方式...以 1 个示例..

假设 如果你想将A类继承到B类中,那么A类必须在B类之前定义,然后你可以使用A类的机制进入B类。 现在你必须改变你的类定义的顺序如下图所示。

在此处输入图像描述

代码--->

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

我希望这个答案对你有帮助。

于 2016-01-20T10:56:57.140 回答