تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
3258 أدوات العرض

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

الصورة الرمزية
إهمال
الكاتب

title is coming from res.partner.title,,

أفضل إجابة

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

الصورة الرمزية
إهمال
أفضل إجابة


@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


الصورة الرمزية
إهمال