* fix: validate uom is integer for PR item
(cherry picked from commit 9a290fdfc9)
# Conflicts:
# erpnext/controllers/subcontracting_controller.py
* chore: `conflicts`
---------
Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
@@ -126,8 +126,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
self.po_required()
|
self.po_required()
|
||||||
self.validate_items_quality_inspection()
|
self.validate_items_quality_inspection()
|
||||||
self.validate_with_previous_doc()
|
self.validate_with_previous_doc()
|
||||||
self.validate_uom_is_integer("uom", ["qty", "received_qty"])
|
self.validate_uom_is_integer()
|
||||||
self.validate_uom_is_integer("stock_uom", "stock_qty")
|
|
||||||
self.validate_cwip_accounts()
|
self.validate_cwip_accounts()
|
||||||
self.validate_provisional_expense_account()
|
self.validate_provisional_expense_account()
|
||||||
|
|
||||||
@@ -141,6 +140,10 @@ class PurchaseReceipt(BuyingController):
|
|||||||
self.reset_default_field_value("rejected_warehouse", "items", "rejected_warehouse")
|
self.reset_default_field_value("rejected_warehouse", "items", "rejected_warehouse")
|
||||||
self.reset_default_field_value("set_from_warehouse", "items", "from_warehouse")
|
self.reset_default_field_value("set_from_warehouse", "items", "from_warehouse")
|
||||||
|
|
||||||
|
def validate_uom_is_integer(self):
|
||||||
|
super().validate_uom_is_integer("uom", ["qty", "received_qty"], "Purchase Receipt Item")
|
||||||
|
super().validate_uom_is_integer("stock_uom", "stock_qty", "Purchase Receipt Item")
|
||||||
|
|
||||||
def validate_cwip_accounts(self):
|
def validate_cwip_accounts(self):
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.is_fixed_asset and is_cwip_accounting_enabled(item.asset_category):
|
if item.is_fixed_asset and is_cwip_accounting_enabled(item.asset_category):
|
||||||
|
|||||||
@@ -329,7 +329,9 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
accepted_warehouse_account = warehouse_account[item.warehouse]["account"]
|
accepted_warehouse_account = warehouse_account[item.warehouse]["account"]
|
||||||
supplier_warehouse_account = warehouse_account.get(self.supplier_warehouse, {}).get("account")
|
supplier_warehouse_account = warehouse_account.get(self.supplier_warehouse, {}).get(
|
||||||
|
"account"
|
||||||
|
)
|
||||||
remarks = self.get("remarks") or _("Accounting Entry for Stock")
|
remarks = self.get("remarks") or _("Accounting Entry for Stock")
|
||||||
|
|
||||||
# Accepted Warehouse Account (Debit)
|
# Accepted Warehouse Account (Debit)
|
||||||
@@ -401,7 +403,9 @@ class SubcontractingReceipt(SubcontractingController):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if divisional_loss := flt(item.amount - stock_value_diff, item.precision("amount")):
|
if divisional_loss := flt(item.amount - stock_value_diff, item.precision("amount")):
|
||||||
loss_account = self.get_company_default("stock_adjustment_account", ignore_validation=True)
|
loss_account = self.get_company_default(
|
||||||
|
"stock_adjustment_account", ignore_validation=True
|
||||||
|
)
|
||||||
|
|
||||||
# Loss Account (Credit)
|
# Loss Account (Credit)
|
||||||
self.add_gl_entry(
|
self.add_gl_entry(
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ class TransactionBase(StatusUpdater):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
frappe.throw(_("Invalid Posting Time"))
|
frappe.throw(_("Invalid Posting Time"))
|
||||||
|
|
||||||
def validate_uom_is_integer(self, uom_field, qty_fields):
|
def validate_uom_is_integer(self, uom_field, qty_fields, child_dt=None):
|
||||||
validate_uom_is_integer(self, uom_field, qty_fields)
|
validate_uom_is_integer(self, uom_field, qty_fields, child_dt)
|
||||||
|
|
||||||
def validate_with_previous_doc(self, ref):
|
def validate_with_previous_doc(self, ref):
|
||||||
self.exclude_fields = ["conversion_factor", "uom"] if self.get("is_return") else []
|
self.exclude_fields = ["conversion_factor", "uom"] if self.get("is_return") else []
|
||||||
@@ -210,12 +210,13 @@ def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None):
|
|||||||
for f in qty_fields:
|
for f in qty_fields:
|
||||||
qty = d.get(f)
|
qty = d.get(f)
|
||||||
if qty:
|
if qty:
|
||||||
if abs(cint(qty) - flt(qty, d.precision(f))) > 0.0000001:
|
precision = d.precision(f)
|
||||||
|
if abs(cint(qty) - flt(qty, precision)) > 0.0000001:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_(
|
_(
|
||||||
"Row {1}: Quantity ({0}) cannot be a fraction. To allow this, disable '{2}' in UOM {3}."
|
"Row {1}: Quantity ({0}) cannot be a fraction. To allow this, disable '{2}' in UOM {3}."
|
||||||
).format(
|
).format(
|
||||||
flt(qty, d.precision(f)),
|
flt(qty, precision),
|
||||||
d.idx,
|
d.idx,
|
||||||
frappe.bold(_("Must be Whole Number")),
|
frappe.bold(_("Must be Whole Number")),
|
||||||
frappe.bold(d.get(uom_field)),
|
frappe.bold(d.get(uom_field)),
|
||||||
|
|||||||
Reference in New Issue
Block a user