i want filter levels based on stage i use onchange:
models mk.stage:
#any stage have multi level
class mk_stage(models.Model):
_name = 'mk.stage'
_description = 'Student Stage'
name = fields.Char(string='Stage')
max_number = fields.Integer(string='Max number of Stages')
level_ids = fields.Many2many(
'mk.levels','stage_level_rel','stage_id',
'level_id', string='Levels'
)
models level:
class mk_levels(models.Model):
_name = 'mk.levels'
_description = 'Student Level'
name = fields.Char(srting = 'Student Level')
model mk.link.student
in this model i want when select stage filter level base any stage have levels in class mk_stage
class mk_link_student(models.Model):
_name = 'mk.link.student'
_description = 'Link Student With Stage'
_rec_name = 'name_stage_id'
name_stage_id = fields.Many2one(
'mk.stage',string='Name Stage',
)
level_id = fields.Many2one(
'mk.levels',
string='Levels'
)
@api.onchange('name_stage_id')
def onchange_domain_on_days(self):
res = {}
ids = []
level_model = self.env['mk.link.student']
all_stage = self.search([])
print all_stage, 'OOOOOOOOOOOOOOOOOOOOOOO'
for level_rec in all_stage:
print level_rec, '?????????????????'
if level_rec.level_id == self.name_stage_id.level_ids:
ids.append(level_rec.id)
res['domain'] = {
'level_id': [('id', 'in', ids)],
}
return res
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
1
Reply
1970
Views
Hi
It seems that onchange is improper. Please try following code.
@api.onchange('name_stage_id')
def onchange_domain_on_days(self):
res = {'domain': {
'level_id': [('id', 'in', self.name_stage_id.level_ids.ids)]
}}
return res
Hope it will solve your issue.
yes solved Dhaval thank you
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
yes solved thank you Dhaval