Skip to content

Commit

Permalink
[FIX] activity draft button issue and create child activity when pare…
Browse files Browse the repository at this point in the history
…nt activity is in_progress state
  • Loading branch information
jayraj-omnia committed Jan 8, 2025
1 parent 883fc7d commit 347c05d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion activity_validation/models/mail_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,23 @@ def write(self, vals):
child_dict['is_eco'] = True

ret = super(MailActivity, self).write(vals)
if self.plm_state == 'in_progress':
for child in self.children_ids:
if not child.mail_children_activity_id:
activity_vals = {
'activity_type_id': self.activity_type_id.id,
'date_deadline': self.date_deadline,
'user_id': child.user_id.id,
'plm_state': 'draft',
'name': child.name,
'note': self.note,
'res_model_id': self.res_model_id.id,
'res_id': self.res_id,
}
new_activity_id = self.create(activity_vals)
child.mail_children_activity_id = new_activity_id.id
child.mail_parent_activity_id = self.id

if self.env.user.has_group('activity_validation.group_force_activity_validation_admin'):
return ret
return ret
Expand Down Expand Up @@ -168,7 +185,6 @@ def clearChildrenActivities(self):
for child_rel in child_id.mail_children_activity_id.sudo():
if child_rel.plm_state == 'draft':
child_rel.unlink()
child_rel.unlink()

def action_to_draft(self):
self.clearChildrenActivities()
Expand Down

0 comments on commit 347c05d

Please sign in to comment.