added naming series for campaign #1413
diff --git a/erpnext/selling/doctype/campaign/campaign.json b/erpnext/selling/doctype/campaign/campaign.json
index 9b45c6a..83b5d27 100644
--- a/erpnext/selling/doctype/campaign/campaign.json
+++ b/erpnext/selling/doctype/campaign/campaign.json
@@ -1,55 +1,163 @@
 {
+ "_last_update": null, 
+ "_user_tags": null, 
+ "allow_attach": null, 
+ "allow_copy": null, 
+ "allow_email": null, 
  "allow_import": 1, 
+ "allow_print": null, 
  "allow_rename": 1, 
+ "allow_trash": null, 
  "autoname": "field:campaign_name", 
- "creation": "2013-01-10 16:34:18.000000", 
+ "change_log": null, 
+ "client_script": null, 
+ "client_script_core": null, 
+ "client_string": null, 
+ "colour": null, 
+ "creation": "2013-01-10 16:34:18", 
+ "custom": null, 
+ "default_print_format": null, 
  "description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ", 
  "docstatus": 0, 
  "doctype": "DocType", 
  "document_type": "Master", 
+ "dt_template": null, 
  "fields": [
   {
-   "fieldname": "trash_reason", 
-   "fieldtype": "Small Text", 
-   "label": "Trash Reason", 
-   "oldfieldname": "trash_reason", 
-   "oldfieldtype": "Small Text", 
-   "permlevel": 0, 
-   "read_only": 1
-  }, 
-  {
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
    "fieldname": "campaign", 
    "fieldtype": "Section Break", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
    "label": "Campaign", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
    "oldfieldtype": "Section Break", 
-   "permlevel": 0
+   "options": null, 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
   }, 
   {
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "naming_series", 
+   "fieldtype": "Select", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Naming Series", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": null, 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": 1, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
+  {
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
    "fieldname": "campaign_name", 
    "fieldtype": "Data", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
    "label": "Campaign Name", 
+   "no_column": null, 
+   "no_copy": null, 
    "oldfieldname": "campaign_name", 
    "oldfieldtype": "Data", 
+   "options": null, 
    "permlevel": 0, 
-   "reqd": 1
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": 1, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
   }, 
   {
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
    "fieldname": "description", 
    "fieldtype": "Text", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
    "label": "Description", 
+   "no_column": null, 
+   "no_copy": null, 
    "oldfieldname": "description", 
    "oldfieldtype": "Text", 
+   "options": null, 
    "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
    "width": "300px"
   }
  ], 
+ "hide_heading": null, 
+ "hide_toolbar": null, 
  "icon": "icon-bullhorn", 
  "idx": 1, 
- "modified": "2014-01-20 17:48:27.000000", 
+ "in_create": null, 
+ "in_dialog": null, 
+ "is_submittable": null, 
+ "is_transaction_doc": null, 
+ "issingle": null, 
+ "istable": null, 
+ "max_attachments": null, 
+ "menu_index": null, 
+ "modified": "2014-04-16 12:19:51.541872", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Campaign", 
+ "name_case": null, 
  "owner": "Administrator", 
+ "parent": null, 
+ "parent_node": null, 
+ "parentfield": null, 
+ "parenttype": null, 
  "permissions": [
   {
    "amend": 0, 
@@ -57,11 +165,15 @@
    "create": 0, 
    "delete": 0, 
    "email": 1, 
+   "export": null, 
    "import": 0, 
+   "match": null, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 0, 
+   "restrict": null, 
+   "restricted": null, 
    "role": "Sales Manager", 
    "submit": 0, 
    "write": 0
@@ -72,10 +184,15 @@
    "create": 0, 
    "delete": 0, 
    "email": 1, 
+   "export": null, 
+   "import": null, 
+   "match": null, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
+   "restrict": null, 
+   "restricted": null, 
    "role": "Sales User", 
    "submit": 0, 
    "write": 0
@@ -86,13 +203,35 @@
    "create": 1, 
    "delete": 1, 
    "email": 1, 
+   "export": null, 
+   "import": null, 
+   "match": null, 
    "permlevel": 0, 
    "print": 1, 
    "read": 1, 
    "report": 1, 
+   "restrict": null, 
+   "restricted": null, 
    "role": "Sales Master Manager", 
    "submit": 0, 
    "write": 1
   }
- ]
+ ], 
+ "plugin": null, 
+ "print_outline": null, 
+ "read_only": null, 
+ "read_only_onload": null, 
+ "search_fields": null, 
+ "section_style": null, 
+ "server_code": null, 
+ "server_code_compiled": null, 
+ "server_code_core": null, 
+ "server_code_error": null, 
+ "show_in_menu": null, 
+ "smallicon": null, 
+ "subject": null, 
+ "tag_fields": null, 
+ "title_field": null, 
+ "use_template": null, 
+ "version": null
 }
\ No newline at end of file
diff --git a/erpnext/selling/doctype/campaign/campaign.py b/erpnext/selling/doctype/campaign/campaign.py
index 523c62d..88bb782 100644
--- a/erpnext/selling/doctype/campaign/campaign.py
+++ b/erpnext/selling/doctype/campaign/campaign.py
@@ -7,4 +7,8 @@
 from frappe.model.document import Document
 
 class Campaign(Document):
-	pass
\ No newline at end of file
+	def autoname(self):
+		if frappe.defaults.get_global_default('campaign_naming_by') == 'Campaign Name':
+			self.name = self.campaign_name
+		else:
+			self.name = make_autoname(self.naming_series+'.#####')
diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.json b/erpnext/selling/doctype/selling_settings/selling_settings.json
index cc61278..ec3096c 100644
--- a/erpnext/selling/doctype/selling_settings/selling_settings.json
+++ b/erpnext/selling/doctype/selling_settings/selling_settings.json
@@ -1,90 +1,367 @@
 {
- "creation": "2013-06-25 10:25:16.000000",
- "description": "Settings for Selling Module",
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Other",
+ "_last_update": null, 
+ "_user_tags": null, 
+ "allow_attach": null, 
+ "allow_copy": null, 
+ "allow_email": null, 
+ "allow_import": null, 
+ "allow_print": null, 
+ "allow_rename": null, 
+ "allow_trash": null, 
+ "autoname": null, 
+ "change_log": null, 
+ "client_script": null, 
+ "client_script_core": null, 
+ "client_string": null, 
+ "colour": null, 
+ "creation": "2013-06-25 10:25:16", 
+ "custom": null, 
+ "default_print_format": null, 
+ "description": "Settings for Selling Module", 
+ "docstatus": 0, 
+ "doctype": "DocType", 
+ "document_type": "Other", 
+ "dt_template": null, 
  "fields": [
   {
-   "default": "Customer Name",
-   "fieldname": "cust_master_name",
-   "fieldtype": "Select",
-   "label": "Customer Naming By",
-   "options": "Customer Name\nNaming Series",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": "Customer Name", 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "cust_master_name", 
+   "fieldtype": "Select", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Customer Naming By", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "Customer Name\nNaming Series", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "description": "<a href=\"#Sales Browser/Customer Group\">Add / Edit</a>",
-   "fieldname": "customer_group",
-   "fieldtype": "Link",
-   "label": "Default Customer Group",
-   "options": "Customer Group",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "campaign_naming_by", 
+   "fieldtype": "Select", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Campaign Naming By", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "Campaign Name\nNaming Series", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>",
-   "fieldname": "territory",
-   "fieldtype": "Link",
-   "label": "Default Territory",
-   "options": "Territory",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": "<a href=\"#Sales Browser/Customer Group\">Add / Edit</a>", 
+   "fieldname": "customer_group", 
+   "fieldtype": "Link", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Default Customer Group", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "Customer Group", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "selling_price_list",
-   "fieldtype": "Link",
-   "label": "Default Price List",
-   "options": "Price List",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": "<a href=\"#Sales Browser/Territory\">Add / Edit</a>", 
+   "fieldname": "territory", 
+   "fieldtype": "Link", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Default Territory", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "Territory", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "column_break_5",
-   "fieldtype": "Column Break",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "selling_price_list", 
+   "fieldtype": "Link", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": 1, 
+   "label": "Default Price List", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "Price List", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "so_required",
-   "fieldtype": "Select",
-   "label": "Sales Order Required",
-   "options": "No\nYes",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "column_break_5", 
+   "fieldtype": "Column Break", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": null, 
+   "label": null, 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": null, 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "dn_required",
-   "fieldtype": "Select",
-   "label": "Delivery Note Required",
-   "options": "No\nYes",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "so_required", 
+   "fieldtype": "Select", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": null, 
+   "label": "Sales Order Required", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "No\nYes", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "maintain_same_sales_rate",
-   "fieldtype": "Check",
-   "label": "Maintain Same Rate Throughout Sales Cycle",
-   "permlevel": 0
-  },
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "dn_required", 
+   "fieldtype": "Select", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": null, 
+   "label": "Delivery Note Required", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": "No\nYes", 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
   {
-   "fieldname": "editable_price_list_rate",
-   "fieldtype": "Check",
-   "label": "Allow user to edit Price List Rate in transactions",
-   "permlevel": 0
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "maintain_same_sales_rate", 
+   "fieldtype": "Check", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": null, 
+   "label": "Maintain Same Rate Throughout Sales Cycle", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": null, 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
+  }, 
+  {
+   "allow_on_submit": null, 
+   "default": null, 
+   "depends_on": null, 
+   "description": null, 
+   "fieldname": "editable_price_list_rate", 
+   "fieldtype": "Check", 
+   "hidden": null, 
+   "ignore_restrictions": null, 
+   "in_filter": null, 
+   "in_list_view": null, 
+   "label": "Allow user to edit Price List Rate in transactions", 
+   "no_column": null, 
+   "no_copy": null, 
+   "oldfieldname": null, 
+   "oldfieldtype": null, 
+   "options": null, 
+   "permlevel": 0, 
+   "print_hide": null, 
+   "print_width": null, 
+   "read_only": null, 
+   "report_hide": null, 
+   "reqd": null, 
+   "search_index": null, 
+   "set_only_once": null, 
+   "trigger": null, 
+   "width": null
   }
- ],
- "icon": "icon-cog",
- "idx": 1,
- "issingle": 1,
- "modified": "2014-02-19 18:35:36.000000",
- "modified_by": "Administrator",
- "module": "Selling",
- "name": "Selling Settings",
- "owner": "Administrator",
+ ], 
+ "hide_heading": null, 
+ "hide_toolbar": null, 
+ "icon": "icon-cog", 
+ "idx": 1, 
+ "in_create": null, 
+ "in_dialog": null, 
+ "is_submittable": null, 
+ "is_transaction_doc": null, 
+ "issingle": 1, 
+ "istable": null, 
+ "max_attachments": null, 
+ "menu_index": null, 
+ "modified": "2014-04-16 12:21:36.117261", 
+ "modified_by": "Administrator", 
+ "module": "Selling", 
+ "name": "Selling Settings", 
+ "name_case": null, 
+ "owner": "Administrator", 
+ "parent": null, 
+ "parent_node": null, 
+ "parentfield": null, 
+ "parenttype": null, 
  "permissions": [
   {
-   "create": 1,
-   "email": 1,
-   "permlevel": 0,
-   "print": 1,
-   "read": 1,
-   "role": "System Manager",
+   "amend": null, 
+   "cancel": null, 
+   "create": 1, 
+   "delete": null, 
+   "email": 1, 
+   "export": null, 
+   "import": null, 
+   "match": null, 
+   "permlevel": 0, 
+   "print": 1, 
+   "read": 1, 
+   "report": null, 
+   "restrict": null, 
+   "restricted": null, 
+   "role": "System Manager", 
+   "submit": null, 
    "write": 1
   }
- ]
-}
+ ], 
+ "plugin": null, 
+ "print_outline": null, 
+ "read_only": null, 
+ "read_only_onload": null, 
+ "search_fields": null, 
+ "section_style": null, 
+ "server_code": null, 
+ "server_code_compiled": null, 
+ "server_code_core": null, 
+ "server_code_error": null, 
+ "show_in_menu": null, 
+ "smallicon": null, 
+ "subject": null, 
+ "tag_fields": null, 
+ "title_field": null, 
+ "use_template": null, 
+ "version": null
+}
\ No newline at end of file