我如何在自定义模块 openerp 中使用 _defaults 函数
How can i use _defaults function in custom module openerp
我编写了自定义模块,但我对 _defaults 函数有疑问。
当我安装模块时,它抛出一个错误
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 = {
}
尝试使用此代码。 (适当缩进)
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 = {
}
我编写了自定义模块,但我对 _defaults 函数有疑问。
当我安装模块时,它抛出一个错误
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 = {
}
尝试使用此代码。 (适当缩进)
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 = {
}