Skip to content
Snippets Groups Projects
Commit 7d061357 authored by Jason Van Malder's avatar Jason Van Malder
Browse files

[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#41037

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 6f7cbedd
No related branches found
No related tags found
No related merge requests found
......@@ -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):
......@@ -544,9 +545,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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment