fix: add validation for 'for_qty' else throws errors (#25829)
* fix: add validation for 'for_qty' else throws errors * fix: check if for_qty is None * fix: check purpose * fix: add purpose to pick list get_doc * fix: set as read only to prevent se from picking up value Co-authored-by: Ankush <ankushmenat@gmail.com> * chore: undo changes to doctype modified timestamp Co-authored-by: Ankush <ankushmenat@gmail.com>
This commit is contained in:
parent
21e44b19f0
commit
8958f55890
@ -17,6 +17,9 @@ from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note a
|
|||||||
# TODO: Prioritize SO or WO group warehouse
|
# TODO: Prioritize SO or WO group warehouse
|
||||||
|
|
||||||
class PickList(Document):
|
class PickList(Document):
|
||||||
|
def validate(self):
|
||||||
|
self.validate_for_qty()
|
||||||
|
|
||||||
def before_save(self):
|
def before_save(self):
|
||||||
self.set_item_locations()
|
self.set_item_locations()
|
||||||
|
|
||||||
@ -35,6 +38,7 @@ class PickList(Document):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def set_item_locations(self, save=False):
|
def set_item_locations(self, save=False):
|
||||||
|
self.validate_for_qty()
|
||||||
items = self.aggregate_item_qty()
|
items = self.aggregate_item_qty()
|
||||||
self.item_location_map = frappe._dict()
|
self.item_location_map = frappe._dict()
|
||||||
|
|
||||||
@ -107,6 +111,11 @@ class PickList(Document):
|
|||||||
|
|
||||||
return item_map.values()
|
return item_map.values()
|
||||||
|
|
||||||
|
def validate_for_qty(self):
|
||||||
|
if self.purpose == "Material Transfer for Manufacture" \
|
||||||
|
and (self.for_qty is None or self.for_qty == 0):
|
||||||
|
frappe.throw(_("Qty of Finished Goods Item should be greater than 0."))
|
||||||
|
|
||||||
|
|
||||||
def validate_item_locations(pick_list):
|
def validate_item_locations(pick_list):
|
||||||
if not pick_list.locations:
|
if not pick_list.locations:
|
||||||
|
@ -37,6 +37,7 @@ class TestPickList(unittest.TestCase):
|
|||||||
'company': '_Test Company',
|
'company': '_Test Company',
|
||||||
'customer': '_Test Customer',
|
'customer': '_Test Customer',
|
||||||
'items_based_on': 'Sales Order',
|
'items_based_on': 'Sales Order',
|
||||||
|
'purpose': 'Delivery',
|
||||||
'locations': [{
|
'locations': [{
|
||||||
'item_code': '_Test Item',
|
'item_code': '_Test Item',
|
||||||
'qty': 5,
|
'qty': 5,
|
||||||
@ -90,6 +91,7 @@ class TestPickList(unittest.TestCase):
|
|||||||
'company': '_Test Company',
|
'company': '_Test Company',
|
||||||
'customer': '_Test Customer',
|
'customer': '_Test Customer',
|
||||||
'items_based_on': 'Sales Order',
|
'items_based_on': 'Sales Order',
|
||||||
|
'purpose': 'Delivery',
|
||||||
'locations': [{
|
'locations': [{
|
||||||
'item_code': '_Test Item Warehouse Group Wise Reorder',
|
'item_code': '_Test Item Warehouse Group Wise Reorder',
|
||||||
'qty': 1000,
|
'qty': 1000,
|
||||||
@ -135,6 +137,7 @@ class TestPickList(unittest.TestCase):
|
|||||||
'company': '_Test Company',
|
'company': '_Test Company',
|
||||||
'customer': '_Test Customer',
|
'customer': '_Test Customer',
|
||||||
'items_based_on': 'Sales Order',
|
'items_based_on': 'Sales Order',
|
||||||
|
'purpose': 'Delivery',
|
||||||
'locations': [{
|
'locations': [{
|
||||||
'item_code': '_Test Serialized Item',
|
'item_code': '_Test Serialized Item',
|
||||||
'qty': 1000,
|
'qty': 1000,
|
||||||
@ -264,6 +267,7 @@ class TestPickList(unittest.TestCase):
|
|||||||
'company': '_Test Company',
|
'company': '_Test Company',
|
||||||
'customer': '_Test Customer',
|
'customer': '_Test Customer',
|
||||||
'items_based_on': 'Sales Order',
|
'items_based_on': 'Sales Order',
|
||||||
|
'purpose': 'Delivery',
|
||||||
'locations': [{
|
'locations': [{
|
||||||
'item_code': '_Test Item',
|
'item_code': '_Test Item',
|
||||||
'qty': 5,
|
'qty': 5,
|
||||||
@ -319,6 +323,7 @@ class TestPickList(unittest.TestCase):
|
|||||||
'company': '_Test Company',
|
'company': '_Test Company',
|
||||||
'customer': '_Test Customer',
|
'customer': '_Test Customer',
|
||||||
'items_based_on': 'Sales Order',
|
'items_based_on': 'Sales Order',
|
||||||
|
'purpose': 'Delivery',
|
||||||
'locations': [{
|
'locations': [{
|
||||||
'item_code': '_Test Item',
|
'item_code': '_Test Item',
|
||||||
'qty': 1,
|
'qty': 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user