summaryrefslogtreecommitdiff
path: root/addons/hr_timesheet/models/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/hr_timesheet/models/project.py')
-rw-r--r--addons/hr_timesheet/models/project.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py
index 37534b1194c..1a5ddfa0b61 100644
--- a/addons/hr_timesheet/models/project.py
+++ b/addons/hr_timesheet/models/project.py
@@ -9,7 +9,7 @@ class Project(models.Model):
_inherit = "project.project"
allow_timesheets = fields.Boolean("Allow timesheets", default=True)
- analytic_account_id = fields.Many2one('account.analytic.account', string="Analytic Account", ondelete='set null',
+ analytic_account_id = fields.Many2one('account.analytic.account', string="Analytic Account", copy=False, ondelete='set null',
help="Link this project to an analytic account if you need financial management on projects. "
"It enables you to connect projects with budgets, planning, cost and revenue analysis, timesheets on projects, etc.")
@@ -154,8 +154,10 @@ class Task(models.Model):
# a timesheet must have an analytic account (and a project)
if self and not project_id:
raise UserError(_('This task must be part of a project because they some timesheets are linked to it.'))
+ account_id = self.env['project.project'].browse(project_id).sudo().analytic_account_id
self.sudo().mapped('timesheet_ids').write({
'project_id': project_id,
- 'account_id': self.env['project.project'].browse(project_id).sudo().analytic_account_id.id
+ 'account_id': account_id.id,
+ 'company_id': account_id.company_id.id,
})
return result