Merge pull request #29014 from ankush/rename_sr_no
fix!: disable renaming on serial nos
This commit is contained in:
parent
2248841d8a
commit
087ebcae5a
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
|
||||||
"autoname": "field:serial_no",
|
"autoname": "field:serial_no",
|
||||||
"creation": "2013-05-16 10:59:15",
|
"creation": "2013-05-16 10:59:15",
|
||||||
"description": "Distinct unit of an Item",
|
"description": "Distinct unit of an Item",
|
||||||
@ -434,10 +433,11 @@
|
|||||||
"icon": "fa fa-barcode",
|
"icon": "fa fa-barcode",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-01-08 14:31:15.375996",
|
"modified": "2021-12-23 10:44:30.299450",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Serial No",
|
"name": "Serial No",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@ -476,5 +476,6 @@
|
|||||||
"show_name_in_global_search": 1,
|
"show_name_in_global_search": 1,
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
|
"states": [],
|
||||||
"track_changes": 1
|
"track_changes": 1
|
||||||
}
|
}
|
@ -194,23 +194,6 @@ class SerialNo(StockController):
|
|||||||
if sle_exists:
|
if sle_exists:
|
||||||
frappe.throw(_("Cannot delete Serial No {0}, as it is used in stock transactions").format(self.name))
|
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):
|
def update_serial_no_reference(self, serial_no=None):
|
||||||
last_sle = self.get_last_sle(serial_no)
|
last_sle = self.get_last_sle(serial_no)
|
||||||
self.set_purchase_details(last_sle.get("purchase_sle"))
|
self.set_purchase_details(last_sle.get("purchase_sle"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user