Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
19149 Lượt xem

Hello. I want to write a function to concatenate the fields 'firstname' and 'surname' in one 'name' field, I tried but I can not get results. Here is my code:

def _firstname_surname(self, cr, uid, ids, field, arg, context=None):
    for etudiant in self.browse(cr, uid, ids, context=None)
    'name' = 'firstname' + ' ' + 'surname' 
    return name
Ảnh đại diện
Huỷ bỏ

you need to reformat your code to make it more readable in the question.

Câu trả lời hay nhất

Please, search before post:

https://accounts.openerp.com/forum/Help-1/question/3513

Ảnh đại diện
Huỷ bỏ
Tác giả

ok thank you very much.

Tác giả Câu trả lời hay nhất

Hi. I have a problem, I would like to concatenate two char in one field, I do this code ut it does'nt work. Can you help me please.

def _my_methode(self, cr, uid, ids, field_name, arg, context=None):
    records=self.browse(cr,uid,ids)
    result = dict((x,'') for x in ids)
    for r in records:
        if(r.firstname and r.lastname)
            result[r.id] = "%s %s" % \
                     (r.firstname or '', r.lastname or '')
    return result
Ảnh đại diện
Huỷ bỏ

I do no want to make the name field as functional field. Whether it is possible to do the concatenation of firstname and lastname in one 'name' field by inheiring create or write method.? Please help if somebody know how to do?