when i select regulation from dropdown to auto populate the data into tree view. small vague with this please help me
this is my py file:
class studentreg(models.Model):
_name='student.registration'
_description='Student registration'
regulation=fields.Selection([('r10','R10'),('r16','R16')],required=True)
supply_data=fields.One2many('page.studentregistration','failed_data')
@api.multi
@api.onchange('regulation')
def onchange_get_faileddata(self):
stud_list = []
stud_obj = self.env['faileddata.form']
for rec in self:
if rec.regulation:
stud_list = [{'subject_code': stu.sub_code,'subject_name': stu.sub_name,'subject_type':stu.sub_type}
for stu in stud_obj.search([('regulation', '=',
rec.regulation.id),
])]
rec.supply_data = stud_list
class faileddataform(models.Model):
_name='faileddata.form'
_description='failed data'
sub_code = fields.Char('Subject Code')
sub_name = fields.Char('Subject Name')
sub_type = fields.Char('Subject Type')
please refer this link for adding values to one2many/ many2many.
https://odoo-development.readthedocs.io/en/latest/dev/py/x2many.html
Odoo Customization Tips refer link: https://www.scoop.it/t/learn-openerp