Hello,
I am working on a module where I implement a special, simplified version of a task.
Ithis task model, there are a few standard task types and each of those types comes with a specific set of state stages.
I have created a table where I can store task types and stage names. I have gotten it so that at the time of creation, the task gets assignedd a specific task type.
Now my issue is that I want to use a callable for the selection field which calls on self to finnd out it's own task type, search for the stages corresponding to this task type and assign them to the selection field.
the theory sounds great, but for some reason, when I call self, it appears to be empty. When I try to debug using the console print, I always get 'irig.task()' (the name of the model) but no records in the recordset.
can anybody help me figure out what am I calling wrong?
state_test = fields.Selection(selection='get_states')
def get_states(self):
sel = [
('1','One'),
('2','Two')
]
print(self)
for r in self:
records = self.env['irig.state'].search([('task_type', 'like', 'gear')])
## It should llok like this, but the r in self is empty:
.search([('task_type', 'like', r.task_type)])
for rec in records:
sel.append((rec.task_type, rec.name) )
print(sel)
return sel
In the above snippet, I have tested individual parts and it all works, the only part that since self shows as empty, then 'r in self' is also empty.
Even after the record is created, when I navigate to it, the 'get_states' method is called, but self is still empty.
Any help will be greatly appreciated!
have you overridden the create method to call get_states()?
@Rithik Sandron
I just tried it, but it still didn't work.