chore: subcontracting validations (backport #33621) (#33626)

* fix: `ZeroDivisionError: float division by zero` in SCR

(cherry picked from commit 434aa594d5)

* chore: add row-index in error msgs

(cherry picked from commit 6878f40d1d)

* chore: update error msgs for Subcontracted PO

(cherry picked from commit a0e2a93f3f)

* fix: validate accepted and rejected qty in SCR Item

(cherry picked from commit f028bd6e69)

* chore: linter

(cherry picked from commit b26e96cdf4)

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
mergify[bot]
2023-01-12 20:31:24 +05:30
committed by GitHub
parent c9edf10693
commit 120dca44ad
3 changed files with 24 additions and 19 deletions

View File

@@ -57,6 +57,7 @@ class SubcontractingReceipt(SubcontractingController):
def before_validate(self):
super(SubcontractingReceipt, self).before_validate()
self.validate_items_qty()
self.set_items_bom()
self.set_items_cost_center()
self.set_items_expense_account()
@@ -157,7 +158,7 @@ class SubcontractingReceipt(SubcontractingController):
total_qty = total_amount = 0
for item in self.items:
if item.name in rm_supp_cost:
if item.qty and item.name in rm_supp_cost:
item.rm_supp_cost = rm_supp_cost[item.name]
item.rm_cost_per_qty = item.rm_supp_cost / item.qty
rm_supp_cost.pop(item.name)
@@ -194,6 +195,13 @@ class SubcontractingReceipt(SubcontractingController):
).format(item.idx)
)
def validate_items_qty(self):
for item in self.items:
if not (item.qty or item.rejected_qty):
frappe.throw(
_("Row {0}: Accepted Qty and Rejected Qty can't be zero at the same time.").format(item.idx)
)
def set_items_bom(self):
if self.is_return:
for item in self.items: