Browse Source

Merge pull request #29014 from ankush/rename_sr_no

fix!: disable renaming on serial nos
develop
Ankush Menat 3 years ago
committed by GitHub
parent
commit
087ebcae5a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      erpnext/stock/doctype/serial_no/serial_no.json
  2. 17
      erpnext/stock/doctype/serial_no/serial_no.py

5
erpnext/stock/doctype/serial_no/serial_no.json

@ -1,7 +1,6 @@
{
"actions": [],
"allow_import": 1,
"allow_rename": 1,
"autoname": "field:serial_no",
"creation": "2013-05-16 10:59:15",
"description": "Distinct unit of an Item",
@ -434,10 +433,11 @@
"icon": "fa fa-barcode",
"idx": 1,
"links": [],
"modified": "2021-01-08 14:31:15.375996",
"modified": "2021-12-23 10:44:30.299450",
"modified_by": "Administrator",
"module": "Stock",
"name": "Serial No",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
@ -476,5 +476,6 @@
"show_name_in_global_search": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"track_changes": 1
}

17
erpnext/stock/doctype/serial_no/serial_no.py

@ -194,23 +194,6 @@ class SerialNo(StockController):
if sle_exists:
frappe.throw(_("Cannot delete Serial No {0}, as it is used in stock transactions").format(self.name))
def before_rename(self, old, new, merge=False):
if merge:
frappe.throw(_("Sorry, Serial Nos cannot be merged"))
def after_rename(self, old, new, merge=False):
"""rename serial_no text fields"""
for dt in frappe.db.sql("""select parent from tabDocField
where fieldname='serial_no' and fieldtype in ('Text', 'Small Text', 'Long Text')"""):
for item in frappe.db.sql("""select name, serial_no from `tab%s`
where serial_no like %s""" % (dt[0], frappe.db.escape('%' + old + '%'))):
serial_nos = map(lambda i: new if i.upper()==old.upper() else i, item[1].split('\n'))
frappe.db.sql("""update `tab%s` set serial_no = %s
where name=%s""" % (dt[0], '%s', '%s'),
('\n'.join(list(serial_nos)), item[0]))
def update_serial_no_reference(self, serial_no=None):
last_sle = self.get_last_sle(serial_no)
self.set_purchase_details(last_sle.get("purchase_sle"))

Loading…
Cancel
Save