Merge pull request #3627 from nabinhait/fix2
PP Tool: Create production order if applicable for item
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index 0bf014b..5de43a0 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -203,7 +203,7 @@
frappe.throw(_("Due Date cannot be before Posting Date"))
else:
default_due_date = get_due_date(posting_date, party_type, party, company)
- if getdate(due_date) > getdate(default_due_date):
+ if default_due_date != posting_date and getdate(due_date) > getdate(default_due_date):
is_credit_controller = frappe.db.get_single_value("Accounts Settings", "credit_controller") in frappe.get_roles()
if is_credit_controller:
msgprint(_("Note: Due / Reference Date exceeds allowed customer credit days by {0} day(s)")
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 93fd325..c3597e3 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -730,8 +730,10 @@
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
for item in self.get("items"):
if item.batch_no:
- if getdate(self.posting_date) > getdate(frappe.db.get_value("Batch", item.batch_no, "expiry_date")):
- frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
+ expiry_date = frappe.db.get_value("Batch", item.batch_no, "expiry_date")
+ if expiry_date:
+ if getdate(self.posting_date) > getdate(expiry_date):
+ frappe.throw(_("Batch {0} of Item {1} has expired.").format(item.batch_no, item.item_code))
@frappe.whitelist()
def get_party_details(ref_dt, ref_dn):
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index de6b3a6..ff027d7 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -18,6 +18,7 @@
from erpnext.stock.utils import validate_warehouse_company
self.validate_mandatory()
self.validate_item()
+ self.validate_batch()
validate_warehouse_company(self.warehouse, self.company)
self.scrub_posting_time()
@@ -96,6 +97,13 @@
def scrub_posting_time(self):
if not self.posting_time or self.posting_time == '00:0':
self.posting_time = '00:00'
+
+ def validate_batch(self):
+ if self.batch_no and self.voucher_type != "Stock Entry":
+ expiry_date = frappe.db.get_value("Batch", self.batch_no, "expiry_date")
+ if expiry_date:
+ if getdate(self.posting_date) > getdate(expiry_date):
+ frappe.throw(_("Batch {0} of Item {1} has expired.").format(self.batch_no, self.item_code))
def on_doctype_update():
if not frappe.db.sql("""show index from `tabStock Ledger Entry`