Steps to reproduce the bug: - Set the timezone of the user to Australia/Melbourne - Set the country of the company to Australia - Set the time of the system to 20:00 UTC - Have Project and Sales installed - Enable Timesheet and Timesheet Timer on project (A) - Create a task in project (A) - Click Start and then Stop - Confirm the wizard Bug: The date of the new timesheet line is set to yesterday. opw:2351204 Original PR: odoo/enterprise#14023 closes odoo/odoo#59966 X-original-commit: b85a5fc39887660992b5dd0f49ca331e38dd6030 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: backspac <backspac@users.noreply.github.com>
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
from datetime import datetime
|
|
|
|
|
|
class ProjectTaskCreateTimesheet(models.TransientModel):
|
|
_name = 'project.task.create.timesheet'
|
|
_description = "Create Timesheet from task"
|
|
|
|
_sql_constraints = [('time_positive', 'CHECK(time_spent > 0)', 'The timesheet\'s time must be positive' )]
|
|
|
|
time_spent = fields.Float('Time', digits=(16, 2))
|
|
description = fields.Char('Description')
|
|
task_id = fields.Many2one(
|
|
'project.task', "Task", required=True,
|
|
default=lambda self: self.env.context.get('active_id', None),
|
|
help="Task for which we are creating a sales order",
|
|
)
|
|
|
|
def save_timesheet(self):
|
|
values = {
|
|
'task_id': self.task_id.id,
|
|
'project_id': self.task_id.project_id.id,
|
|
'date': fields.Date.context_today(self),
|
|
'name': self.description,
|
|
'user_id': self.env.uid,
|
|
'unit_amount': self.time_spent,
|
|
}
|
|
self.task_id.user_timer_id.unlink()
|
|
return self.env['account.analytic.line'].create(values)
|
|
|
|
def action_delete_timesheet(self):
|
|
self.task_id.user_timer_id.unlink()
|