Raise an exception if product already has a route assigned.

This commit is contained in:
Albert Cervera i Areny 2014-04-10 00:41:37 +02:00
parent e832aa1590
commit 59652c8666
1 changed files with 5 additions and 0 deletions

View File

@ -178,6 +178,8 @@ class Plan:
cls._error_messages.update({
'route_already_exists': ('A route already exists for cost plan '
'"%s".'),
'product_already_has_route': ('Product "%s" already has a '
'route assigned.'),
})
@classmethod
@ -271,6 +273,9 @@ class Plan:
ProductBOM()
if self.product.boms:
product_bom = self.product.boms[0]
if product_bom.route:
self.raise_user_error('product_already_has_route',
self.product.rec_name)
else:
product_bom = ProductBOM()
product_bom.product = self.product