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

I have a class:

class activeuser(osv.osv):

_name = activeuser

_columns = {

'name':fields.char('Name', size=128),

'description_about':fields.text('About Name'),

}

activeuser()

I want get every word of 'name' field into new fields that I will create, lets say:

'first_word'

'second_word'

'third_word'

'fourth_word'

How to do that?

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

Can Create Three fields First Name, Last Name, Middle Name in the fourth fields Complete Name con-cat all the three fields using Functional Fields or on_change event

الكاتب

can you explain more spesific?

أفضل إجابة

Code:

overridden Create and Write Method

class activeuser(osv.osv):
_name = activeuser
_columns = {
'first_name':fields.char('First Name', size=128),
'middle_name':fields.char('Middle Name', size=128),
'last_name':fields.char('Last Name', size=128),
'name':fields.char('Full Name', size=128),
'description_about':fields.text('About Name'),
}
activeuser

    def create(self, cr, user, vals, context=None):
        vals['full_name'] = vals['first_name'] + ' ' + str(vals['middle_name'] or '') + ' ' + vals['last_name']
        return super(activeuser,self).create(cr, user, vals, context)

    def write(self, cr, user, ids, vals, context=None):
        for res in self.browse(cr,user,ids):
            print "name"
        if not 'first_name' in vals:   
            vals['first_name'] =  res.first_name
        if not 'middle_name' in vals:       
            vals['middle_name'] =  res.middle_name
        if not 'last_name' in vals:           
            vals['last_name'] =  res.last_name
        vals['full_name'] = vals['first_name'] + ' ' + str(vals['middle_name'] or '') + ' ' + vals['last_name']
        return super(activeuser,self).write(cr, user, ids, vals, context)
الصورة الرمزية
إهمال
الكاتب

ok, thanks in advance, I'll try first, how to apply it in on_change method?

المنشورات ذات الصلة الردود أدوات العرض النشاط
3
أغسطس 19
7960
0
يونيو 15
3143
2
أغسطس 24
2385
1
مارس 15
4152
0
مارس 15
3727