Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

separate long name into several field

By
bakulnet
on 5/17/13, 9:07 AM 1,388 views

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

Prakash
on 5/17/13, 9:39 AM

can you explain more spesific?

bakulnet
on 5/17/13, 10:12 AM
0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 5/17/13, 10:28 AM

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?

bakulnet
on 5/17/13, 10:31 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/17/13, 9:07 AM
Seen: 1388 times
Last updated: 3/16/15, 8:10 AM