Browse Source

Apr 17 [UPDT] : Bug Fixed 'all_in_one_schedule_activity_management'

pull/278/merge
AjmalCybro 1 year ago
parent
commit
1473cbfd0d
  1. 66
      all_in_one_schedule_activity_management/models/mail_activity.py

66
all_in_one_schedule_activity_management/models/mail_activity.py

@ -46,16 +46,16 @@ class MailActivity(models.Model):
help="state for the activity",
)
active = fields.Boolean("Active", default=True, help="The record make Active")
type = fields.Selection(
[
("overdue", "Overdue"),
("today", "Today"),
("planned", "Planned"),
("done", "Done"),
("cancel", "Cancelled"),
],
help="Type for the activity",
)
# type = fields.Selection(
# [
# ("overdue", "Overdue"),
# ("today", "Today"),
# ("planned", "Planned"),
# ("done", "Done"),
# ("cancel", "Cancelled"),
# ],
# help="Type for the activity",
# )
activity_type = fields.Many2many(
"activity.tag", string="Activity Type", help="Activity type"
)
@ -219,29 +219,29 @@ class MailActivity(models.Model):
return messages, next_activities
@api.model
def _compute_state_from_date(self, date_deadline, tz=False):
"""Compute the state"""
date_deadline = fields.Date.from_string(date_deadline)
today_default = date.today()
today = today_default
if tz:
today_utc = pytz.utc.localize(datetime.utcnow())
today_tz = today_utc.astimezone(pytz.timezone(tz))
today = date(year=today_tz.year, month=today_tz.month, day=today_tz.day)
diff = date_deadline - today
for rec in self:
if rec.state == "done":
return "done"
elif rec.type == "cancel":
return "cancel"
else:
if diff.days == 0:
return "today"
elif diff.days < 0:
return "overdue"
else:
return "planned"
# @api.model
# def _compute_state_from_date(self, date_deadline, tz=False):
# """Compute the state"""
# date_deadline = fields.Date.from_string(date_deadline)
# today_default = date.today()
# today = today_default
# if tz:
# today_utc = pytz.utc.localize(datetime.utcnow())
# today_tz = today_utc.astimezone(pytz.timezone(tz))
# today = date(year=today_tz.year, month=today_tz.month, day=today_tz.day)
# diff = date_deadline - today
# for rec in self:
# if rec.state == "done":
# return "done"
# elif rec.type == "cancel":
# return "cancel"
# else:
# if diff.days == 0:
# return "today"
# elif diff.days < 0:
# return "overdue"
# else:
# return "planned"
def action_cancel(self):
"""cancel activities"""

Loading…
Cancel
Save