Merge pull request #94 from Antiun/imp-mrp_project_analytic_line

[8.0][IMP][mrp_project] Set workorder in analytic.line related with a task from a work order
This commit is contained in:
Pedro M. Baeza
2016-02-18 14:43:11 +01:00
4 changed files with 15 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ Contributors
* Daniel Campos <danielcampos@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Antonio Espinosa <antonioea@antiun.com>
Maintainer
----------

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.2.0",
"depends": [
"mrp_analytic",
"project",
"project_timesheet",
],
'license': 'AGPL-3',
"images": [],

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# (c) 2016 Daniel Dico <dd@oerp.ca>
# (c) 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, api
@@ -10,7 +11,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

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# (c) 2015 Pedro M. Baeza - Serv. Tecnol. Avanzados
# (c) 2016 Antiun Ingenieria S.L. - Antonio Espinosa
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api
@@ -28,3 +29,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)