Skip to Content
Menu
This question has been flagged
1 Atsakyti
237 Rodiniai

Hi guys!!!!

I have tried this to change the value of a field but nothing wotks fine.

resultat = {'value':{'name_field':value

}

return resultat

Please need your help

Portretas
Atmesti
Best Answer

Dear Abdelwahed,

There are two option to update the value.

1. Use the write method.

Write method perform when you press the save button.

2. Use the on change method.

On change method perform when you want value update based on value change of other field.

Updated answer..

Here I explain how to use write method

Syntax of write() method

write(cr, uid, ids, vals, context=None)

Update records with given ids with the given field values

Parameters:

  • cr -- database cursor

  • user (integer) -- current user id

  • ids -- object id or list of object ids to update according to vals

  • vals (dictionary) -- field values to update, e.g {'field_name': new_field_value, ...}

  • context (dictionary) -- (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...}

Also example of write method.

def write(self, cr, uid, vals, context=None):

     vals.update({'field_name1':'value1', 'field_name_2':'value2'................................}) # this code not need to write

     vals.update({'name':'Ankit', 'last_name':'Gandhi',................................})

    return super(model_name, self).write(cr, uid, vals, context=context) # this code not need to write

    return super(hr_employee, self).write(cr, uid, vals, context=context)

Here above example given

  1. field_name1, field_name2 means you set here your fields which you want to change

  2. value1, value2 means which you want to set the new value of that field.

  3. model name means write your model name which you define class name.


Hope this helpful for you.

Thanks & Regards

Ankit H Gandhi

Portretas
Atmesti
Autorius

Ankit thanks for the answer but please i didnt know how to use the write method on class a when i am in class b

Related Posts Replies Rodiniai Veikla
0
kov. 25
1419
0
saus. 25
3496
1
rugp. 23
14864
1
rugp. 23
13511
1
liep. 23
10488