fix: ignore Stock Reservation for future dated PR (cherry picked from commit 33eedb97dcb531cc8e14813d742266f2c5168fac) Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
parent
0e979b6c5b
commit
d74f0ef586
@ -7,7 +7,7 @@ from frappe import _, throw
|
||||
from frappe.desk.notifications import clear_doctype_notifications
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.query_builder.functions import CombineDatetime
|
||||
from frappe.utils import cint, flt, getdate, nowdate
|
||||
from frappe.utils import cint, flt, get_datetime, getdate, nowdate
|
||||
from pypika import functions as fn
|
||||
|
||||
import erpnext
|
||||
@ -829,8 +829,12 @@ class PurchaseReceipt(BuyingController):
|
||||
update_billing_percentage(pr_doc, update_modified=update_modified)
|
||||
|
||||
def reserve_stock_for_sales_order(self):
|
||||
if self.is_return or not cint(
|
||||
frappe.db.get_single_value("Stock Settings", "auto_reserve_stock_for_sales_order_on_purchase")
|
||||
if (
|
||||
self.is_return
|
||||
or not frappe.db.get_single_value("Stock Settings", "enable_stock_reservation")
|
||||
or not frappe.db.get_single_value(
|
||||
"Stock Settings", "auto_reserve_stock_for_sales_order_on_purchase"
|
||||
)
|
||||
):
|
||||
return
|
||||
|
||||
@ -851,6 +855,11 @@ class PurchaseReceipt(BuyingController):
|
||||
so_items_details_map.setdefault(item.sales_order, []).append(item_details)
|
||||
|
||||
if so_items_details_map:
|
||||
if get_datetime("{} {}".format(self.posting_date, self.posting_time)) > get_datetime():
|
||||
return frappe.msgprint(
|
||||
_("Cannot create Stock Reservation Entries for future dated Purchase Receipts.")
|
||||
)
|
||||
|
||||
for so, items_details in so_items_details_map.items():
|
||||
so_doc = frappe.get_doc("Sales Order", so)
|
||||
so_doc.create_stock_reservation_entries(
|
||||
|
Loading…
x
Reference in New Issue
Block a user