Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove from or target warehouse for non internal transfer entries #37612

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions erpnext/controllers/stock_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,21 @@ def set_rate_of_stock_uom(self):
d.stock_uom_rate = d.rate / (d.conversion_factor or 1)

def validate_internal_transfer(self):
if (
self.doctype in ("Sales Invoice", "Delivery Note", "Purchase Invoice", "Purchase Receipt")
and self.is_internal_transfer()
):
self.validate_in_transit_warehouses()
self.validate_multi_currency()
self.validate_packed_items()
if self.doctype in ("Sales Invoice", "Delivery Note", "Purchase Invoice", "Purchase Receipt"):
if self.is_internal_transfer():
self.validate_in_transit_warehouses()
self.validate_multi_currency()
self.validate_packed_items()
else:
self.validate_internal_transfer_warehouse()

def validate_internal_transfer_warehouse(self):
for row in self.items:
if row.get("target_warehouse"):
row.target_warehouse = None

if row.get("from_warehouse"):
row.from_warehouse = None

def validate_in_transit_warehouses(self):
if (
Expand Down
15 changes: 15 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,21 @@ def tearDown(self):
frappe.db.rollback()
frappe.db.set_single_value("Selling Settings", "dont_reserve_sales_order_qty_on_sales_return", 0)

def non_internal_transfer_delivery_note(self):
rohitwaghchaure marked this conversation as resolved.
Show resolved Hide resolved
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse

dn = create_delivery_note(do_not_submit=True)
warehouse = create_warehouse("Internal Transfer Warehouse", dn.company)
dn.items[0].db_set("target_warehouse", "warehouse")

dn.reload()

self.assertEqual(dn.items[0].target_warehouse, warehouse.name)

dn.save()
dn.reload()
self.assertFalse(dn.items[0].target_warehouse)


def create_delivery_note(**args):
dn = frappe.new_doc("Delivery Note")
Expand Down
15 changes: 15 additions & 0 deletions erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,21 @@ def test_purchase_return_with_zero_rate(self):
for entry in gl_entries:
self.assertEqual(abs(entry.debit + entry.credit), abs(sl_entries[0].stock_value_difference))

def non_internal_transfer_purchase_receipt(self):
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse

pr_doc = make_purchase_receipt(do_not_submit=True)
warehouse = create_warehouse("Internal Transfer Warehouse", pr_doc.company)
pr_doc.items[0].db_set("target_warehouse", "warehouse")

pr_doc.reload()

self.assertEqual(pr_doc.items[0].from_warehouse, warehouse.name)

pr_doc.save()
pr_doc.reload()
self.assertFalse(pr_doc.items[0].from_warehouse)


def prepare_data_for_internal_transfer():
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier
Expand Down
Loading