2015-06-24 56 views
0

请,我想把一个函数的值放在一个字段中。我的功能返回不同的结果,这就是为什么我提出:如何在odoo中的字段中设置一个值

def create(self, cr, uid, vals, context=None): 
     return {'value': {'field': value}} 

但是什么也没有发生。

+0

请详细说明更多关于什么是你的目标。 [阅读更多](http://stackoverflow.com/help/how-to-ask)关于如何提出一个好问题。 – methode

回答

1

如果传递像一个参数的值: '丘壑'

OpenERP的V7,

def create(self, cr, uid, vals, context=None): return {'value': {'your_field_name': vals }}

Odoo(OpenERP的V8)

def create(self,vals): return {'value': {'your_field_name': vals }}

我希望这能帮你!

1

您需要重写create方法,然后调用super方法。

def create(self, cr, uid, vals, context=None): 
    ### here you can change the value of the fields 
    vals.update({'field': value}) 
    ## then call the super method 
    return super(class_name, self).create(cr, uid, vals, context=context) 
0

如果您使用的是8/9 API

@api.model 
def create(self,values): 
     values.update({'field_name': value}) 
     ## then call the super method 
     return super(ClassName, self).create(values) 
0
def create(self, cr, uid, vals, context=None): 
    ### here you can change the value of the fields 
    vals.update({'field': value}) 
    ## then call the super method 
    return super(class_name, self).create(cr, uid, vals, context=context) 
相关问题