Merge pull request #120 from Antiun/imp-mrp_project_analytic_parent

[8.0][IMP][mrp_project] If production come from a sale order, set project parent
This commit is contained in:
Pedro M. Baeza
2016-04-25 17:28:32 +02:00

View File

@@ -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