From d58d1b5a1867d141c06a8a596c0c1b69e6856ad4 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 26 Apr 2013 17:25:44 +0530 Subject: [PATCH] validation for stock and nonstock items in purchase cycle --- controllers/buying_controller.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index 94e3d56ddc..e167dc57b7 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -45,12 +45,13 @@ class BuyingController(StockController): def validate_stock_or_nonstock_items(self): items = [d.item_code for d in self.doclist.get({"parentfield": self.fname})] - if self.stock_items and len(items) > len(self.stock_items): + if self.stock_items: nonstock_items = list(set(items) - set(self.stock_items)) - webnotes.msgprint(_("Stock and non-stock items can not be entered in the same ") + - self.doc.doctype + _(""". You should make separate documents for them. - Stock Items: """) + ", ".join(self.stock_items) + _(""" - Non-stock Items: """) + ", ".join(nonstock_items), raise_exception=1) + if nonstock_items: + webnotes.msgprint(_("Stock and non-stock items can not be entered in the same ") + + self.doc.doctype + _(""". You should make separate documents for them. + Stock Items: """) + ", ".join(self.stock_items) + _(""" + Non-stock Items: """) + ", ".join(nonstock_items), raise_exception=1) elif items and not self.stock_items: tax_for_valuation = [d.account_head for d in