fix: patch and validation message to fix target warehouse issue (#21371)

This commit is contained in:
rohitwaghchaure
2020-04-23 09:46:29 +05:30
committed by GitHub
parent e8a651bc00
commit 6fa6caf46c
3 changed files with 81 additions and 0 deletions

View File

@@ -46,6 +46,7 @@ class SellingController(StockController):
set_default_income_account_for_item(self)
self.set_customer_address()
self.validate_for_duplicate_items()
self.validate_target_warehouse()
def set_missing_values(self, for_validate=False):
@@ -403,6 +404,14 @@ class SellingController(StockController):
else:
chk_dupl_itm.append(f)
def validate_target_warehouse(self):
items = self.get("items") + (self.get("packed_items") or [])
for d in items:
if d.get("target_warehouse") and d.get("warehouse") == d.get("target_warehouse"):
warehouse = frappe.bold(d.get("target_warehouse"))
frappe.throw(_("Row {0}: Delivery Warehouse ({1}) and Customer Warehouse ({2}) can not be same")
.format(d.idx, warehouse, warehouse))
def validate_items(self):
# validate items to see if they have is_sales_item enabled