2016-02-01 65 views
0

我編寫自定義模塊,但是我有_defaults函數的問題。如何在自定義模塊中使用_defaults函數openerp

當我安裝模塊,它拋出一個錯誤

Indentation Error: unexpected indent for "_defaults = {".

medical_diagnostic_hypothesis.py 

from openerp.osv import fields, orm 


class MedicalDiagnostic_hypothesis(orm.Model): 
    _name = 'medical.diagnostic_hypothesis' 
    #_inherit = ['mail.thread', 'ir.needaction_mixin'] 

    _columns = { 
     'name': fields.char(size=256, string='Diagnostic ID', required=True), 
     'partner_id': fields.many2one('res.partner', 'Partner', 
             required=True), 
     'pathology_category_id': fields.many2one('medical.pathology.category', 
             'Pathology',required=True), 
     'diagnostic': fields.char(size=256, string='Diagnostic'), 
     'treatment_method': fields.char(size=256, string='Treatment Method'), 
    } 
    _defaults = { 
       } 

Server trace-back image

+0

沒有你留下的_defaults字典。故意空? –

+0

當_deaults函數有內容時也會出現同樣的問題。感謝您的意見 !。 – haris

+0

這是一個縮進錯誤,您需要檢查它。縮進必須匹配。 –

回答

0

與此代碼嘗試。 (做正確的縮進)

medical_diagnostic_hypothesis.py

from openerp.osv import fields, orm 

class MedicalDiagnostic_hypothesis(orm.Model): 
    _name = 'medical.diagnostic_hypothesis' 
    #_inherit = ['mail.thread', 'ir.needaction_mixin'] 

    _columns = { 
     'name': fields.char(size=256, string='Diagnostic ID', required=True), 
     'partner_id': fields.many2one('res.partner', 'Partner', 
             required=True), 
     'pathology_category_id': fields.many2one('medical.pathology.category', 
             'Pathology',required=True), 
     'diagnostic': fields.char(size=256, string='Diagnostic'), 
     'treatment_method': fields.char(size=256, string='Treatment Method'), 
    } 

    _defaults = { 
    } 

更多關於indentation in python.

相關問題