Skip to Content
Menu
This question has been flagged
1 Reply
7810 Views
 odoo.define("portal_student.registration", function (require) {
$(document).on("change", "#course_dropdown", function (){
var rpc = require('web.rpc'); var course = document.getElementById("course_dropdown"); rpc.query({ model: 'op.batch', }).then(function (data) { for(i in data){  document.getElementById("batch_id").value = i.name;} }); }); 
Avatar
Discard
Best Answer

Hi Paidy,
You can use the below code get records inside 'op.batch' model in javascript.

odoo.define("portal_student.registration", function (require) {
    $(document).on("change", "#course_dropdown", function (){
        var rpc = require('web.rpc');
        var course = document.getElementById("course_dropdown");
        rpc.query({
            model: 'op.batch',
            method: 'search',
            args: [[]]
        }).then(function (data) {
            // you will get all the records inside op.batch model from data variable
            for(i in data){
                document.getElementById("batch_id").value = i.name;
            }
        });
    });
});

Regards
Cybrosys

Avatar
Discard
Author

this is not working for my form why

<div class="col-md-8">

<select id="course_dropdown" class="form-control" name="course_id">

<option value="">

<lable>Select your option</lable>

</option>

<t t-foreach="course" t-as="course_id">

<option t-att-value="course_id.id">

<t t-esc="course_id.name"/>

</option>

</t>

</select>

</div>

<div class="col-md-4 mt16">

<lable for="batch_id">Batch:</lable>

</div>

<div class="col-md-8 mt8" id="batch_id">

<select class="form-control" id="batch_id"

name="batch_id" required="1">

</select>

</div>

Author

when i select the course_id value batch_id value is not updating please help me