Merge pull request #40721 from frappe/mergify/bp/version-14-hotfix/pr-40718
fix: do not fetch received items in purchase receipt (backport #40718)
This commit is contained in:
@@ -669,7 +669,7 @@ class StockController(AccountsController):
|
||||
self.validate_multi_currency()
|
||||
self.validate_packed_items()
|
||||
|
||||
if self.get("is_internal_supplier"):
|
||||
if self.get("is_internal_supplier") and self.docstatus == 1:
|
||||
self.validate_internal_transfer_qty()
|
||||
else:
|
||||
self.validate_internal_transfer_warehouse()
|
||||
|
||||
@@ -965,6 +965,9 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
||||
for tax in get_taxes_and_charges(master_doctype, target.get("taxes_and_charges")):
|
||||
target.append("taxes", tax)
|
||||
|
||||
if not target.get("items"):
|
||||
frappe.throw(_("All items have already been received"))
|
||||
|
||||
def update_details(source_doc, target_doc, source_parent):
|
||||
target_doc.inter_company_invoice_reference = source_doc.name
|
||||
if target_doc.doctype == "Purchase Receipt":
|
||||
@@ -1020,6 +1023,10 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
||||
shipping_address_name=target_doc.shipping_address_name,
|
||||
)
|
||||
|
||||
def update_item(source, target, source_parent):
|
||||
if source_parent.doctype == "Delivery Note" and source.received_qty:
|
||||
target.qty = flt(source.qty) + flt(source.returned_qty) - flt(source.received_qty)
|
||||
|
||||
doclist = get_mapped_doc(
|
||||
doctype,
|
||||
source_name,
|
||||
@@ -1043,6 +1050,8 @@ def make_inter_company_transaction(doctype, source_name, target_doc=None):
|
||||
"Material_request_item": "material_request_item",
|
||||
},
|
||||
"field_no_map": ["warehouse"],
|
||||
"condition": lambda item: item.received_qty < item.qty + item.returned_qty,
|
||||
"postprocess": update_item,
|
||||
},
|
||||
},
|
||||
target_doc,
|
||||
|
||||
Reference in New Issue
Block a user