Odoo Help

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

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: 2102 times
Last updated: 3/16/15, 8:10 AM