如何在自定义模块openerp中使用\u defaults函数

2024-05-13 04:26:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了自定义模块,但在使用默认函数时遇到了问题。你知道吗

当我安装模块时,它抛出了一个错误

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


Tags: 模块nametruefieldspartnersizestringorm
1条回答
网友
1楼 · 发布于 2024-05-13 04:26:52

尝试使用此代码。(作适当的缩进)

医疗诊断_假设.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.

相关问题 更多 >