From e27603acf3a088447527afbc09d9e6ed1d2362ca Mon Sep 17 00:00:00 2001 From: Antonio Espinosa Date: Fri, 22 Apr 2016 22:01:11 +0200 Subject: [PATCH] [IMP] If production come from a sale order, set project parent --- mrp_project/models/mrp_production.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mrp_project/models/mrp_production.py b/mrp_project/models/mrp_production.py index 5d68300b5..bee26761d 100644 --- a/mrp_project/models/mrp_production.py +++ b/mrp_project/models/mrp_production.py @@ -17,10 +17,17 @@ class MrpProduction(models.Model): @api.model def _prepare_project_vals(self, production): + # If this production come from a sale order and that order + # has an analytic account assigned, then project is child of + # that analytic account + parent_id = False + if 'sale_id' in production._fields: + parent_id = production.sale_id.project_id.id return { 'name': production.name, 'use_tasks': True, 'automatic_creation': True, + 'parent_id': parent_id, } @api.model