diff --git a/erpnext/patches/jan_mar_2012/rename_dt.py b/erpnext/patches/jan_mar_2012/rename_dt.py index 171fe3f86c..aa50dfbfd0 100644 --- a/erpnext/patches/jan_mar_2012/rename_dt.py +++ b/erpnext/patches/jan_mar_2012/rename_dt.py @@ -151,7 +151,11 @@ def rename_in_db(ren_data, data_type, is_doctype): def update_dt_in_records(rendt): for d in rendt: # Feed, property setter, search criteria, gl mapper, form 16A, naming series options, doclayer - dodtype is not mentioed in options - dt_list = webnotes.conn.sql("select t1.parent, t1.fieldname from tabDocField t1, tabDocType t2 where t1.parent = t2.name and t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0 and t1.parent in ('Custom Field', 'Custom Script')") + dt_list = webnotes.conn.sql("""select t1.parent, t1.fieldname from + tabDocField t1, tabDocType t2 where t1.parent = t2.name and + t1.fieldname in ('dt', 'doctype', 'doc_type', 'dt_type') and + ifnull(t1.options, '') = '' and ifnull(t2.issingle, 0) = 0 and + t1.parent in ('Custom Field', 'Custom Script', 'Property Setter')""") for dt in dt_list: webnotes.conn.sql("update `tab%s` set %s = replace(%s, '%s', '%s') where %s = '%s'" % (dt[0], dt[1], dt[1], d, rendt[d], dt[1], d)) diff --git a/erpnext/patches/mar_2012/clean_property_setter.py b/erpnext/patches/mar_2012/clean_property_setter.py index 12e0a9e3e3..2d83fb1a0a 100644 --- a/erpnext/patches/mar_2012/clean_property_setter.py +++ b/erpnext/patches/mar_2012/clean_property_setter.py @@ -6,9 +6,35 @@ def execute(): * Remove docfield property setters if fieldname doesn't exist * Remove prev_field properties if value fieldname doesn't exist """ + change_property_setter_fieldnames() clean_doctype_properties() clean_docfield_properties() +def change_property_setter_fieldnames(): + import webnotes.model.sync + webnotes.model.sync.sync('core', 'property_setter') + docfield_list = webnotes.conn.sql("""\ + SELECT name, fieldname FROM `tabDocField`""", as_list=1) + custom_field_list = webnotes.conn.sql("""\ + SELECT name, fieldname FROM `tabCustom Field`""", as_list=1) + field_list = docfield_list + custom_field_list + property_setter_list = webnotes.conn.sql("""\ + SELECT name, doc_name, value, property + FROM `tabProperty Setter` + WHERE doctype_or_field='DocField'""") + field_dict = dict(field_list) + for name, doc_name, value, prop in property_setter_list: + if doc_name in field_dict: + webnotes.conn.sql("""\ + UPDATE `tabProperty Setter` + SET field_name = %s + WHERE name = %s""", (field_dict.get(doc_name), name)) + if value in field_dict and prop=='previous_field': + webnotes.conn.sql("""\ + UPDATE `tabProperty Setter` + SET value = %s + WHERE name = %s""", (field_dict.get(value), name)) + def clean_doctype_properties(): desc = webnotes.conn.sql("DESC `tabDocType`", as_dict=1) property_list = '", "'.join([d.get('Field') for d in desc]) diff --git a/erpnext/patches/mar_2012/create_custom_fields.py b/erpnext/patches/mar_2012/create_custom_fields.py new file mode 100644 index 0000000000..759a4d5860 --- /dev/null +++ b/erpnext/patches/mar_2012/create_custom_fields.py @@ -0,0 +1,115 @@ +# do not run this patch +field_list = [ +['Contact', 'notes'], +['Contact', 'birthday'], +['Contact', 'anniversary'], +['Customer', 'state_tax_type'], +['Customer', 'tin_no'], +['Customer', 'excise_registration_number'], +['Customer', 'customer_discount_details'], +['Customer', 'notes'], +['Customer', 'follow_up_section'], +['Customer', 'follow_up'], +['Delivery Note', 'shipping_contact_no'], +['Delivery Note', 'shipping_tin_no'], +['Delivery Note', 'shipping_excise_no'], +['Delivery Note', 'tin_no'], +['Delivery Note', 'excise_no'], +['Delivery Note Detail', 'cetsh_number'], +['Item', 'base_material'], +['Item', 'tool_type'], +['Item', 'no_of_flutes'], +['Item', 'special_treatment'], +['Item', 'length'], +['Item', 'width'], +['Item', 'height_dia'], +['Item', 'pl_item'], +['Item', 'cetsh_number'], +['Item', 'stock_maintained'], +['Item', 'is_rm'], +['Journal Voucher Detail', 'line_remarks'], +['Lead', 'designation'], +['Purchase Order', 'challan_number'], +['Quotation', 'cust_enq_no'], +['Quotation', 'enq_date'], +['Quotation', 'quote_valid'], +['Quotation', 'due_date'], +['Receivable Voucher', 'voucher_time'], +['Receivable Voucher', 'removal_time'], +['Receivable Voucher', 'removal_date'], +['Receivable Voucher', 'shipping_address'], +['Receivable Voucher', 'shipping_location'], +['Receivable Voucher', 'ship_to'], +['Receivable Voucher', 'shipping_contact_no'], +['Receivable Voucher', 'shipping_excise_no'], +['Receivable Voucher', 'shipping_tin_no'], +['Receivable Voucher', 'po_no'], +['Receivable Voucher', 'po_date'], +['Receivable Voucher', 'lr_no'], +['Receivable Voucher', 'transporters'], +['Receivable Voucher', 'ship_terms'], +['Receivable Voucher', 'tin_no'], +['Receivable Voucher', 'excise_no'], +['RV Detail', 'cetsh_number'], +['Sales Order', 'shipping_contact_no'], +['Sales Order', 'shipping_tin_no'], +['Sales Order', 'shipping_excise_no'], +['Sales Order', 'tin_no'], +['Sales Order', 'excise_number'], +['Sales Order Detail', 'cetsh_number'], +['Sales Order Detail', 'prd_notes'], +['Shipping Address', 'phone_no'], +['Shipping Address', 'tin_no'], +['Shipping Address', 'excise_no'], +['Stock Entry', 'process_custom'], +['Stock Entry', 'city'], +['Stock Entry', 'address_line_2'], +['Stock Entry', 'address_line_1'], +['Stock Entry', 'comp_other'], +['Stock Entry', 'mobile_no'], +['Stock Entry', 'phone_no'], +['Stock Entry', 'country'], +['Stock Entry', 'state'], +['Stock Entry', 'challan_number'], +['Stock Entry Detail', 'machine'], +['Stock Entry Detail', 'worker'], +['Supplier', 'notes'], +['Supplier', 'purchase_other_charges'], +['Supplier', 'tax_details'], +['Supplier', 'tin_number'], +['Supplier', 'excise_regd_number'], +['Supplier', 'service_tax_regd_number'], +['Warehouse', 'comp_other'], +['Warehouse', 'process'], +['Warehouse', 'country'], +['Warehouse', 'tax_registration_number'], +['Warehouse Type', 'process'], +['Workstation', 'maintenance_data'], +] + + +import webnotes +from webnotes.model.code import get_obj +from webnotes.model.doc import Document + +def execute(): + import webnotes.model.sync + webnotes.model.sync.sync('core', 'custom_field') + for f in field_list: + res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field` + WHERE dt=%s AND fieldname=%s""", (f[0], f[1])) + if res: continue + docfield = webnotes.conn.sql("""SELECT * FROM `tabDocField` + WHERE parent=%s AND fieldname=%s""", (f[0], f[1]), as_dict=1) + if not docfield: continue + custom_field = docfield[0] + + # scrub custom field dict + custom_field['dt'] = custom_field['parent'] + del custom_field['parent'] + + d = Document('Custom Field', fielddata=custom_field) + d.name = custom_field['dt'] + '-' + custom_field['fieldname'] + d.save(1, ignore_fields=1) + #obj = get_obj(doc=d) + #obj.on_update() diff --git a/erpnext/patches/mar_2012/doctype_get_refactor.py b/erpnext/patches/mar_2012/doctype_get_refactor.py index fb8c65a2f1..147fb931ff 100644 --- a/erpnext/patches/mar_2012/doctype_get_refactor.py +++ b/erpnext/patches/mar_2012/doctype_get_refactor.py @@ -8,8 +8,6 @@ def execute(): * Remove 'no_column' from DocField * Drop table DocFormat """ - change_property_setter_fieldnames() - import webnotes.model.sync webnotes.model.sync.sync_all(force=1) @@ -19,33 +17,6 @@ def execute(): # do at last - needs commit due to DDL statements change_to_decimal() -def change_property_setter_fieldnames(): - import webnotes.model.sync - webnotes.model.sync.sync('core', 'property_setter') - docfield_list = webnotes.conn.sql("""\ - SELECT name, fieldname FROM `tabDocField`""", as_list=1) - custom_field_list = webnotes.conn.sql("""\ - SELECT name, fieldname FROM `tabCustom Field`""", as_list=1) - field_list = docfield_list + custom_field_list - property_setter_list = webnotes.conn.sql("""\ - SELECT name, doc_name, value, property - FROM `tabProperty Setter` - WHERE doctype_or_field='DocField'""") - field_dict = dict(field_list) - for name, doc_name, value, prop in property_setter_list: - if doc_name in field_dict: - webnotes.conn.sql("""\ - UPDATE `tabProperty Setter` - SET field_name = %s - WHERE name = %s""", (field_dict.get(doc_name), name)) - if value in field_dict and prop=='previous_field': - webnotes.conn.sql("""\ - UPDATE `tabProperty Setter` - SET value = %s - WHERE name = %s""", (field_dict.get(value), name)) - import patches.mar_2012.clean_property_setter - patches.mar_2012.clean_property_setter.execute() - def handle_custom_fields(): """ * Assign idx to custom fields diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 94164f0e74..f134ed2133 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -232,6 +232,11 @@ patch_list = [ 'patch_file': 'sync_ref_db', 'description': 'Deletes non required doctypes' }, + { + 'patch_module': 'patches.mar_2012', + 'patch_file': 'clean_property_setter', + 'description': 'Patch related to property setter cleanup' + }, { 'patch_module': 'patches.jan_mar_2012', 'patch_file': 'rename_dt', diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js index 52f312400a..a2ff51550f 100644 --- a/erpnext/selling/doctype/sales_common/sales_common.js +++ b/erpnext/selling/doctype/sales_common/sales_common.js @@ -466,14 +466,14 @@ cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) doc = locals[doc.doctype][doc.name]; // Make Display Area - cur_frm.fields_dict['Taxes and Charges Calculation'].disp_area.innerHTML = + cur_frm.fields_dict['other_charges_calculation'].disp_area.innerHTML = 'Calculation Details for Taxes and Charges:'; var cl = getchildren(tname, doc.name, fname); var tax = getchildren('Sales Taxes and Charges', doc.name, other_fname,doc.doctype); // Make display table - var otc = make_table(cur_frm.fields_dict['Taxes and Charges Calculation'].disp_area, + var otc = make_table(cur_frm.fields_dict['other_charges_calculation'].disp_area, cl.length + 1, tax.length + 1, '90%', [], { border:'1px solid #AAA', padding:'2px' }); $y(otc,{marginTop:'8px'});