Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
7534 Widoki

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.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 17
5685
0
mar 23
1289
1
gru 20
5443
2
lis 19
4471
0
mar 19
2876