[IMP] Set workorder in analytic.line related with a task from a work order

This commit is contained in:
Antonio Espinosa
2016-02-17 15:50:04 +01:00
parent cfb78dda17
commit 9ce244819c
3 changed files with 12 additions and 2 deletions

View File

@@ -6,10 +6,11 @@
{
"name": "MRP Project Link",
"summary": "Link production with projects",
"version": "8.0.1.1.0",
"version": "8.0.1.1.1",
"depends": [
"mrp_analytic",
"project",
"project_timesheet",
],
'license': 'AGPL-3',
"images": [],

View File

@@ -10,7 +10,10 @@ class HrAnalyticTimesheet(models.Model):
@api.model
def create(self, vals):
production = self._context.get('production', False)
production = self.env.context.get('production', False)
workorder = self.env.context.get('workorder', False)
vals['mrp_production_id'] = vals.get(
'mrp_production_id', False) or production and production.id
vals['workorder'] = vals.get(
'workorder', False) or workorder and workorder.id
return super(HrAnalyticTimesheet, self).create(vals)

View File

@@ -28,3 +28,9 @@ class ProjectTaskWork(models.Model):
task = self.env['project.task'].browse(task_id)
res['value'] = {'user_id': task.user_id.id}
return res
@api.model
def _create_analytic_entries(self, vals):
task = self.env['project.task'].browse(vals.get('task_id', False))
return super(ProjectTaskWork, self.with_context(
workorder=task.workorder))._create_analytic_entries(vals)