Skip to Content
Menu
This question has been flagged
3 Replies
2956 Views

hi all,i have a form on the top of which i have name field and below i have a field called title as to give title such as mr,mrs,professor etc,,,,,,,,,,what i want is that when i give name in the name field and go down and give title ,,name field should be automatically merged with the title,,,,,,

for example

name : osama

title: mr


and name should be changed to mr osama automatically

can any one help??

Avatar
Discard
Author

title is coming from res.partner.title,,

Best Answer

Hi,

You can achieve this in different ways,

* If you want to get the name like this Mr XYZ in some other model, like in the many2one field of this model, you can achieve it by adjusting the name_get function for this model as shown by Srikanth in his answer. 

* If you need the merged value in the same model itself, you can create a third field in same model and compute value into it from the first two fields.

* Another option is to write onchange for the first field and write the entered value  in title field to name field so that user will enter name as rest of the title.

Thanks

Avatar
Discard
Best Answer


@api.multi
@api.depends('name', 'title')
def name_get(self):
result = []
for rec in self:
name = rec.name + ' ' + rec.title
result.append((rec.id, name))
return result


Avatar
Discard