如何解决未捕获的TypeError:类型不是构造函数

时间:2019-02-18 10:59:50

标签: python-2.7 odoo-8

我使用的是odoo 8,我想对干预请求中的有缺陷的碎片和数量进行精确调整,但显示错误 Uncaught TypeError:Type不是构造函数。我注意到问题所在当我在Piécesde rechange 树中使用 product_id 时出现。我为解决该问题进行了许多研究,但并不总是有效。这是我的代码有什么帮助吗?

enter image description here

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),
}

0 个答案:

没有答案