fix: accepted warehouse and rejected warehouse can't be same

(cherry picked from commit d618aaef32)

# Conflicts:
#	erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
#	erpnext/stock/doctype/purchase_receipt/purchase_receipt.json
#	erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json
#	erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json
This commit is contained in:
Rohit Waghchaure
2023-07-04 17:26:48 +05:30
committed by Mergify
parent 0f9a6ee70a
commit 5d77e3ce05
9 changed files with 58 additions and 12 deletions

View File

@@ -410,18 +410,23 @@ class BuyingController(SubcontractingController):
# validate rate with ref PR
def validate_rejected_warehouse(self):
for d in self.get("items"):
if flt(d.rejected_qty) and not d.rejected_warehouse:
for item in self.get("items"):
if flt(item.rejected_qty) and not item.rejected_warehouse:
if self.rejected_warehouse:
d.rejected_warehouse = self.rejected_warehouse
item.rejected_warehouse = self.rejected_warehouse
if not d.rejected_warehouse:
if not item.rejected_warehouse:
frappe.throw(
_("Row #{0}: Rejected Warehouse is mandatory against rejected Item {1}").format(
d.idx, d.item_code
_("Row #{0}: Rejected Warehouse is mandatory for the rejected Item {1}").format(
item.idx, item.item_code
)
)
if item.get("rejected_warehouse") and (item.get("rejected_warehouse") == item.get("warehouse")):
frappe.throw(
_("Row #{0}: Accepted Warehouse and Rejected Warehouse cannot be same").format(item.idx)
)
# validate accepted and rejected qty
def validate_accepted_rejected_qty(self):
for d in self.get("items"):