justme
justme

Reputation: 31

How to set a value in a field in odoo

Please, i want to put a value of a function in a field. my function return different results thats why i made :

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

But nothing happened.

Upvotes: 0

Views: 4619

Answers (4)

chainika
chainika

Reputation: 1

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) 

Upvotes: 0

user2946922
user2946922

Reputation: 1

If you are using the 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)

Upvotes: 0

You need to override create method and then super method calling required.

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)

Upvotes: 1

Juan Salcedo
Juan Salcedo

Reputation: 1668

If you pass a value like a parameter: 'vals'

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 }}

I hope this can help you!

Upvotes: 1

Related Questions