Link created bom with the product.

This commit is contained in:
Albert Cervera i Areny 2014-04-10 00:18:25 +02:00
parent d11c0bc84b
commit 6667493d34
1 changed files with 12 additions and 1 deletions

13
plan.py
View File

@ -331,7 +331,9 @@ class Plan(ModelSQL, ModelView):
super(Plan, cls).delete(plans)
def create_bom(self, name):
BOM = Pool().get('production.bom')
pool = Pool()
BOM = pool.get('production.bom')
ProductBOM = pool.get('product.product-production.bom')
if self.bom:
self.raise_user_error('bom_already_exists', self.rec_name)
bom = BOM()
@ -341,6 +343,15 @@ class Plan(ModelSQL, ModelView):
bom.save()
self.bom = bom
self.save()
ProductBOM()
if self.product.boms:
product_bom = self.product.boms[0]
else:
product_bom = ProductBOM()
product_bom.product = self.product
product_bom.bom = bom
product_bom.save()
return bom
def _get_bom_outputs(self):