diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json index 5a08f045b8c..dfc4f3c9215 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json @@ -547,6 +547,7 @@ "depends_on": "update_stock", "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "no_copy": 1, "options": "Warehouse", @@ -1573,7 +1574,11 @@ "idx": 204, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2023-04-29 12:57:50.832598", +======= + "modified": "2023-07-04 17:22:59.145031", +>>>>>>> d618aaef32 (fix: accepted warehouse and rejected warehouse can't be same) "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice", diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index f8c1975863e..92db6b61bb9 100644 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -421,6 +421,7 @@ { "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "options": "Warehouse" }, @@ -881,7 +882,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2023-07-02 18:39:41.495723", + "modified": "2023-07-04 17:22:21.501152", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index 04636de6406..fa94a4a88d4 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -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"): diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json index dc61ec4d243..e1f084e0932 100755 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.json @@ -437,6 +437,7 @@ { "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "no_copy": 1, "oldfieldname": "rejected_warehouse", @@ -1239,7 +1240,11 @@ "idx": 261, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2023-05-07 20:18:25.458185", +======= + "modified": "2023-07-04 17:23:17.025390", +>>>>>>> d618aaef32 (fix: accepted warehouse and rejected warehouse can't be same) "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt", diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index 4743f3a4d7f..c87b3587fec 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -323,6 +323,15 @@ class TestPurchaseReceipt(FrappeTestCase): pr.cancel() self.assertFalse(frappe.db.get_value("Serial No", pr_row_1_serial_no, "warehouse")) + def test_rejected_warehouse_filter(self): + pr = frappe.copy_doc(test_records[0]) + pr.get("items")[0].item_code = "_Test Serialized Item With Series" + pr.get("items")[0].qty = 3 + pr.get("items")[0].rejected_qty = 2 + pr.get("items")[0].received_qty = 5 + pr.get("items")[0].rejected_warehouse = pr.get("items")[0].warehouse + self.assertRaises(frappe.ValidationError, pr.save) + def test_rejected_serial_no(self): pr = frappe.copy_doc(test_records[0]) pr.get("items")[0].item_code = "_Test Serialized Item With Series" diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index 98d6154f22e..76f476edf8a 100644 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -495,6 +495,7 @@ { "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "no_copy": 1, "oldfieldname": "rejected_warehouse", @@ -1022,7 +1023,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2023-07-02 18:40:48.152637", + "modified": "2023-07-04 17:22:02.830029", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json index 3385eac0528..e722c178782 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.json @@ -250,6 +250,7 @@ "description": "Sets 'Rejected Warehouse' in each row of the Items table.", "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "no_copy": 1, "options": "Warehouse", @@ -629,7 +630,11 @@ "in_create": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-11-16 14:18:57.001239", +======= + "modified": "2023-07-06 18:43:16.171842", +>>>>>>> d618aaef32 (fix: accepted warehouse and rejected warehouse can't be same) "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt", diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index 416f4f80a21..ecec73e265c 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -190,13 +190,23 @@ class SubcontractingReceipt(SubcontractingController): self.total = total_amount def validate_rejected_warehouse(self): - if not self.rejected_warehouse: - for item in self.items: - if item.rejected_qty: + for item in self.items: + if flt(item.rejected_qty) and not item.rejected_warehouse: + if self.rejected_warehouse: + item.rejected_warehouse = self.rejected_warehouse + + if not item.rejected_warehouse: frappe.throw( - _("Rejected Warehouse is mandatory against rejected Item {0}").format(item.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) + ) + def validate_available_qty_for_consumption(self): for item in self.get("supplied_items"): precision = item.precision("consumed_qty") diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json b/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json index 4b64e4bafee..7e8415a7ebf 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json +++ b/erpnext/subcontracting/doctype/subcontracting_receipt_item/subcontracting_receipt_item.json @@ -252,6 +252,7 @@ "depends_on": "eval: !parent.is_return", "fieldname": "rejected_warehouse", "fieldtype": "Link", + "ignore_user_permissions": 1, "label": "Rejected Warehouse", "no_copy": 1, "options": "Warehouse", @@ -476,7 +477,11 @@ "idx": 1, "istable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-11-16 14:21:26.125815", +======= + "modified": "2023-07-06 18:43:45.599761", +>>>>>>> d618aaef32 (fix: accepted warehouse and rejected warehouse can't be same) "modified_by": "Administrator", "module": "Subcontracting", "name": "Subcontracting Receipt Item",