我想在更改字段值FrontEnd Odoo v12之后更新另一个字段的值,
有两个字段选择,我想当我更改第一个字段的值时,第二个字段将自动更改,
第一个字段是公司列表,第二个字段是部门列表字段, 我不希望出现所有列表的问题,我想要当我选择一家公司时,该列表将被过滤,并且看来该公司的部门 这是我的代码:
controller.py
@http.route('/page/listdepartment', auth='public', website=True)
def index(self, **kw):
print('kw',kw)
company = http.request.env['res.company'].sudo().search([])
department = http.request.env['hr.department'].sudo().search([('is_institute', '=', 'true')])
vals = {
'company': company,
'department' : department,
}
return http.request.render('mymodule.listdepartment', vals)
我的XML
<select class="form-control" name="desired_faculty" id="desired_company" required="required" >
<option value="">Choose...</option>
<t t-foreach="company or []" t-as="comp">
<t t-if="comp.id == def_company">
<option t-att-value="comp.id" selected="selected">
<t t-esc="comp.name" />
</option>
</t>
<t t-else="">
<option t-att-value="comp.id">
<t t-esc="comp.name" />
</option>
</t>
</t>
</select>
</div>
<div class="form-group col-md-6 ">
<label class="label-sml" for="desired_department">
Choice the faculty
<span class="is-required">*</span>
</label>
<select class="form-control" name="desired_department" id="desired_department" required="required" >
<option value="">Choose...</option>
<t t-foreach="department or []" t-as="dep">
<t t-if="dep.id == def_department">
<option t-att-value="dep.id" selected="selected">
<t t-esc="dep.name" />
</option>
</t>
<t t-else="">
<option t-att-value="dep.id">
<t t-esc="dep.name" />
</option>
</t>
</t>
</select>
</div>