Hi all,
I am very new to openerp and python script. I have requirement where I want to
run onchange event python script. Where to add the script is my question? I
have added base_contact module. I have create a new object called
x_training_attendance. I need to call 'onchange_studentgp_id' for attendance
view. I have imported attendance.py (where I have define the function
'onchange_studentgp_id') file in _init . But through view when I call the
onchange function it gives me the below error:
Traceback (most recent call last):
File "netsvc.pyo", line 235, in dispatch
File "netsvc.pyo", line 74, in __call__
File "service\web_services.pyo", line 526, in execute
File "osv\osv.pyo", line 59, in wrapper
File "osv\osv.pyo", line 119, in execute
File "osv\osv.pyo", line 111, in execute_cr
AttributeError: 'x_custom_model' object has no attribute 'onchange_studentgp_id'
What else i have to change?
my attendance.py is as below:
import time
import netsvc
from osv import fields, osv
import ir
from mx import DateTime
from tools import config
from tools.translate import _
class x_training_attend(osv.osv):
_name = "x_training_attend"
_description = "Daily Attendance"
_columns = {
'x_name': fields.date('Attendance Date',required=True),
'x_session_id': fields.many2one('x_training_sessions','Session'),
'x_studentgp_id': fields.many2one('x_training_studentgp','Student
group'),
'x_student_id':
fields.many2many('x_training_studentgp','x_training_studentgp_x_rel','x_','x_student_id','Student'),
'x_present': fields.boolean('Present'),
'x_absent': fields.boolean('Absent')
}
def onchange_studentgp_id(self, cr, uid, ids, studentgp_id):
v={}
if studentgp_id:
gp=self.pool.get('x_training_studentgp').browse(cr,uid,studentgp_id)
if gp.x_.id:
v['x_student_id']=gp.x_.id
return {'value':v}
x_training_attend()
my attendance view is
<?xml version="1.0" encoding="utf-8"?>
<form string="x_training_attend">
<field name="x_name"/><field name="x_session_id"/><field
name="x_present"/><field name="x_absent"/><field name="x_studentgp_id"
on_change="onchange_studentgp_id(x_studentgp_id)"
select="1"/><separator/><field colspan="4"
domain="[('student_id','=',x_student_id)]" name="x_student_id" select="1"/>
</form>
-------------------- m2f --------------------
--
http://www.openobject.com/forum/viewtopic.php?p=38359#38359
-------------------- m2f --------------------
_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users