mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-24 05:32:46 +01:00
fix: ignore Stock Reservation for future dated PR
(cherry picked from commit 33eedb97dc)
Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from frappe import _, throw
|
|||||||
from frappe.desk.notifications import clear_doctype_notifications
|
from frappe.desk.notifications import clear_doctype_notifications
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.query_builder.functions import CombineDatetime
|
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
|
from pypika import functions as fn
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
@@ -829,8 +829,12 @@ class PurchaseReceipt(BuyingController):
|
|||||||
update_billing_percentage(pr_doc, update_modified=update_modified)
|
update_billing_percentage(pr_doc, update_modified=update_modified)
|
||||||
|
|
||||||
def reserve_stock_for_sales_order(self):
|
def reserve_stock_for_sales_order(self):
|
||||||
if self.is_return or not cint(
|
if (
|
||||||
frappe.db.get_single_value("Stock Settings", "auto_reserve_stock_for_sales_order_on_purchase")
|
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
|
return
|
||||||
|
|
||||||
@@ -851,6 +855,11 @@ class PurchaseReceipt(BuyingController):
|
|||||||
so_items_details_map.setdefault(item.sales_order, []).append(item_details)
|
so_items_details_map.setdefault(item.sales_order, []).append(item_details)
|
||||||
|
|
||||||
if so_items_details_map:
|
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():
|
for so, items_details in so_items_details_map.items():
|
||||||
so_doc = frappe.get_doc("Sales Order", so)
|
so_doc = frappe.get_doc("Sales Order", so)
|
||||||
so_doc.create_stock_reservation_entries(
|
so_doc.create_stock_reservation_entries(
|
||||||
|
|||||||
Reference in New Issue
Block a user