mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-14 15:11:52 +00:00
fix(opportunity): add validation for positive item quantities
(cherry picked from commit c47cc37441)
This commit is contained in:
@@ -132,6 +132,7 @@ class Opportunity(TransactionBase, CRMNote):
|
|||||||
self.validate_uom_is_integer("uom", "qty")
|
self.validate_uom_is_integer("uom", "qty")
|
||||||
self.validate_cust_name()
|
self.validate_cust_name()
|
||||||
self.map_fields()
|
self.map_fields()
|
||||||
|
self.validate_qty()
|
||||||
self.set_exchange_rate()
|
self.set_exchange_rate()
|
||||||
|
|
||||||
if not self.title:
|
if not self.title:
|
||||||
@@ -142,6 +143,15 @@ class Opportunity(TransactionBase, CRMNote):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.update_prospect()
|
self.update_prospect()
|
||||||
|
|
||||||
|
def validate_qty(self):
|
||||||
|
for item in self.items:
|
||||||
|
if item.qty <= 0:
|
||||||
|
frappe.throw(
|
||||||
|
_("Row #{0}: Quantity must be greater than 0 for Item {1}").format(
|
||||||
|
item.idx, item.item_code
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def map_fields(self):
|
def map_fields(self):
|
||||||
for field in self.meta.get_valid_columns():
|
for field in self.meta.get_valid_columns():
|
||||||
if not self.get(field) and frappe.db.field_exists(self.opportunity_from, field):
|
if not self.get(field) and frappe.db.field_exists(self.opportunity_from, field):
|
||||||
|
|||||||
Reference in New Issue
Block a user