Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5828 มุมมอง

just getting used to openerp. building a simple entity class and view for a contact list. which looks like this

from openerp.osv import osv,fields

class contact(osv.Model):
    _name = "contact.contact"
    _columns = {
        'name': fields.text('Contacts Name', size=80, required=True),
        'gender': fields.selection('Sex', [('Male', 'Male'), ('Female', 'female')], required=True),
        'email': fields.text('Email address', size=60),
        'number': fields.text('Phone Number', size=20),
    }
    _defaults = {
         'name': 'eoin',
         'active': True,
    }

when i try to install the module i get the following error.

AssertionError: Default function defined in contact.contact but field active does not exist !

can anyone help me with this?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The problem is _defaults. Look on it again you have given active field in _defaults but you didn't defined it in _columns.

So either remove it from _defaults or define the field.

อวตาร
ละทิ้ง
ผู้เขียน

deleted that but still get the same error?

After make changes in py file, you have to restart OpenERP server.

ผู้เขียน

thanks you. realise this now. but iam still getting errors likre the following

ผู้เขียน

ProgrammingError: syntax error at or near "ARRAY" LINE 1: COMMENT ON COLUMN contact_contact."gender" IS ARRAY[('Male',...

ผู้เขียน คำตอบที่ดีที่สุด

thanks, yeah i just copied some of this from another example so didnt really know what i was at.

อวตาร
ละทิ้ง
ผู้เขียน

yeah deleted that line and it still get the same error