Merge pull request #5833 from nabinhait/fix_108

Validate warehouse if update stock checked in Purchase Invoice
This commit is contained in:
Nabin Hait 2016-07-22 13:21:43 +05:30 committed by GitHub
commit 13e248af8d

View File

@ -147,6 +147,14 @@ class PurchaseInvoice(BuyingController):
["Purchase Receipt", "purchase_receipt", "pr_detail"]
])
def validate_warehouse(self):
if self.update_stock:
for d in self.get('items'):
if not d.warehouse:
frappe.throw(_("Warehouse required at Row No {0}").format(d.idx))
super(PurchaseInvoice, self).validate_warehouse()
def set_expense_account(self):
auto_accounting_for_stock = cint(frappe.defaults.get_global_default("auto_accounting_for_stock"))
@ -155,6 +163,7 @@ class PurchaseInvoice(BuyingController):
stock_items = self.get_stock_items()
if self.update_stock:
self.validate_warehouse()
warehouse_account = get_warehouse_account()
for item in self.get("items"):