Fixed FSM work orders printing with UTC times
This commit is contained in:
parent
67fcffb37a
commit
b90466786d
2 changed files with 32 additions and 7 deletions
|
|
@ -3,10 +3,31 @@ from odoo.addons.project.models.project_task import CLOSED_STATES
|
|||
import re
|
||||
|
||||
|
||||
import pytz
|
||||
|
||||
class Task(models.Model):
|
||||
_inherit = ["project.task", "durpro.tag.inheritance.mixin"]
|
||||
_name = "project.task"
|
||||
|
||||
planned_date_begin_est = fields.Datetime(compute="_compute_est_dates", string="Planned Start (EST)")
|
||||
date_deadline_est = fields.Datetime(compute="_compute_est_dates", string="Planned End (EST)")
|
||||
|
||||
def _get_est_datetime(self, dt):
|
||||
if not dt:
|
||||
return False
|
||||
user_tz = pytz.timezone('America/Toronto')
|
||||
if not dt.tzinfo:
|
||||
dt = fields.Datetime.from_string(str(dt))
|
||||
dt = fields.Datetime.context_timestamp(self, dt)
|
||||
dt_est = dt.astimezone(user_tz)
|
||||
# Return naive datetime in EST (strip tzinfo)
|
||||
return dt_est.replace(tzinfo=None)
|
||||
|
||||
def _compute_est_dates(self):
|
||||
for rec in self:
|
||||
rec.planned_date_begin_est = rec._get_est_datetime(rec.planned_date_begin)
|
||||
rec.date_deadline_est = rec._get_est_datetime(rec.date_deadline)
|
||||
|
||||
work_order_contacts = fields.Many2many(
|
||||
comodel_name="res.partner",
|
||||
relation="task_work_order_contact_rel",
|
||||
|
|
|
|||
|
|
@ -361,13 +361,17 @@
|
|||
t-if="doc.planned_date_begin or doc.date_deadline"
|
||||
>
|
||||
<div t-if="doc.planned_date_begin"><h6>Planned start: </h6></div>
|
||||
<div class="mb-3">
|
||||
<div t-out="doc.planned_date_begin.strftime('%Y-%m-%d %H:%M')" />
|
||||
</div>
|
||||
<div t-if="doc.date_deadline"><h6>Planned end: </h6></div>
|
||||
<div class="mb-3">
|
||||
<div t-out="doc.date_deadline.strftime('%Y-%m-%d %H:%M')" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div>
|
||||
<span t-esc="doc.planned_date_begin_est and doc.planned_date_begin_est.strftime('%Y-%m-%d %H:%M')" />
|
||||
</div>
|
||||
</div>
|
||||
<div t-if="doc.date_deadline"><h6>Planned end: </h6></div>
|
||||
<div class="mb-3">
|
||||
<div>
|
||||
<span t-esc="doc.date_deadline_est and doc.date_deadline_est.strftime('%Y-%m-%d %H:%M')" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" name="site_and_work_order_contacts">
|
||||
|
|
|
|||
Loading…
Reference in a new issue