Key error! 扩展product模块错误
-
个人觉得Tiny ERP 在小企业应用中非常适合。灵活,模块化,而且应该开发难度不高。现有的模块已经具备基本功能,有些特殊的需求能很快开发出扩展模块,自带workfolw 引擎,能满足业务流程定制,自定义报表。。。。
现在正在研究模块开发,现在遇到一些问题,希望能得到高人指点。
我写的测试模块是在原有product 模块基础上扩展部分功能,原有的product 模块没有产品属性,只有产品分类
实体类文件product_new.py:[code]from osv import fields, osv
class product_property(osv.osv):
def name_get(self, cr, uid, ids, context={}):
if not len(ids):
return []
reads = self.read(cr, uid, ids, ['name','parent_id'], context)
res = []
for record in reads:
name = record['name']
if record['parent_id']:
name = record['parent_id'][1]+' / '+name
res.append((record['id'], name))
return resdef _name_get_fnc(self, cr, uid, ids, prop, unknow_none, unknow_dict): res = self.name_get(cr, uid, ids) return dict(res) def _check_recursion(self, cr, uid, ids): level = 100 while len(ids): cr.execute('select distinct parent_id from product_property where id in ('+','.join(map(str,ids))+')') ids = filter(None, map(lambda x:x[0], cr.fetchall())) if not level: return False level -= 1 return True _description='Prodcut Property' _name = 'product.property' _columns = { 'name': fields.char('Property Name', required=True, size=64), 'parent_id': fields.many2one('product.property', 'Parent Property', select=True), 'complete_name': fields.function(_name_get_fnc, method=True, type="char", string='Name'), 'child_ids': fields.one2many('product.property', 'parent_id', 'Childs Category'), 'active' : fields.boolean('Active'), } _constraints = [ (_check_recursion, 'Error ! You can not create recursive properties.', ['parent_id']) ] _defaults = { 'active' : lambda *a: 1, } _order = 'parent_id,name'
product_property()
class product_product(osv.osv):
_name = "product.product"
_inherit = "product.product"
_columns = {
'property_ids': fields.many2many("product.property", "product_property_rel", "product_id", "property_id", "roperties"),
}
product_product()[/code]
视图定义product_new_view.xml发不上来,见附件
报错信息:[code]Traceback (most recent call last):
File "netsvc.pyo", line 200, in _dispatch
File "serviceweb_services.pyo", line 366, in execute
File "osvosv.pyo", line 111, in execute
File "osvosv.pyo", line 92, in execute_cr
File "osvorm.pyo", line 1544, in fields_view_get
File "osvorm.pyo", line 1409, in __view_look_dom_arch
KeyError: u'property_ids'[/code]找了很久不知错误在哪里,请帮忙指点。[[i] 本帖最后由 Wingedox 于 2008-4-3 20:30 编辑 [/i]]