refactor: added naming series for pricing rule
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
index 0be41b4..99c5b34 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.json
@@ -2,12 +2,13 @@
"actions": [],
"allow_import": 1,
"allow_rename": 1,
- "autoname": "field:title",
+ "autoname": "naming_series:",
"creation": "2014-02-21 15:02:51",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"applicability_section",
+ "naming_series",
"title",
"disable",
"apply_on",
@@ -95,8 +96,7 @@
"fieldtype": "Data",
"label": "Title",
"no_copy": 1,
- "reqd": 1,
- "unique": 1
+ "reqd": 1
},
{
"default": "0",
@@ -571,6 +571,13 @@
"fieldname": "is_recursive",
"fieldtype": "Check",
"label": "Is Recursive"
+ },
+ {
+ "default": "PRLE-.####",
+ "fieldname": "naming_series",
+ "fieldtype": "Select",
+ "label": "Naming Series",
+ "options": "PRLE-.####"
}
],
"icon": "fa fa-gift",
@@ -634,5 +641,6 @@
],
"show_name_in_global_search": 1,
"sort_field": "modified",
- "sort_order": "DESC"
-}
\ No newline at end of file
+ "sort_order": "DESC",
+ "title_field": "title"
+}
diff --git a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
index 53239fe..f4ee188 100644
--- a/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
+++ b/erpnext/accounts/doctype/promotional_scheme/promotional_scheme.py
@@ -81,7 +81,7 @@
new_doc = []
args = get_args_for_pricing_rule(doc)
applicable_for = frappe.scrub(doc.get('applicable_for'))
- for d in doc.get(child_doc):
+ for idx, d in enumerate(doc.get(child_doc)):
if d.name in rules:
for applicable_for_value in args.get(applicable_for):
temp_args = args.copy()
@@ -93,24 +93,24 @@
applicable_for: applicable_for_value
}
)
-
+
if docname:
pr = frappe.get_doc('Pricing Rule', docname[0].get('name'))
temp_args[applicable_for] = applicable_for_value
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
else:
pr = frappe.new_doc("Pricing Rule")
- pr.title = make_autoname("{0}/.####".format(doc.name))
+ pr.title = doc.name
temp_args[applicable_for] = applicable_for_value
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
-
+
new_doc.append(pr)
-
+
else:
for i in range(len(args.get(applicable_for))) :
pr = frappe.new_doc("Pricing Rule")
- pr.title = make_autoname("{0}/.####".format(doc.name))
+ pr.title = doc.name
temp_args = args.copy()
temp_args[applicable_for] = args[applicable_for][i]
pr = set_args(temp_args, pr, doc, child_doc, discount_fields, d)
@@ -144,13 +144,13 @@
def get_args_for_pricing_rule(doc):
args = { 'promotional_scheme': doc.name }
applicable_for = frappe.scrub(doc.get('applicable_for'))
-
+
for d in pricing_rule_fields:
if d == applicable_for:
items = []
for applicable_for_values in doc.get(applicable_for):
- items.append(applicable_for_values.get(applicable_for))
- args[d] = items
+ items.append(applicable_for_values.get(applicable_for))
+ args[d] = items
else:
args[d] = doc.get(d)
return args