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

Loading…
Cancel
Save