首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

OpenERP中设立默认值

2012-10-09 
OpenERP中设置默认值#--------------------------------------------------# IT goods category#---------

OpenERP中设置默认值

#--------------------------------------------------# IT goods category#--------------------------------------------------class goods_category(osv.osv):    _name = "it_warehourse.goods_category"    _description = "IT goods_category"    _columns = {        'name': fields.char('Name', size=100, required=True),        'parent_id': fields.many2one('it_warehourse.goods_category', 'Parent Category', select=True),        'child_id': fields.one2many('it_warehourse.goods_category', 'parent_id', string='Child Categories'),        'type':fields.selection([('desktop', 'Desktop Computer'), ('notebook', 'Notebook'), ('others', 'Others')], 'Category Type'),    }        _defaults = {        'type': lambda * a : 'desktop',    }    goods_category()

其中, _defaults是设置默认值,有点类似__init__作用。

热点排行