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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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
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
field_name1, field_name2 means you set here your fields which you want to change
value1, value2 means which you want to set the new value of that field.
model name means write your model name which you define class name.
Hope this helpful for you.
Thanks & Regards
Ankit H Gandhi
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
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
mrt. 25
|
1419 | ||
|
0
jan. 25
|
3498 | ||
|
1
aug. 23
|
14865 | ||
change password
Opgelost
|
|
1
aug. 23
|
13511 | |
|
1
jul. 23
|
10489 |