mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 16:04:46 +00:00
Disallowed End of Life Items from getting selected in Production Orders and Stock Reconciliation
This commit is contained in:
@@ -262,7 +262,8 @@ cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
|||||||
return {
|
return {
|
||||||
filters:[
|
filters:[
|
||||||
['Item', 'is_pro_applicable', '=', 'Yes'],
|
['Item', 'is_pro_applicable', '=', 'Yes'],
|
||||||
['Item', 'has_variants', '=', 'No']
|
['Item', 'has_variants', '=', 'No'],
|
||||||
|
['Item', 'end_of_life', '>', frappe.datetime.now_datetime()]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ from frappe import _
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
|
from erpnext.manufacturing.doctype.bom.bom import validate_bom_no
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
|
from erpnext.stock.doctype.item.item import validate_end_of_life
|
||||||
|
|
||||||
class OverProductionError(frappe.ValidationError): pass
|
class OverProductionError(frappe.ValidationError): pass
|
||||||
class StockOverProductionError(frappe.ValidationError): pass
|
class StockOverProductionError(frappe.ValidationError): pass
|
||||||
@@ -329,6 +330,8 @@ class ProductionOrder(Document):
|
|||||||
|
|
||||||
if frappe.db.get_value("Item", self.production_item, "has_variants"):
|
if frappe.db.get_value("Item", self.production_item, "has_variants"):
|
||||||
frappe.throw(_("Production Order cannot be raised against a Item Template"))
|
frappe.throw(_("Production Order cannot be raised against a Item Template"))
|
||||||
|
|
||||||
|
validate_end_of_life(self.production_item)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_item_details(item):
|
def get_item_details(item):
|
||||||
|
|||||||
@@ -135,6 +135,12 @@ class TestProductionOrder(unittest.TestCase):
|
|||||||
prod_order.set_production_order_operations()
|
prod_order.set_production_order_operations()
|
||||||
self.assertEqual(prod_order.planned_operating_cost, cost*2)
|
self.assertEqual(prod_order.planned_operating_cost, cost*2)
|
||||||
|
|
||||||
|
def test_production_item(self):
|
||||||
|
item = frappe.get_doc("Item", "_Test FG Item")
|
||||||
|
item.end_of_life =
|
||||||
|
|
||||||
|
prod_order = make_prod_order_test_record(item="_Test FG Item", qty=1, do_not_save=True)
|
||||||
|
|
||||||
def make_prod_order_test_record(**args):
|
def make_prod_order_test_record(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
|
|||||||
@@ -98,3 +98,11 @@ cur_frm.cscript.company = function(doc, cdt, cdn) {
|
|||||||
cur_frm.cscript.posting_date = function(doc, cdt, cdn){
|
cur_frm.cscript.posting_date = function(doc, cdt, cdn){
|
||||||
erpnext.get_fiscal_year(doc.company, doc.posting_date);
|
erpnext.get_fiscal_year(doc.company, doc.posting_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict.items.grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
|
||||||
|
return {
|
||||||
|
filters:[
|
||||||
|
['Item', 'end_of_life', '>', frappe.datetime.now_datetime()]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user