Merge pull request #1775 from nabinhait/v4-hotfix

create custom fields for india specific fields
This commit is contained in:
Anand Doshi 2014-06-09 16:23:21 +05:30
commit 534ebde638
3 changed files with 64 additions and 31 deletions

View File

@ -39,7 +39,6 @@ execute:frappe.delete_doc("Page", "Financial Statements")
execute:frappe.delete_doc("DocType", "Stock Ledger")
execute:frappe.db.sql("update `tabJournal Voucher` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''")
execute:frappe.delete_doc("DocType", "Grade")
erpnext.patches.v4_0.remove_india_specific_fields
execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_group, '')=''")
execute:frappe.delete_doc("Print Format", "SalesInvoice")
execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
@ -56,3 +55,4 @@ erpnext.patches.v4_0.reset_permissions_for_masters
erpnext.patches.v4_0.update_tax_amount_after_discount
execute:frappe.reset_perms("GL Entry") #2014-06-09
execute:frappe.reset_perms("Stock Ledger Entry") #2014-06-09
erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields

View File

@ -0,0 +1,63 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.core.doctype.custom_field.custom_field import create_custom_field_if_values_exist
def execute():
frappe.reload_doc("stock", "doctype", "purchase_receipt")
frappe.reload_doc("hr", "doctype", "employee")
frappe.reload_doc("hr", "doctype", "salary_slip")
india_specific_fields = {
"Purchase Receipt": [{
"label": "Supplier Shipment No",
"fieldname": "challan_no",
"fieldtype": "Data",
"insert_after": "is_subcontracted"
}, {
"label": "Supplier Shipment Date",
"fieldname": "challan_date",
"fieldtype": "Date",
"insert_after": "challan_no"
}],
"Employee": [{
"label": "PAN Number",
"fieldname": "pan_number",
"fieldtype": "Data",
"insert_after": "company_email"
}, {
"label": "Gratuity LIC Id",
"fieldname": "gratuity_lic_id",
"fieldtype": "Data",
"insert_after": "pan_number"
}, {
"label": "Esic Card No",
"fieldname": "esic_card_no",
"fieldtype": "Data",
"insert_after": "bank_ac_no"
}, {
"label": "PF Number",
"fieldname": "pf_number",
"fieldtype": "Data",
"insert_after": "esic_card_no"
}],
"Salary Slip": [{
"label": "Esic No",
"fieldname": "esic_no",
"fieldtype": "Data",
"insert_after": "letter_head",
"permlevel": 1
}, {
"label": "PF Number",
"fieldname": "pf_no",
"fieldtype": "Data",
"insert_after": "esic_no",
"permlevel": 1
}]
}
for dt, docfields in india_specific_fields.items():
for df in docfields:
create_custom_field_if_values_exist(dt, df)

View File

@ -1,30 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.core.doctype.custom_field.custom_field import create_custom_field_if_values_exist
def execute():
frappe.db.sql("delete from tabDocField where parent='Salary Slip' and options='Grade'")
docfields = {
("Purchase Receipt", "challan_no"): frappe.get_meta("Purchase Receipt").get_field("challan_no"),
("Purchase Receipt", "challan_date"): frappe.get_meta("Purchase Receipt").get_field("challan_date"),
("Employee", "pf_number"): frappe.get_meta("Employee").get_field("pf_number"),
("Employee", "pan_number"): frappe.get_meta("Employee").get_field("pan_number"),
("Employee", "gratuity_lic_id"): frappe.get_meta("Employee").get_field("gratuity_lic_id"),
("Employee", "esic_card_no"): frappe.get_meta("Employee").get_field("esic_card_no"),
("Salary Slip", "esic_no"): frappe.get_meta("Salary Slip").get_field("esic_no"),
("Salary Slip", "pf_no"): frappe.get_meta("Salary Slip").get_field("pf_no")
}
for (doctype, fieldname), df in docfields.items():
if not df:
continue
opts = df.as_dict()
if df.idx >= 2:
opts["insert_after"] = frappe.get_meta(doctype).get("fields")[df.idx - 2].fieldname
frappe.delete_doc("DocField", df.name)
frappe.clear_cache(doctype=doctype)
create_custom_field_if_values_exist(doctype, opts)