# DocType, Update Series
[

	# These values are common in all dictionaries
	{
		'creation': '2010-08-08 17:09:29',
		'docstatus': 0,
		'modified': '2010-09-20 14:06:57',
		'modified_by': 'Administrator',
		'owner': 'Administrator'
	},

	# These values are common for all DocType
	{
		'allow_copy': 1,
		'allow_email': 1,
		'allow_print': 1,
		'colour': 'White:FFF',
		'doctype': 'DocType',
		'hide_toolbar': 0,
		'in_create': 1,
		'issingle': 1,
		'module': 'Setup',
		'name': '__common__',
		'read_only': 1,
		'section_style': 'Simple',
		'server_code': 'class DocType:\n  def __init__(self, doc, doclist=[]):\n    self.doc = doc\n    self.doclist = doclist\n\n  def update_series(self):\n    series = sql("select name,current from `tabSeries` where name = %s", self.doc.prefix,as_dict = 1)\n    if series:\n      msgprint("This is going to update Series with Prefix : " + series[0][\'name\'] + " from Current : " + cstr(series[0][\'current\']) + " to Current : "+ cstr(self.doc.current))\n      sql("update `tabSeries` set current = \'%s\' where name = \'%s\'" % (self.doc.current,series[0][\'name\']))\n      msgprint("Series Updated Successfully")\n    else:\n      msgprint("Please Check Prefix as there is no such Prefix : "+ self.doc.prefix +" Or Try Insert Button")\n\n  def insert_series(self):\n    #sql("start transaction")\n    series = sql("select name,current from `tabSeries` where name = %s", self.doc.prefix, as_dict = 1)\n    if series:\n      msgprint("Series with Prefix : " + series[0][\'name\'] + "already in the system . Try Update Button")\n    else:\n      msgprint("This is going to Insert Series with Prefix : " + cstr(self.doc.prefix) + " Current: " + cstr(self.doc.current))\n      sql("insert into `tabSeries` (name,current) values (\'%s\',\'%s\')" % (self.doc.prefix, self.doc.current))\n      msgprint("Series Inserted Successfully")',
		'server_code_error': ' ',
		'show_in_menu': 0,
		'version': 5
	},

	# These values are common for all DocField
	{
		'doctype': 'DocField',
		'name': '__common__',
		'parent': 'Update Series',
		'parentfield': 'fields',
		'parenttype': 'DocType',
		'permlevel': 0
	},

	# These values are common for all DocPerm
	{
		'create': 0,
		'doctype': 'DocPerm',
		'idx': 1,
		'name': '__common__',
		'parent': 'Update Series',
		'parentfield': 'permissions',
		'parenttype': 'DocType',
		'permlevel': 0,
		'read': 1,
		'role': 'System Manager',
		'write': 1
	},

	# DocType, Update Series
	{
		'doctype': 'DocType',
		'name': 'Update Series'
	},

	# DocPerm
	{
		'doctype': 'DocPerm'
	},

	# DocField
	{
		'doctype': 'DocField',
		'fieldname': 'prefix',
		'fieldtype': 'Data',
		'idx': 1,
		'label': 'Prefix'
	},

	# DocField
	{
		'doctype': 'DocField',
		'fieldname': 'current',
		'fieldtype': 'Int',
		'idx': 2,
		'label': 'Current'
	},

	# DocField
	{
		'doctype': 'DocField',
		'fieldtype': 'Button',
		'idx': 3,
		'label': 'Update',
		'options': 'update_series'
	},

	# DocField
	{
		'doctype': 'DocField',
		'fieldtype': 'Button',
		'idx': 4,
		'label': 'Insert',
		'options': 'insert_series'
	}
]