i'm using odoo 8 and I want to precise the defective pieces and the quantity in my request for intervention but it show error Uncaught TypeError: Type is not a constructor.I notice that the problem comes when i use product_id in the tree Piéces de rechange.I di many research to resolve the problem but it doesn't work always.Here is my code any help please ?
cmms_intervention.xml
<record id="view_intervention_form" model="ir.ui.view">
<field name="name">cmms.intervention.form</field>
<field name="model">cmms.intervention</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Intervention request" version="7.0">
<header>
<button name="action_broadcast" type="object" string="Déffuser mail" icon="STOCK_REDO"/>
<button name="action_done" states="draft" string="Valider" type="object" icon="gtk-apply"/>
<button name="action_cancel" states="done," string="Annuler" type="object" icon="gtk-cancel"/>
<button name="action_draft" states="cancel" string="Remettre en brouillon" type="object" icon="terp-stock_effects-object-colorize"/>
<field name="state" widget="statusbar" />
</header>
<sheet>
<group>
<group>
<field name="name" select="1" />
<field name="user_id" select="1" colspan="1" />
<field name="user2_id" />
<field name="priority" />
<field name="state_machine" />
<field name="product_id"/>
</group>
<group>
<field name="type" select="1" colspan="1" />
<field name="equipment_id" select="1" colspan="1" />
<field name="date_inter" />
<field name="date_end" />
</group>
</group>
<separator colspan="4" string="Piéce défectueuse" name="piece_def"/>
<!--<page string="Affectation">-->
<field name="piece_line" widget="one2many_list">
<tree string="Piéces de rechange" editable="bottom">
<filed name="product_id" />
<field name="product_qty"/>
</tree>
</field>
<newline />
<notebook colspan="1">
<page string="Motif d'intervention">
<field name="motif" />
</page>
<page string="Observation">
<field name="observation" />
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
piece_defectueuse.py
class Piece_defectueuse(osv.osv):
_name = "cmms.piece"
_columns = {
'product_id': fields.many2one('product.product', 'Product',required=True),
'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'),
required=True),
'product_name':fields.char("Nom "),
'intervention_id':fields.many2one('cmms.intervention','Demande d intervention'),}
cmms.py
class cmms_intervention(osv.osv):
_name = "cmms.intervention"
_columns = {
'piece_line': fields.one2many('cmms.piece', 'intervention_id', 'Piéces de rechange défectueuse', required=True,
states={'done': [('readonly', True)]}),
'product_id': fields.many2one('product.product', 'Piéces de rechange', required=True),
'product_qty': fields.integer('Quantité'),
'product_name': fields.char("Nom "),
'move_lines': fields.one2many('stock.move', 'picking_id', copy=True),
# 'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines',copy=True),
'name': fields.char('Intervention reference', size=64),
'equipment_id': fields.many2one('cmms.equipment', 'Unit of work', required=True),
'date': fields.datetime('Date'),
'user_id': fields.many2one('res.users', 'Sender', readonly=True),
'user2_id': fields.many2one('res.users', 'Recipient'),
'priority': fields.selection([('normal','Normal'),('low','Low'),('urgent','Urgent'),('other','Other')],'priority', size=32),
'observation': fields.text('Observation'),
'motif': fields.text('Motif'),
'date_inter': fields.datetime('Intervention date'),
'date_end': fields.datetime('Intervention end date'),
'type': fields.selection([('check','Check'),('repair','Repair'),('revision','Revision'),('other','Other')],'Intervention type', size=32),
'state_machine': fields.selection([('start','En Marche'),('stop','En Arret')],'Etat de machine', size=32),
'state' : fields.selection([('draft',u'En cours'),('done',u'Validé'),('cancel',u'Annulé')],u'Statut',required=True),
}