[FIX] project: fix crash when no language selected
Reproduce the issue
- Select a language (done by default)
- Install Project
- Create a project
- Create a task with a formatted date
- Reset the language
- Go on the project
Traceback
Cause
In 7e42c663, I format the date_deadline based on the user's language
but did'nt know that we could have no language selected.
This commit uses the `format_date` method from `odoo.tools.misc`
which fallback on the first language installed if there is no
language selected.
OPW-2146479
closes odoo/odoo#41057
X-original-commit: 7d06135712b6646816b0558a63e55bc10622e59c
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from datetime import timedelta
|
||||
from odoo import api, fields, models, tools, SUPERUSER_ID, _
|
||||
from odoo.exceptions import UserError, AccessError, ValidationError
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.tools.misc import format_date
|
||||
|
||||
|
||||
class ProjectTaskType(models.Model):
|
||||
@@ -532,9 +533,8 @@ class Task(models.Model):
|
||||
|
||||
@api.depends('date_deadline')
|
||||
def _compute_date_deadline_formatted(self):
|
||||
date_format = self.env['res.lang']._lang_get(self.env.user.lang).date_format
|
||||
for task in self:
|
||||
task.date_deadline_formatted = task.date_deadline.strftime(date_format) if task.date_deadline else None
|
||||
task.date_deadline_formatted = format_date(self.env, task.date_deadline) if task.date_deadline else None
|
||||
|
||||
def _compute_attachment_ids(self):
|
||||
for task in self:
|
||||
|
||||
Reference in New Issue
Block a user