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;} }); });
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
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>
when i select the course_id value batch_id value is not updating please help me
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up