Skip to Content
Menu
This question has been flagged
1 Atsakyti
7289 Rodiniai

I am working in an invoice form in Odoo, what i want is to display all the related details of a customer selected in the form from database.I have given an onchange context in the xml

field string="Student" name="partner_id"
                           on_change=" _get_joined_student_data(partner_id)" context="{'default_branch':branch,'default_course':course,'default_faculty':faculty,'search_default_customer':1, 'show_address': 1,'special_display_name': True,'default_time_slot':time_slot}"
                            options='{"always_reload": True}'
                            domain="[('customer', '=', True)]"/>

And the corresponding function definition for the function is given below

 def _get_joined_student_data(self,partner_id):
    print "function"
    datas={}
    print self
    if partner_id:
        print partner_id
        self._cr.execute("SELECT c.id,c.fee,b.id,t.id,f.id FROM custom_joinform cj LEFT JOIN course_custom c on cj.course=c.id "+
           "LEFT JOIN branch_custom b on cj.branch=b.id LEFT JOIN custom_timeslot t on cj.time_slot=t.id LEFT JOIN custom_faculty f on cj.faculty=f.id LEFT JOIN res_partner r on r.id=cj.name where r.id="+str(partner_id)+" and function='Student'")
           #print "SELECT c.name,c.fee,b.name,t.name,f.name FROM custom_joinform cj LEFT JOIN course_custom c on cj.course=c.id LEFT JOIN branch_custom b on cj.branch=b.id LEFT JOIN custom_timeslot t on cj.time_slot=t.id LEFT JOIN custom_faculty f on cj.faculty=f.id LEFT JOIN res_partner r on r.id=cj.name where r.id="+str(self.name.id)+" and function='Student'"
        for res in self.env.cr.fetchall():
            datas={
                   'course':res[0],
                   'course_fee':res[1],
                   'branch':res[2],
                   'time_slot':res[3],
                   'faculty':res[4]
                  }
        print datas
        self.update(datas)


And the print statements inside the function is printing correctly. But nothing happens in the form after changing the selection.Can anyone help me to solve this issue.

Portretas
Atmesti
Autorius Best Answer

I have tried with the below code but that too gives me the same output, Nothing happens for the fields which i have given in the xml for default values

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
spal. 17
5540
0
kov. 23
1154
1
gruod. 20
5295
2
lapkr. 19
4299
0
kov. 19
2680