Skip to content
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

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

adasatorres
Copy link

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.

@adasatorres adasatorres force-pushed the 14.0-add-base_automation_team_activity branch 3 times, most recently from b985275 to 8f186a5 Compare October 21, 2024 13:46
Copy link

@sheragar sheragar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Funtional Review 👍

Comment on lines 26 to 57
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

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:

Suggested change
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
)

@adasatorres adasatorres force-pushed the 14.0-add-base_automation_team_activity branch 5 times, most recently from cef045f to 4ffbf89 Compare October 22, 2024 06:41
@adasatorres adasatorres force-pushed the 14.0-add-base_automation_team_activity branch from 4ffbf89 to ea5fb04 Compare October 22, 2024 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants