-
-
Notifications
You must be signed in to change notification settings - Fork 529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[14.0][ADD] base_automation_team_activity #957
base: 14.0
Are you sure you want to change the base?
[14.0][ADD] base_automation_team_activity #957
Conversation
b985275
to
8f186a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Funtional Review 👍
def _run_action_next_activity(self, eval_context=None): | ||
if ( | ||
not self.activity_type_id | ||
or not self._context.get("active_id") | ||
or self._is_recompute() | ||
): | ||
return False | ||
|
||
records = self.env[self.model_name].browse( | ||
self._context.get("active_ids", self._context.get("active_id")) | ||
) | ||
|
||
vals = { | ||
"summary": self.activity_summary or "", | ||
"note": self.activity_note or "", | ||
"activity_type_id": self.activity_type_id.id, | ||
} | ||
if self.activity_date_deadline_range > 0: | ||
vals["date_deadline"] = fields.Date.context_today(self) + relativedelta( | ||
**{ | ||
self.activity_date_deadline_range_type: self.activity_date_deadline_range | ||
} | ||
) | ||
for record in records: | ||
if self.activity_user_type == "team": | ||
vals["team_id"] = self.team_id.id | ||
vals["user_id"] = self.team_id.user_id.id | ||
record.activity_schedule(**vals) | ||
else: | ||
super()._run_action_next_activity(eval_context=eval_context) | ||
|
||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the idea but what do you think about an approach with less code like the next one, this pass the tests you created:
def _run_action_next_activity(self, eval_context=None): | |
if ( | |
not self.activity_type_id | |
or not self._context.get("active_id") | |
or self._is_recompute() | |
): | |
return False | |
records = self.env[self.model_name].browse( | |
self._context.get("active_ids", self._context.get("active_id")) | |
) | |
vals = { | |
"summary": self.activity_summary or "", | |
"note": self.activity_note or "", | |
"activity_type_id": self.activity_type_id.id, | |
} | |
if self.activity_date_deadline_range > 0: | |
vals["date_deadline"] = fields.Date.context_today(self) + relativedelta( | |
**{ | |
self.activity_date_deadline_range_type: self.activity_date_deadline_range | |
} | |
) | |
for record in records: | |
if self.activity_user_type == "team": | |
vals["team_id"] = self.team_id.id | |
vals["user_id"] = self.team_id.user_id.id | |
record.activity_schedule(**vals) | |
else: | |
super()._run_action_next_activity(eval_context=eval_context) | |
return False | |
def _run_action_next_activity(self, eval_context=None): | |
if self.activity_user_type == "team": | |
self = self.with_context(mail_activity_team_id=self.team_id) | |
super()._run_action_next_activity(eval_context) | |
return False | |
def activity_schedule( | |
self, act_type_xmlid="", date_deadline=None, summary="", note="", **act_values | |
): | |
team_id = self.env.context.get("mail_activity_team_id") | |
if team_id: | |
act_values.update({"team_id": team_id.id, "user_id": team_id.user_id.id}) | |
super().activity_schedule( | |
self, act_type_xmlid, date_deadline, summary, note, **act_values | |
) |
cef045f
to
4ffbf89
Compare
4ffbf89
to
ea5fb04
Compare
Hello, this add-on allows the creation of automated actions that generate team activities.
To use this add-on, you just need to change the "Activity User Type" field to "team" and select the group you want to use.