fix: Validate Serial/Batch No naming series in Item itself (#21167)
* fix: Validate Serial/Batch No naming series in Item itself * fix: Consider '#' too
This commit is contained in:
parent
d14598bc51
commit
c732e9967d
@ -101,6 +101,7 @@ class Item(WebsiteGenerator):
|
||||
self.add_default_uom_in_conversion_factor_table()
|
||||
self.validate_conversion_factor()
|
||||
self.validate_item_type()
|
||||
self.validate_naming_series()
|
||||
self.check_for_active_boms()
|
||||
self.fill_customer_code()
|
||||
self.check_item_tax()
|
||||
@ -186,7 +187,7 @@ class Item(WebsiteGenerator):
|
||||
or frappe.db.get_single_value('Stock Settings', 'default_warehouse'))
|
||||
if default_warehouse:
|
||||
warehouse_company = frappe.db.get_value("Warehouse", default_warehouse, "company")
|
||||
|
||||
|
||||
if not default_warehouse or warehouse_company != default.company:
|
||||
default_warehouse = frappe.db.get_value('Warehouse',
|
||||
{'warehouse_name': _('Stores'), 'company': default.company})
|
||||
@ -522,6 +523,13 @@ class Item(WebsiteGenerator):
|
||||
if self.has_serial_no == 0 and self.serial_no_series:
|
||||
self.serial_no_series = None
|
||||
|
||||
def validate_naming_series(self):
|
||||
for field in ["serial_no_series", "batch_number_series"]:
|
||||
series = self.get(field)
|
||||
if series and "#" in series and "." not in series:
|
||||
frappe.throw(_("Invalid naming series (. missing) for {0}")
|
||||
.format(frappe.bold(self.meta.get_field(field).label)))
|
||||
|
||||
def check_for_active_boms(self):
|
||||
if self.default_bom:
|
||||
bom_item = frappe.db.get_value("BOM", self.default_bom, "item")
|
||||
@ -1007,8 +1015,6 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
order by pr.posting_date desc, pr.posting_time desc, pr.name desc
|
||||
limit 1""", (item_code, cstr(doc_name)), as_dict=1)
|
||||
|
||||
|
||||
|
||||
purchase_order_date = getdate(last_purchase_order and last_purchase_order[0].transaction_date
|
||||
or "1900-01-01")
|
||||
purchase_receipt_date = getdate(last_purchase_receipt and
|
||||
@ -1016,7 +1022,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
|
||||
if last_purchase_order and (purchase_order_date >= purchase_receipt_date or not last_purchase_receipt):
|
||||
# use purchase order
|
||||
|
||||
|
||||
last_purchase = last_purchase_order[0]
|
||||
purchase_date = purchase_order_date
|
||||
|
||||
@ -1036,7 +1042,7 @@ def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
"discount_percentage": flt(last_purchase.discount_percentage),
|
||||
"purchase_date": purchase_date
|
||||
})
|
||||
|
||||
|
||||
|
||||
conversion_rate = flt(conversion_rate) or 1.0
|
||||
out.update({
|
||||
|
Loading…
x
Reference in New Issue
Block a user