fix: warning message for negative stock (#42683)
This commit is contained in:
@@ -6,7 +6,7 @@ import gzip
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe import _, scrub
|
||||
from frappe import _, bold, scrub
|
||||
from frappe.model.meta import get_field_precision
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.utils import (
|
||||
@@ -14,6 +14,7 @@ from frappe.utils import (
|
||||
cint,
|
||||
cstr,
|
||||
flt,
|
||||
format_date,
|
||||
get_link_to_form,
|
||||
getdate,
|
||||
now,
|
||||
@@ -746,9 +747,29 @@ class update_entries_after:
|
||||
|
||||
return self.distinct_item_warehouses[key].dependent_voucher_detail_nos
|
||||
|
||||
def validate_previous_sle_qty(self, sle):
|
||||
previous_sle = self.data[sle.warehouse].previous_sle
|
||||
if previous_sle and previous_sle.get("qty_after_transaction") < 0 and sle.get("actual_qty") > 0:
|
||||
frappe.msgprint(
|
||||
_(
|
||||
"The stock for the item {0} in the {1} warehouse was negative on the {2}. You should create a positive entry {3} before the date {4} and time {5} to post the correct valuation rate. For more details, please read the <a href='https://docs.erpnext.com/docs/user/manual/en/stock-adjustment-cogs-with-negative-stock'>documentation<a>."
|
||||
).format(
|
||||
bold(sle.item_code),
|
||||
bold(sle.warehouse),
|
||||
bold(format_date(previous_sle.posting_date)),
|
||||
sle.voucher_no,
|
||||
bold(format_date(previous_sle.posting_date)),
|
||||
bold(previous_sle.posting_time),
|
||||
),
|
||||
title=_("Warning on Negative Stock"),
|
||||
indicator="blue",
|
||||
)
|
||||
|
||||
def process_sle(self, sle):
|
||||
# previous sle data for this warehouse
|
||||
self.wh_data = self.data[sle.warehouse]
|
||||
|
||||
self.validate_previous_sle_qty(sle)
|
||||
self.affected_transactions.add((sle.voucher_type, sle.voucher_no))
|
||||
|
||||
if (sle.serial_no and not self.via_landed_cost_voucher) or not cint(self.allow_negative_stock):
|
||||
|
||||
Reference in New Issue
Block a user