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:
Alan 2021-06-24 21:01:55 +05:30 committed by GitHub
parent 21e44b19f0
commit 8958f55890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View File

@ -17,6 +17,9 @@ from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note a
# TODO: Prioritize SO or WO group warehouse
class PickList(Document):
def validate(self):
self.validate_for_qty()
def before_save(self):
self.set_item_locations()
@ -35,6 +38,7 @@ class PickList(Document):
@frappe.whitelist()
def set_item_locations(self, save=False):
self.validate_for_qty()
items = self.aggregate_item_qty()
self.item_location_map = frappe._dict()
@ -107,6 +111,11 @@ class PickList(Document):
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):
if not pick_list.locations:

View File

@ -37,6 +37,7 @@ class TestPickList(unittest.TestCase):
'company': '_Test Company',
'customer': '_Test Customer',
'items_based_on': 'Sales Order',
'purpose': 'Delivery',
'locations': [{
'item_code': '_Test Item',
'qty': 5,
@ -90,6 +91,7 @@ class TestPickList(unittest.TestCase):
'company': '_Test Company',
'customer': '_Test Customer',
'items_based_on': 'Sales Order',
'purpose': 'Delivery',
'locations': [{
'item_code': '_Test Item Warehouse Group Wise Reorder',
'qty': 1000,
@ -135,6 +137,7 @@ class TestPickList(unittest.TestCase):
'company': '_Test Company',
'customer': '_Test Customer',
'items_based_on': 'Sales Order',
'purpose': 'Delivery',
'locations': [{
'item_code': '_Test Serialized Item',
'qty': 1000,
@ -264,6 +267,7 @@ class TestPickList(unittest.TestCase):
'company': '_Test Company',
'customer': '_Test Customer',
'items_based_on': 'Sales Order',
'purpose': 'Delivery',
'locations': [{
'item_code': '_Test Item',
'qty': 5,
@ -319,6 +323,7 @@ class TestPickList(unittest.TestCase):
'company': '_Test Company',
'customer': '_Test Customer',
'items_based_on': 'Sales Order',
'purpose': 'Delivery',
'locations': [{
'item_code': '_Test Item',
'qty': 1,