refactor: Consolidate duplicate zero-quantity transaction Items checks.

(cherry picked from commit 4918aeb4c6)

# Conflicts:
#	erpnext/stock/doctype/stock_entry/stock_entry.py
This commit is contained in:
Bernd Oliver Sünderhauf
2023-11-14 19:43:26 +01:00
committed by Mergify
parent e91a0acbb3
commit cf45ffdabe
5 changed files with 13 additions and 21 deletions

View File

@@ -24,10 +24,13 @@ from frappe.utils import (
import erpnext
from erpnext.accounts.general_ledger import process_gl_map
<<<<<<< HEAD
<<<<<<< HEAD
from erpnext.buying.utils import check_on_hold_or_closed_status
=======
from erpnext.controllers.accounts_controller import InvalidQtyError
>>>>>>> b2d8a44199 (test: Add, expand and refine test-cases for zero-quantity transactions.)
=======
>>>>>>> 4918aeb4c6 (refactor: Consolidate duplicate zero-quantity transaction Items checks.)
from erpnext.controllers.taxes_and_totals import init_landed_taxes_and_totals
from erpnext.manufacturing.doctype.bom.bom import (
add_additional_cost,
@@ -369,10 +372,8 @@ class StockEntry(StockController):
frappe.delete_doc("Stock Entry", d.name)
def set_transfer_qty(self):
self.validate_qty_is_not_zero()
for item in self.get("items"):
if not flt(item.qty):
message = _("Row {0}: Qty is mandatory").format(item.idx)
frappe.throw(message, InvalidQtyError, title=_("Zero quantity"))
if not flt(item.conversion_factor):
frappe.throw(_("Row {0}: UOM Conversion Factor is mandatory").format(item.idx))
item.transfer_qty = flt(