fix: validate FG Item and Qty

This commit is contained in:
s-aga-r
2023-08-21 22:23:57 +05:30
parent faf9f13215
commit 9588bb7443
3 changed files with 49 additions and 13 deletions

View File

@@ -49,18 +49,6 @@ class PurchaseOrder(BuyingController):
}
]
def can_update_items(self) -> bool:
result = True
if self.is_subcontracted and not self.is_old_subcontracting_flow:
# Check - 1: NOT ALLOWED if non-cancelled Subcontracting Order exists for this Purchase Order
if frappe.db.exists(
"Subcontracting Order", {"purchase_order": self.name, "docstatus": ["!=", 2]}
):
return False
return result
def onload(self):
supplier_tds = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
self.set_onload("supplier_tds", supplier_tds)
@@ -463,6 +451,17 @@ class PurchaseOrder(BuyingController):
else:
self.db_set("per_received", 0, update_modified=False)
def can_update_items(self) -> bool:
result = True
if self.is_subcontracted and not self.is_old_subcontracting_flow:
if frappe.db.exists(
"Subcontracting Order", {"purchase_order": self.name, "docstatus": ["!=", 2]}
):
result = False
return result
def item_last_purchase_rate(name, conversion_rate, item_code, conversion_factor=1.0):
"""get last purchase rate for an item"""