Hi all,
Take a look at my error please... in my model I have create() method to concatenate my first_name and last_name and fill into my name field and it works. I have also write() method to update if I have any changes to first_name, last_name and fill into my name field, but I got an errors below. someone can help me figure out to work my write() method, Thanks for the effort and answers
errors------
Server Traceback (most recent call last): File "/home/jp/ws/openerp/web/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/jp/ws/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/jp/ws/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/jp/ws/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) TypeError: write() got multiple values for keyword argument 'context'
python -----
def create(self, cr, uid, vals, context=None):
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
vals['name'] = name.title()
return super(hr_employee, self).create(cr, uid, vals, context=context)def write(self, cr, uid, vals, context=None):
name = str(vals['first_name'] or '') + ' ' +str(vals['last_name'] or '')
vals['name'] = name
return super(hr_employee, self).write(cr, uid, vals, context=context)def onchange_first_name(self, cr, uid, ids, first_name, context=None):
if first_name:
return {'value': {'first_name': first_name.title()}}
return {'value':{}}def onchange_last_name(self, cr, uid, ids, last_name, context=None):
if last_name:
return {'value': {'last_name': last_name.title()}}
return {'value':{}}def onchange_name(self, cr, uid, ids, last_name, context=None):
if last_name:
return {'value': {'last_name': last_name.title()}}
return {'value':{}}
_columns = {
'name': fields.char('First Name', size=32),
'date_start': fields.date('Start Date', required=True),
'date_end': fields.date('End Date'),
'attendance_ids' : fields.one2many('philcode.test', 'calendar_id', 'Working Time'),
'first_name': fields.char('First Name', size=32, required=True),
'last_name': fields.char('Last Name', size=32, required=True),
}
xml -----
<label for="first_name"/>
<div>
<h1><field name="first_name" style="width: 50%%" on_change="onchange_first_name(first_name)"/></h1><br/>
</div>
<label for="last_name"/>
<div>
<h1><field name="last_name" style="width: 50%%" on_change="onchange_last_name(last_name)"/></h1>
</div>
<label for="name" String="Full Name"/>
<div>
<h1><field name="name" on_change="onchange_name(name)" style="width: 50%%"/></h1>