resoved conflict in patch, company and renaming tools
This commit is contained in:
commit
a56fc00ea3
@ -72,6 +72,7 @@ cur_frm.fields_dict['master_name'].get_query=function(doc){
|
||||
else alert("Please select master type");
|
||||
}
|
||||
|
||||
/*
|
||||
// Get customer/supplier address
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.master_name = function(doc,cdt,cdn){
|
||||
@ -79,6 +80,7 @@ cur_frm.cscript.master_name = function(doc,cdt,cdn){
|
||||
get_server_fields('get_address','','',doc,cdt,cdn);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// parent account get query
|
||||
// -----------------------------------------
|
||||
|
@ -260,3 +260,16 @@ class DocType:
|
||||
def on_restore(self):
|
||||
# rebuild tree
|
||||
self.update_nsm_model()
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
company_abbr = sql("select tc.abbr from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.name=%s", olddn)[0][0]
|
||||
|
||||
newdnchk = newdn.split(" - ")
|
||||
|
||||
if newdnchk[-1].lower() != company_abbr.lower():
|
||||
msgprint("Please add company abbreviation <b>%s</b>" %(company_abbr), raise_exception=1)
|
||||
else:
|
||||
account_name = " - ".join(newdnchk[:-1])
|
||||
sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(account_name,olddn))
|
||||
|
@ -16,7 +16,6 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
@ -146,3 +145,23 @@ class DocType:
|
||||
def on_trash(self):
|
||||
self.delete_supplier_address()
|
||||
self.delete_supplier_contact()
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
#update supplier_name if not naming series
|
||||
if get_defaults().get('supp_master_name') == 'Supplier Name':
|
||||
update_fields = [
|
||||
('Supplier', 'name'),
|
||||
('Address', 'supplier'),
|
||||
('Contact', 'supplier'),
|
||||
('Payable Voucher', 'supplier'),
|
||||
('Purchase Order', 'supplier'),
|
||||
('Purchase Receipt', 'supplier'),
|
||||
('Serial No', 'supplier'),
|
||||
('Supplier Quotation', 'supplier')]
|
||||
for rec in update_fields:
|
||||
sql("update `tab%s` set supplier_name = '%s' where %s = '%s'" %(rec[0],newdn,rec[1],olddn))
|
||||
|
||||
#update master_name in doctype account
|
||||
sql("update `tabAccount` set master_name = '%s', master_type = 'Supplier' where master_name = '%s'" %(newdn,olddn))
|
||||
|
@ -1,6 +1,7 @@
|
||||
# REMEMBER to update this
|
||||
# ========================
|
||||
last_patch = 306
|
||||
|
||||
last_patch = 308
|
||||
|
||||
#-------------------------------------------
|
||||
|
||||
@ -1187,9 +1188,9 @@ def execute(patch_no):
|
||||
reload_doc('payroll', 'doctype', 'salary_structure')
|
||||
reload_doc('payroll', 'doctype', 'salary_slip')
|
||||
elif patch_no == 298:
|
||||
sql("update `tabDocField` set options = 'Link:Company' where parent = 'Attendance' and fieldname = 'company'")
|
||||
sql("update `tabDocField` set options = 'Link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
|
||||
sql("update `tabDocField` set options = 'Link:Company' where parent = 'Appraisal' and fieldname = 'company'")
|
||||
sql("update `tabDocField` set options = 'link:Company' where parent = 'Attendance' and fieldname = 'company'")
|
||||
sql("update `tabDocField` set options = 'link:Company' where parent = 'Expense Voucher' and fieldname = 'company'")
|
||||
sql("update `tabDocField` set options = 'link:Company' where parent = 'Appraisal' and fieldname = 'company'")
|
||||
elif patch_no == 299:
|
||||
sql("update `tabDocPerm` set `match` = NULL where parent = 'Employee' and role = 'Employee'")
|
||||
elif patch_no == 300:
|
||||
@ -1208,5 +1209,14 @@ def execute(patch_no):
|
||||
elif patch_no == 305:
|
||||
sql("update `tabDocField` set options = 'link:Company' where options='link:Company' and fieldname='company' and fieldtype='Select'")
|
||||
elif patch_no == 306:
|
||||
sql("update `tabDocField` set options = '\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem' where parent = 'Rename Tool' and fieldname = 'select_doctype'")
|
||||
sql("update `tabDocField` set options = 'link:Item' where parent = 'Raw Materials Supplied' and fieldname = 'po_item'")
|
||||
sql("update `tabDocField` set options = 'Sales Order' where parent = 'Indent Detail' and fieldname = 'sales_order_no'")
|
||||
sql("update `tabDocField` set options = 'link:Company', fieldtype = 'Select' where parent = 'Stock Ledger Entry' and fieldname = 'company'")
|
||||
reload_doc('tools', 'doctype', 'rename_tool')
|
||||
elif patch_no == 307:
|
||||
sql("delete from `tabDocField` where parent = 'company' and label = 'Trash Company' and fieldtype = 'Button'")
|
||||
reload_doc('setup', 'doctype', 'company')
|
||||
elif patch_no == 308:
|
||||
from erpnext_structure_cleanup import run_patches
|
||||
run_patches()
|
||||
|
@ -13,7 +13,6 @@ convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
@ -23,7 +22,6 @@ class DocType:
|
||||
def autoname(self):
|
||||
cust_master_name = get_defaults().get('cust_master_name')
|
||||
if cust_master_name == 'Customer Name':
|
||||
|
||||
# filter out bad characters in name
|
||||
#cust = self.doc.customer_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
|
||||
cust = self.doc.customer_name
|
||||
@ -35,7 +33,6 @@ class DocType:
|
||||
raise Exception
|
||||
else:
|
||||
self.doc.name = cust
|
||||
|
||||
else:
|
||||
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
|
||||
|
||||
@ -164,7 +161,7 @@ class DocType:
|
||||
#create address and contact from lead
|
||||
def create_lead_address_contact(self):
|
||||
if self.doc.lead_name:
|
||||
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, contact_no, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
|
||||
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
|
||||
d = Document('Address')
|
||||
d.address_line1 = details[0]['address_line1']
|
||||
d.address_line2 = details[0]['address_line2']
|
||||
@ -174,7 +171,7 @@ class DocType:
|
||||
d.state = details[0]['state']
|
||||
d.fax = details[0]['fax']
|
||||
d.email_id = details[0]['email_id']
|
||||
d.phone = details[0]['contact_no']
|
||||
d.phone = details[0]['phone']
|
||||
d.customer = self.doc.name
|
||||
d.customer_name = self.doc.customer_name
|
||||
d.is_primary_address = 1
|
||||
@ -187,8 +184,8 @@ class DocType:
|
||||
c = Document('Contact')
|
||||
c.first_name = details[0]['lead_name']
|
||||
c.email_id = details[0]['email_id']
|
||||
c.phone = details[0]['contact_no']
|
||||
c.phone = details[0]['contact_no']
|
||||
c.phone = details[0]['phone']
|
||||
c.mobile_no = details[0]['mobile_no']
|
||||
c.customer = self.doc.name
|
||||
c.customer_name = self.doc.customer_name
|
||||
c.is_primary_contact = 1
|
||||
@ -228,3 +225,33 @@ class DocType:
|
||||
self.delete_customer_contact()
|
||||
if self.doc.lead_name:
|
||||
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
#update customer_name if not naming series
|
||||
if get_defaults().get('cust_master_name') == 'Customer Name':
|
||||
update_fields = [
|
||||
('Customer', 'name'),
|
||||
('Address', 'customer'),
|
||||
('Contact', 'customer'),
|
||||
('Customer Issue', 'customer'),
|
||||
('Delivery Note', 'customer'),
|
||||
('Enquiry', 'customer'),
|
||||
('Installation Note', 'customer'),
|
||||
('Maintenance Schedule', 'customer'),
|
||||
('Maintenance Visit', 'customer'),
|
||||
('Project', 'customer'),
|
||||
('Quotation', 'customer'),
|
||||
('Receivable Voucher', 'customer'),
|
||||
('Sales Order', 'customer'),
|
||||
('Serial No', 'customer'),
|
||||
('Shipping Address', 'customer'),
|
||||
('Stock Entry', 'customer'),
|
||||
('Support Ticket', 'customer'),
|
||||
('Ticket', 'customer')]
|
||||
for rec in update_fields:
|
||||
sql("update `tab%s` set customer_name = '%s' where %s = '%s'" %(rec[0],newdn,rec[1],olddn))
|
||||
|
||||
#update master_name in doctype account
|
||||
sql("update `tabAccount` set master_name = '%s', master_type = 'Customer' where master_name = '%s'" %(newdn,olddn))
|
||||
|
@ -244,3 +244,8 @@ class DocType:
|
||||
get_obj('Cost Center', each[0]).on_restore()
|
||||
|
||||
msgprint("Company restored. All the accounts and cost centers related to this company also restored.")
|
||||
|
||||
# on rename
|
||||
# ---------
|
||||
def on_rename(self,newdn,olddn):
|
||||
sql("update `tabCompany` set company_name = '%s' where name = '%s'" %(newdn,olddn))
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,9 @@ class DocType:
|
||||
# call on_rename method if exists
|
||||
obj = get_obj(self.doc.select_doctype, self.doc.document_to_rename)
|
||||
if hasattr(obj, 'on_rename'):
|
||||
obj.on_rename(self.doc.new_name)
|
||||
obj.on_rename(self.doc.new_name,self.doc.document_to_rename)
|
||||
|
||||
# rename the document
|
||||
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
|
||||
|
||||
webnotes.msgprint("Item renamed successfully")
|
||||
webnotes.msgprint("Successfully renamed "+self.doc.select_doctype+" : '"+self.doc.document_to_rename+"' to <b>"+self.doc.new_name+"</b>")
|
||||
|
Loading…
x
Reference in New Issue
Block a user