Hi,
I have this class :
class Custom_Project (models.Model):
_inherit = "project.task"
task_lines = fields.One2many('task.line','task_id',string="Lines")
state = fields.Selection((('draft',_('Draft')),('open',_('In progress')),('done',_('Done'))), default = 'draft', string='Status', required="True")
What i want is to change the state of the workflow to "done" when the value of the field "progress" in all lines of the one2many tree "task_lines" is equal to 100.
So in my custom module (in the .py file) I tried
@api.onchange( 'task_lines.progress')
def progress_on_change(self):
for record in self:
all_done = True
for line in record.task_lines:
if line.progress != 100:
all_done = False
break
if all_done == True:
record.write({'state': 'done'})
But this does not change the state to done as i expected. What should I do to make it work?
Thanks,