Skip to content

Commit

Permalink
[IMP]project_task_recurring_activity: change fields to computed and s…
Browse files Browse the repository at this point in the history
…tored
  • Loading branch information
PicchiSeba committed Sep 26, 2024
1 parent 2c3597b commit ad7d1f2
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions project_task_recurring_activity/models/recurring_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,21 @@ class RecurringActivity(models.Model):
string="Assigned to",
index=True,
required=True,
compute="_compute_on_activity_type_id",
store=True,
readonly=False,
)
summary = fields.Char(
compute="_compute_on_activity_type_id",
store=True,
readonly=False,
)
description = fields.Html(
sanitize_style=True,
compute="_compute_on_activity_type_id",
store=True,
readonly=False,
)
summary = fields.Char()
description = fields.Html(sanitize_style=True)
days_after_task_creation_date = fields.Integer()
next_recurrence_date = fields.Date(
string="next_date", compute="_compute_next_recurrence_date", store=True
Expand Down Expand Up @@ -66,17 +78,14 @@ def _check_user_id(self):
)
)

@api.onchange("activity_type_id")
def _onchange_activity_type_id(self):
self.user_id = (
self.user_id if self.user_id else self.activity_type_id.default_user_id
)
self.description = (
self.activity_type_id.default_description
if not self.description or self.description == "<p><br></p>"
else self.description
)
self.summary = self.summary if self.summary else self.activity_type_id.summary
@api.depends("activity_type_id")
def _compute_on_activity_type_id(self):
if not self.user_id:
self.user_id = self.activity_type_id.default_user_id

Check warning on line 84 in project_task_recurring_activity/models/recurring_activity.py

View check run for this annotation

Codecov / codecov/patch

project_task_recurring_activity/models/recurring_activity.py#L84

Added line #L84 was not covered by tests
if not self.description or self.description == "<p><br></p>":
self.description = self.activity_type_id.default_description

Check warning on line 86 in project_task_recurring_activity/models/recurring_activity.py

View check run for this annotation

Codecov / codecov/patch

project_task_recurring_activity/models/recurring_activity.py#L86

Added line #L86 was not covered by tests
if not self.summary:
self.summary = self.activity_type_id.summary

Check warning on line 88 in project_task_recurring_activity/models/recurring_activity.py

View check run for this annotation

Codecov / codecov/patch

project_task_recurring_activity/models/recurring_activity.py#L88

Added line #L88 was not covered by tests

@api.model
def delta_time(self, old, new):
Expand Down

0 comments on commit ad7d1f2

Please sign in to comment.