Skip to content

Commit

Permalink
fix: Blanket Order Ordered Quantity (backport #39725) (#39738)
Browse files Browse the repository at this point in the history
* fix: disable no-copy for blanket order in PO

(cherry picked from commit 5ce5c35)

# Conflicts:
#	erpnext/buying/doctype/purchase_order_item/purchase_order_item.json

* fix: update BO Ordered Quantity on PO Close/Open

(cherry picked from commit 61ded69)

# Conflicts:
#	erpnext/buying/doctype/purchase_order/purchase_order.py

* test: BO on PO Close/Open

(cherry picked from commit 27d6c8b)

* chore: `conflicts`

---------

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
  • Loading branch information
mergify[bot] and s-aga-r authored Feb 5, 2024
1 parent 46ac4f4 commit 44c09de
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def update_status(self, status):
self.update_requested_qty()
self.update_ordered_qty()
self.update_reserved_qty_for_subcontract()
self.update_blanket_order()
self.notify_update()
clear_doctype_notifications(self)

Expand Down
25 changes: 25 additions & 0 deletions erpnext/buying/doctype/purchase_order/test_purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,30 @@ def test_po_optional_blanket_order(self):
# To test if the PO does NOT have a Blanket Order
self.assertEqual(po_doc.items[0].blanket_order, None)

def test_blanket_order_on_po_close_and_open(self):
# Step - 1: Create Blanket Order
bo = make_blanket_order(blanket_order_type="Purchasing", quantity=10, rate=10)

# Step - 2: Create Purchase Order
po = create_purchase_order(
item_code="_Test Item", qty=5, against_blanket_order=1, against_blanket=bo.name
)

bo.load_from_db()
self.assertEqual(bo.items[0].ordered_qty, 5)

# Step - 3: Close Purchase Order
po.update_status("Closed")

bo.load_from_db()
self.assertEqual(bo.items[0].ordered_qty, 0)

# Step - 4: Re-Open Purchase Order
po.update_status("Re-open")

bo.load_from_db()
self.assertEqual(bo.items[0].ordered_qty, 5)

def test_payment_terms_are_fetched_when_creating_purchase_invoice(self):
from erpnext.accounts.doctype.payment_entry.test_payment_entry import (
create_payment_terms_template,
Expand Down Expand Up @@ -1016,6 +1040,7 @@ def create_purchase_order(**args):
"schedule_date": add_days(nowdate(), 1),
"include_exploded_items": args.get("include_exploded_items", 1),
"against_blanket_order": args.against_blanket_order,
"against_blanket": args.against_blanket,
"material_request": args.material_request,
"material_request_item": args.material_request_item,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,13 @@
"fieldname": "blanket_order",
"fieldtype": "Link",
"label": "Blanket Order",
"no_copy": 1,
"options": "Blanket Order"
},
{
"depends_on": "eval:doc.against_blanket_order",
"fieldname": "blanket_order_rate",
"fieldtype": "Currency",
"label": "Blanket Order Rate",
"no_copy": 1,
"print_hide": 1,
"read_only": 1
},
Expand Down Expand Up @@ -918,7 +916,7 @@
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2023-11-24 19:07:34.921094",
"modified": "2024-02-05 11:23:24.859435",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order Item",
Expand Down

0 comments on commit 44c09de

Please sign in to comment.