[fixes] setup wizard and other fixes related to cart
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js
index d7a4f5a..8828e0c 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/sales_taxes_and_charges_template.js
@@ -5,6 +5,3 @@
{% include "public/js/controllers/accounts.js" %}
-frappe.ui.form.on("Sales Taxes and Charges Template", "onload", function(frm) {
- erpnext.add_applicable_territory();
-});
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json
index 69dbd8e..2b737b9 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges_template/test_records.json
@@ -20,19 +20,7 @@
"rate": 6.36
}
],
- "title": "_Test Sales Taxes and Charges Template",
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "All Territories"
- },
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
+ "title": "_Test Sales Taxes and Charges Template"
},
{
"company": "_Test Company",
@@ -115,14 +103,7 @@
"row_id": 7
}
],
- "title": "_Test India Tax Master",
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory India"
- }
- ]
+ "title": "_Test India Tax Master"
},
{
"company": "_Test Company",
@@ -145,14 +126,7 @@
"rate": 4
}
],
- "title": "_Test Sales Taxes and Charges Template - Rest of the World",
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
+ "title": "_Test Sales Taxes and Charges Template - Rest of the World"
},
{
"company": "_Test Company",
@@ -175,14 +149,7 @@
"rate": 4
}
],
- "title": "_Test Sales Taxes and Charges Template 1",
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
+ "title": "_Test Sales Taxes and Charges Template 1"
},
{
"company": "_Test Company",
@@ -205,14 +172,7 @@
"rate": 4
}
],
- "title": "_Test Sales Taxes and Charges Template 2",
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
+ "title": "_Test Sales Taxes and Charges Template 2"
},
{
"doctype" : "Sales Taxes and Charges Template",
@@ -224,9 +184,6 @@
"cost_center": "Main - _TC",
"description": "Test Shopping cart taxes with Tax Rule",
"tax_amount": 1000
- }],
- "territories":[{
- "territory" : "All Territories"
}]
},
{
@@ -239,9 +196,6 @@
"cost_center": "Main - _TC",
"description": "Test Shopping cart taxes with Tax Rule",
"tax_amount": 200
- }],
- "territories":[{
- "territory" : "All Territories"
}]
}
]
diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.js b/erpnext/accounts/doctype/shipping_rule/shipping_rule.js
index 233bea1..17f2083 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.js
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.js
@@ -1,8 +1,3 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-$.extend(cur_frm.cscript, {
- onload: function() {
- erpnext.add_applicable_territory();
- }
-});
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.json b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json
index be65baf..1c5d979 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.json
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.json
@@ -1,397 +1,397 @@
{
- "allow_copy": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "autoname": "field:label",
- "creation": "2013-06-25 11:48:03",
- "custom": 0,
- "description": "Specify conditions to calculate shipping amount",
- "docstatus": 0,
- "doctype": "DocType",
+ "allow_copy": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "field:label",
+ "creation": "2013-06-25 11:48:03",
+ "custom": 0,
+ "description": "Specify conditions to calculate shipping amount",
+ "docstatus": 0,
+ "doctype": "DocType",
"fields": [
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "description": "example: Next Day Shipping",
- "fieldname": "label",
- "fieldtype": "Data",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Shipping Rule Label",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "description": "example: Next Day Shipping",
+ "fieldname": "label",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Shipping Rule Label",
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "disabled",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Disabled",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "disabled",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Disabled",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "default": "Net Total",
- "fieldname": "calculate_based_on",
- "fieldtype": "Select",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Calculate Based On",
- "no_copy": 0,
- "options": "Net Total\nNet Weight",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "default": "Net Total",
+ "fieldname": "calculate_based_on",
+ "fieldtype": "Select",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Calculate Based On",
+ "no_copy": 0,
+ "options": "Net Total\nNet Weight",
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "depends_on": "eval:!doc.disabled",
- "fieldname": "rule_conditions_section",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Shipping Rule Conditions",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "eval:!doc.disabled",
+ "fieldname": "rule_conditions_section",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Shipping Rule Conditions",
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "conditions",
- "fieldtype": "Table",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Shipping Rule Conditions",
- "no_copy": 0,
- "options": "Shipping Rule Condition",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "conditions",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Shipping Rule Conditions",
+ "no_copy": 0,
+ "options": "Shipping Rule Condition",
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "depends_on": "eval:!doc.disabled",
- "fieldname": "section_break_6",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Valid for Countries",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "eval:!doc.disabled",
+ "fieldname": "section_break_6",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Valid for Countries",
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "worldwide_shipping",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Worldwide Shipping",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "worldwide_shipping",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Worldwide Shipping",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "depends_on": "eval:!doc.worldwide_shipping",
- "fieldname": "countries",
- "fieldtype": "Table",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Valid for Countries",
- "no_copy": 0,
- "options": "Shipping Rule Country",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "eval:!doc.worldwide_shipping",
+ "fieldname": "countries",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Valid for Countries",
+ "no_copy": 0,
+ "options": "Shipping Rule Country",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "depends_on": "eval:!doc.disabled",
- "fieldname": "section_break_10",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "depends_on": "eval:!doc.disabled",
+ "fieldname": "section_break_10",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "company",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Company",
- "no_copy": 0,
- "options": "Company",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Company",
+ "no_copy": 0,
+ "options": "Company",
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "column_break_12",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "column_break_12",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "account",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Shipping Account",
- "no_copy": 0,
- "options": "Account",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "account",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Shipping Account",
+ "no_copy": 0,
+ "options": "Account",
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "cost_center",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Cost Center",
- "no_copy": 0,
- "options": "Cost Center",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Cost Center",
+ "no_copy": 0,
+ "options": "Cost Center",
+ "permlevel": 0,
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
}
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "icon-truck",
- "idx": 1,
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "modified": "2015-09-17 08:30:57.226342",
- "modified_by": "Administrator",
- "module": "Accounts",
- "name": "Shipping Rule",
- "owner": "Administrator",
+ ],
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "icon": "icon-truck",
+ "idx": 1,
+ "in_create": 0,
+ "in_dialog": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "modified": "2015-09-22 08:30:57.226342",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Shipping Rule",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 0,
- "apply_user_permissions": 1,
- "cancel": 0,
- "create": 0,
- "delete": 0,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Accounts User",
- "set_user_permissions": 0,
- "share": 0,
- "submit": 0,
+ "amend": 0,
+ "apply_user_permissions": 1,
+ "cancel": 0,
+ "create": 0,
+ "delete": 0,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Accounts User",
+ "set_user_permissions": 0,
+ "share": 0,
+ "submit": 0,
"write": 0
- },
+ },
{
- "amend": 0,
- "apply_user_permissions": 1,
- "cancel": 0,
- "create": 0,
- "delete": 0,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Sales User",
- "set_user_permissions": 0,
- "share": 0,
- "submit": 0,
+ "amend": 0,
+ "apply_user_permissions": 1,
+ "cancel": 0,
+ "create": 0,
+ "delete": 0,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales User",
+ "set_user_permissions": 0,
+ "share": 0,
+ "submit": 0,
"write": 0
- },
+ },
{
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Accounts Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "amend": 0,
+ "apply_user_permissions": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Accounts Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
"write": 1
- },
+ },
{
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Sales Master Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
+ "amend": 0,
+ "apply_user_permissions": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales Master Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
"write": 1
}
- ],
- "read_only": 0,
+ ],
+ "read_only": 0,
"read_only_onload": 0
-}
\ No newline at end of file
+}
diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
index a2ee820..80e4fb7 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
@@ -25,6 +25,9 @@
if self.worldwide_shipping:
self.countries = []
+ elif not len([d.country for d in self.countries if d.country]):
+ frappe.throw(_("Please specify a country for this Shipping Rule or check Worldwide Shipping"))
+
def validate_from_to_values(self):
zero_to_values = []
diff --git a/erpnext/accounts/doctype/shipping_rule/test_records.json b/erpnext/accounts/doctype/shipping_rule/test_records.json
index 96e7770..a271009 100644
--- a/erpnext/accounts/doctype/shipping_rule/test_records.json
+++ b/erpnext/accounts/doctype/shipping_rule/test_records.json
@@ -1,116 +1,100 @@
[
{
- "account": "_Test Account Shipping Charges - _TC",
- "calculate_based_on": "Net Total",
- "company": "_Test Company",
- "cost_center": "_Test Cost Center - _TC",
- "doctype": "Shipping Rule",
- "label": "_Test Shipping Rule",
- "name": "_Test Shipping Rule",
+ "account": "_Test Account Shipping Charges - _TC",
+ "calculate_based_on": "Net Total",
+ "company": "_Test Company",
+ "cost_center": "_Test Cost Center - _TC",
+ "doctype": "Shipping Rule",
+ "label": "_Test Shipping Rule",
+ "name": "_Test Shipping Rule",
"conditions": [
{
- "doctype": "Shipping Rule Condition",
- "from_value": 0,
- "parentfield": "conditions",
- "shipping_amount": 50.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 0,
+ "parentfield": "conditions",
+ "shipping_amount": 50.0,
"to_value": 100
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 101,
- "parentfield": "conditions",
- "shipping_amount": 100.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 101,
+ "parentfield": "conditions",
+ "shipping_amount": 100.0,
"to_value": 200
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 201,
- "parentfield": "conditions",
+ "doctype": "Shipping Rule Condition",
+ "from_value": 201,
+ "parentfield": "conditions",
"shipping_amount": 0.0
}
- ],
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory"
- }
- ]
- },
+ ],
+ "worldwide_shipping": 1
+ },
{
- "account": "_Test Account Shipping Charges - _TC",
- "calculate_based_on": "Net Total",
- "company": "_Test Company",
- "cost_center": "_Test Cost Center - _TC",
- "doctype": "Shipping Rule",
- "label": "_Test Shipping Rule - India",
- "name": "_Test Shipping Rule - India",
+ "account": "_Test Account Shipping Charges - _TC",
+ "calculate_based_on": "Net Total",
+ "company": "_Test Company",
+ "cost_center": "_Test Cost Center - _TC",
+ "doctype": "Shipping Rule",
+ "label": "_Test Shipping Rule - India",
+ "name": "_Test Shipping Rule - India",
"conditions": [
{
- "doctype": "Shipping Rule Condition",
- "from_value": 0,
- "parentfield": "conditions",
- "shipping_amount": 50.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 0,
+ "parentfield": "conditions",
+ "shipping_amount": 50.0,
"to_value": 100
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 101,
- "parentfield": "conditions",
- "shipping_amount": 100.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 101,
+ "parentfield": "conditions",
+ "shipping_amount": 100.0,
"to_value": 200
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 201,
- "parentfield": "conditions",
+ "doctype": "Shipping Rule Condition",
+ "from_value": 201,
+ "parentfield": "conditions",
"shipping_amount": 0.0
}
- ],
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory India"
- }
+ ],
+ "countries": [
+ {"country": "India"}
]
- },
+ },
{
- "account": "_Test Account Shipping Charges - _TC",
- "calculate_based_on": "Net Total",
- "company": "_Test Company",
- "cost_center": "_Test Cost Center - _TC",
- "doctype": "Shipping Rule",
- "label": "_Test Shipping Rule - Rest of the World",
- "name": "_Test Shipping Rule - Rest of the World",
+ "account": "_Test Account Shipping Charges - _TC",
+ "calculate_based_on": "Net Total",
+ "company": "_Test Company",
+ "cost_center": "_Test Cost Center - _TC",
+ "doctype": "Shipping Rule",
+ "label": "_Test Shipping Rule - Rest of the World",
+ "name": "_Test Shipping Rule - Rest of the World",
"conditions": [
{
- "doctype": "Shipping Rule Condition",
- "from_value": 0,
- "parentfield": "conditions",
- "shipping_amount": 500.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 0,
+ "parentfield": "conditions",
+ "shipping_amount": 500.0,
"to_value": 1000
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 1001,
- "parentfield": "conditions",
- "shipping_amount": 1000.0,
+ "doctype": "Shipping Rule Condition",
+ "from_value": 1001,
+ "parentfield": "conditions",
+ "shipping_amount": 1000.0,
"to_value": 2000
- },
+ },
{
- "doctype": "Shipping Rule Condition",
- "from_value": 2001,
- "parentfield": "conditions",
+ "doctype": "Shipping Rule Condition",
+ "from_value": 2001,
+ "parentfield": "conditions",
"shipping_amount": 1500.0
}
- ],
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
+ ],
+ "worldwide_shipping": 1
}
-]
\ No newline at end of file
+]
diff --git a/erpnext/accounts/doctype/tax_rule/tax_rule.py b/erpnext/accounts/doctype/tax_rule/tax_rule.py
index 0a9bb11..1e306e9 100644
--- a/erpnext/accounts/doctype/tax_rule/tax_rule.py
+++ b/erpnext/accounts/doctype/tax_rule/tax_rule.py
@@ -5,6 +5,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
+from frappe.model import default_fields
from frappe.model.document import Document
from frappe.utils import cstr
@@ -13,6 +14,9 @@
class ConflictingTaxRule(frappe.ValidationError): pass
class TaxRule(Document):
+ def __setup__(self):
+ self.flags.ignore_these_exceptions_in_test = [ConflictingTaxRule]
+
def validate(self):
self.validate_tax_template()
self.validate_customer_group()
@@ -25,7 +29,7 @@
self.purchase_tax_template = self.supplier = self.supplier_type= None
else:
self.sales_tax_template= self.customer = self.customer_group= None
-
+
if not (self.sales_tax_template or self.purchase_tax_template):
frappe.throw(_("Tax Template is mandatory."))
@@ -34,7 +38,7 @@
if not frappe.db.get_value("Customer", self.customer, "customer_group") == self.customer_group:
frappe.throw(_("Customer {0} does not belong to customer group {1}"). \
format(self.customer, self.customer_group), IncorrectCustomerGroup)
-
+
def validate_supplier_type(self):
if self.supplier and self.supplier_type:
if not frappe.db.get_value("Supplier", self.supplier, "supplier_type") == self.supplier_type:
@@ -60,28 +64,28 @@
"shipping_country": self.shipping_country,
"company": self.company
}
-
+
conds=""
for d in filters:
if conds:
conds += " and "
conds += """ifnull({0}, '') = '{1}'""".format(d, frappe.db.escape(cstr(filters[d])))
-
+
if self.from_date and self.to_date:
conds += """ and ((from_date > '{from_date}' and from_date < '{to_date}') or
(to_date > '{from_date}' and to_date < '{to_date}') or
('{from_date}' > from_date and '{from_date}' < to_date) or
('{from_date}' = from_date and '{to_date}' = to_date))""".format(from_date=self.from_date, to_date=self.to_date)
-
+
elif self.from_date and not self.to_date:
conds += """ and to_date > '{from_date}'""".format(from_date = self.from_date)
elif self.to_date and not self.from_date:
conds += """ and from_date < '{to_date}'""".format(to_date = self.to_date)
-
+
tax_rule = frappe.db.sql("select name, priority \
- from `tabTax Rule` where {0} and name != '{1}'".format(conds, self.name), as_dict=1)
-
+ from `tabTax Rule` where {0} and name != '{1}'".format(conds, self.name), as_dict=1)
+
if tax_rule:
if tax_rule[0].priority == self.priority:
frappe.throw(_("Tax Rule Conflicts with {0}".format(tax_rule[0].name)), ConflictingTaxRule)
@@ -95,10 +99,10 @@
else:
billing_filters= {party_type: party, "is_primary_address": 1}
shipping_filters= {party_type:party, "is_shipping_address": 1}
-
+
billing_address= frappe.get_all("Address", fields=["city", "state", "country"], filters= billing_filters)
shipping_address= frappe.get_all("Address", fields=["city", "state", "country"], filters= shipping_filters)
-
+
if billing_address:
out["billing_city"]= billing_address[0].city
out["billing_state"]= billing_address[0].state
@@ -108,7 +112,7 @@
out["shipping_city"]= shipping_address[0].city
out["shipping_state"]= shipping_address[0].state
out["shipping_country"]= shipping_address[0].country
-
+
return out
def get_tax_template(posting_date, args):
@@ -121,14 +125,14 @@
matching = frappe.db.sql("""select * from `tabTax Rule`
where {0}""".format(" and ".join(conditions)), as_dict = True)
-
+
if not matching:
return None
-
+
for rule in matching:
rule.no_of_keys_matched = 0
for key in args:
if rule.get(key): rule.no_of_keys_matched += 1
-
+
rule = sorted(matching, lambda b, a: cmp(a.no_of_keys_matched, b.no_of_keys_matched) or cmp(a.priority, b.priority))[0]
- return rule.sales_tax_template or rule.purchase_tax_template
\ No newline at end of file
+ return rule.sales_tax_template or rule.purchase_tax_template
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 68a447b..7f69202 100644
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -49,18 +49,6 @@
}
},
- add_applicable_territory: function() {
- if(cur_frm.doc.__islocal && (cur_frm.doc.territories || []).length===0) {
- var default_territory = frappe.defaults.get_user_default("territory");
- if(default_territory) {
- var territory = frappe.model.add_child(cur_frm.doc, "Applicable Territory",
- "territories");
- territory.territory = default_territory;
- }
-
- }
- },
-
setup_serial_no: function() {
var grid_row = cur_frm.open_grid_row();
if(!grid_row.fields_dict.serial_no ||
@@ -131,8 +119,8 @@
}
);
}
- },
-
+ },
+
copy_value_in_all_row: function(doc, dt, dn, table_fieldname, fieldname) {
var d = locals[dt][dn];
if(d[fieldname]){
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index 77ad90a..a137033 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -174,10 +174,7 @@
"enabled": 1,
"buying": 1 if pl_type == "Buying" else 0,
"selling": 1 if pl_type == "Selling" else 0,
- "currency": args["currency"],
- "territories": [{
- "territory": get_root_of("Territory")
- }]
+ "currency": args["currency"]
}).insert()
def set_defaults(args):
@@ -304,7 +301,7 @@
return fy
def create_taxes(args):
-
+
for i in xrange(1,6):
if args.get("tax_" + str(i)):
# replace % in case someone also enters the % symbol
@@ -324,7 +321,7 @@
raise
except RootNotEditable, e:
pass
-
+
def make_tax_head(args, i, tax_group, tax_rate):
return frappe.get_doc({
"doctype":"Account",
diff --git a/erpnext/shopping_cart/__init__.py b/erpnext/shopping_cart/__init__.py
index 1858c0d..db44f94 100644
--- a/erpnext/shopping_cart/__init__.py
+++ b/erpnext/shopping_cart/__init__.py
@@ -1,103 +1,2 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.utils import get_fullname, flt
-from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import check_shopping_cart_enabled, get_default_territory
-
-# TODO
-# validate stock of each item in Website Warehouse or have a list of possible warehouses in Shopping Cart Settings
-# Below functions are used for test cases
-
-def get_quotation(user=None):
- if not user:
- user = frappe.session.user
- if user == "Guest":
- raise frappe.PermissionError
-
- check_shopping_cart_enabled()
- party = get_party(user)
- values = {
- "order_type": "Shopping Cart",
- party.doctype.lower(): party.name,
- "docstatus": 0,
- "contact_email": user,
- "selling_price_list": "_Test Price List Rest of the World",
- "currency": "USD"
- }
-
- try:
- quotation = frappe.get_doc("Quotation", values)
-
- except frappe.DoesNotExistError:
- quotation = frappe.new_doc("Quotation")
- quotation.update(values)
- if party.doctype == "Customer":
- quotation.contact_person = frappe.db.get_value("Contact", {"customer": party.name, "email_id": user})
- quotation.insert(ignore_permissions=True)
-
- return quotation
-
-def set_item_in_cart(item_code, qty, user=None):
- validate_item(item_code)
- quotation = get_quotation(user=user)
- qty = flt(qty)
- quotation_item = quotation.get("items", {"item_code": item_code})
- if qty==0:
- if quotation_item:
- # remove
- quotation.get("items").remove(quotation_item[0])
- else:
- # add or update
- if quotation_item:
- quotation_item[0].qty = qty
- else:
- quotation.append("items", {
- "doctype": "Quotation Item",
- "item_code": item_code,
- "qty": qty
- })
- quotation.save(ignore_permissions=True)
- return quotation
-
-def validate_item(item_code):
- item = frappe.db.get_value("Item", item_code, ["item_name", "show_in_website"], as_dict=True)
- if not item.show_in_website:
- frappe.throw(_("{0} cannot be purchased using Shopping Cart").format(item.item_name))
-
-def get_party(user):
- def _get_party(user):
- customer = frappe.db.get_value("Contact", {"email_id": user}, "customer")
- if customer:
- return frappe.get_doc("Customer", customer)
-
- lead = frappe.db.get_value("Lead", {"email_id": user})
- if lead:
- return frappe.get_doc("Lead", lead)
-
- # create a lead
- lead = frappe.new_doc("Lead")
- lead.update({
- "email_id": user,
- "lead_name": get_fullname(user),
- "territory": guess_territory()
- })
- lead.insert(ignore_permissions=True)
-
- return lead
-
- if not getattr(frappe.local, "shopping_cart_party", None):
- frappe.local.shopping_cart_party = {}
-
- if not frappe.local.shopping_cart_party.get(user):
- frappe.local.shopping_cart_party[user] = _get_party(user)
-
- return frappe.local.shopping_cart_party[user]
-
-def guess_territory():
- territory = None
- if frappe.session.get("session_country"):
- territory = frappe.db.get_value("Territory", frappe.session.get("session_country"))
- return territory or get_default_territory()
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index 74d9e64..b6acf20 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -17,19 +17,19 @@
if not quotation:
quotation = _get_cart_quotation()
cart_count = cstr(len(quotation.get("items")))
- frappe.local.cookie_manager.set_cookie("cart_count", cart_count)
+
+ if hasattr(frappe.local, "cookie_manager"):
+ frappe.local.cookie_manager.set_cookie("cart_count", cart_count)
@frappe.whitelist()
def get_cart_quotation(doc=None):
- party = get_lead_or_customer()
+ party = get_customer()
if not doc:
quotation = _get_cart_quotation(party)
doc = quotation
set_cart_count(quotation)
- print get_applicable_shipping_rules(party)
-
return {
"doc": decorate_quotation_doc(doc),
"addresses": [{"name": address.name, "display": address.display}
@@ -60,7 +60,9 @@
sales_order.flags.ignore_permissions = True
sales_order.insert()
sales_order.submit()
- frappe.local.cookie_manager.delete_cookie("cart_count")
+
+ if hasattr(frappe.local, "cookie_manager"):
+ frappe.local.cookie_manager.delete_cookie("cart_count")
return sales_order.name
@@ -156,7 +158,7 @@
def _get_cart_quotation(party=None):
if not party:
- party = get_lead_or_customer()
+ party = get_customer()
quotation = frappe.db.get_value("Quotation",
{party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0})
@@ -176,9 +178,9 @@
(party.doctype.lower()): party.name
})
- if party.doctype == "Customer":
- qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
- "customer": party.name})
+ qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
+ "customer": party.name})
+ qdoc.contact_email = frappe.session.user
qdoc.flags.ignore_permissions = True
qdoc.run_method("set_missing_values")
@@ -187,27 +189,21 @@
return qdoc
def update_party(fullname, company_name=None, mobile_no=None, phone=None):
- party = get_lead_or_customer()
+ party = get_customer()
- if party.doctype == "Lead":
- party.company_name = company_name
- party.lead_name = fullname
- party.mobile_no = mobile_no
- party.phone = phone
- else:
- party.customer_name = company_name or fullname
- party.customer_type == "Company" if company_name else "Individual"
+ party.customer_name = company_name or fullname
+ party.customer_type == "Company" if company_name else "Individual"
- contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
- "customer": party.name})
- contact = frappe.get_doc("Contact", contact_name)
- contact.first_name = fullname
- contact.last_name = None
- contact.customer_name = party.customer_name
- contact.mobile_no = mobile_no
- contact.phone = phone
- contact.flags.ignore_permissions = True
- contact.save()
+ contact_name = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
+ "customer": party.name})
+ contact = frappe.get_doc("Contact", contact_name)
+ contact.first_name = fullname
+ contact.last_name = None
+ contact.customer_name = party.customer_name
+ contact.mobile_no = mobile_no
+ contact.phone = phone
+ contact.flags.ignore_permissions = True
+ contact.save()
party_doc = frappe.get_doc(party.as_dict())
party_doc.flags.ignore_permissions = True
@@ -222,7 +218,7 @@
def apply_cart_settings(party=None, quotation=None):
if not party:
- party = get_lead_or_customer()
+ party = get_customer()
if not quotation:
quotation = _get_cart_quotation(party)
@@ -250,8 +246,9 @@
# refetch values
quotation.run_method("set_price_list_and_item_details")
- # set it in cookies for using in product page
- frappe.local.cookie_manager.set_cookie("selling_price_list", quotation.selling_price_list)
+ if hasattr(frappe.local, "cookie_manager"):
+ # set it in cookies for using in product page
+ frappe.local.cookie_manager.set_cookie("selling_price_list", quotation.selling_price_list)
def _set_price_list(quotation, cart_settings):
"""Set price list based on customer or shopping cart default"""
@@ -286,32 +283,38 @@
# # append taxes
quotation.append_taxes_from_master()
-def get_lead_or_customer():
- customer = frappe.db.get_value("Contact", {"email_id": frappe.session.user}, "customer")
+def get_customer(user=None):
+ if not user:
+ user = frappe.session.user
+
+ customer = frappe.db.get_value("Contact", {"email_id": user}, "customer")
if customer:
return frappe.get_doc("Customer", customer)
- lead = frappe.db.get_value("Lead", {"email_id": frappe.session.user})
- if lead:
- return frappe.get_doc("Lead", lead)
else:
- lead_doc = frappe.get_doc({
- "doctype": "Lead",
- "email_id": frappe.session.user,
- "lead_name": get_fullname(frappe.session.user),
- "territory": guess_territory(),
- "status": "Open" # TODO: set something better???
+ customer = frappe.new_doc("Customer")
+ fullname = get_fullname(user)
+ customer.update({
+ "customer_name": fullname,
+ "customer_type": "Individual",
+ "customer_group": get_shopping_cart_settings().default_customer_group,
+ "territory": get_root_of("Territory")
})
+ customer.insert(ignore_permissions=True)
- if frappe.session.user not in ("Guest", "Administrator"):
- lead_doc.flags.ignore_permissions = True
- lead_doc.insert()
+ contact = frappe.new_doc("Contact")
+ contact.update({
+ "customer": customer.name,
+ "first_name": fullname,
+ "email_id": user
+ })
+ contact.insert(ignore_permissions=True)
- return lead_doc
+ return customer
def get_address_docs(doctype=None, txt=None, filters=None, limit_start=0, limit_page_length=20, party=None):
if not party:
- party = get_lead_or_customer()
+ party = get_customer()
address_docs = frappe.db.sql("""select * from `tabAddress`
where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(),
diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py
index 4fac3a8..d8d00ef 100644
--- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py
+++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py
@@ -8,7 +8,6 @@
from frappe import _, msgprint
from frappe.utils import comma_and
from frappe.model.document import Document
-from frappe.utils.nestedset import get_root_of
class ShoppingCartSetupError(frappe.ValidationError): pass
@@ -75,9 +74,6 @@
def is_cart_enabled():
return get_shopping_cart_settings().enabled
-def get_default_territory():
- return get_shopping_cart_settings().default_territory or get_root_of("Territory")
-
def check_shopping_cart_enabled():
if not get_shopping_cart_settings().enabled:
frappe.throw(_("You need to enable Shopping Cart"), ShoppingCartSetupError)
diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/test_shopping_cart_settings.py b/erpnext/shopping_cart/doctype/shopping_cart_settings/test_shopping_cart_settings.py
index 66be927..10bbcfe 100644
--- a/erpnext/shopping_cart/doctype/shopping_cart_settings/test_shopping_cart_settings.py
+++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/test_shopping_cart_settings.py
@@ -19,14 +19,14 @@
def test_exchange_rate_exists(self):
frappe.db.sql("""delete from `tabCurrency Exchange`""")
- cart_settings = self.test_price_list_territory_overlap()
- controller = cart_settings
- self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist)
+ cart_settings = self.get_cart_settings()
+ cart_settings.price_list = "_Test Price List Rest of the World"
+ self.assertRaises(ShoppingCartSetupError, cart_settings.validate_exchange_rates_exist)
from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records as \
currency_exchange_records
frappe.get_doc(currency_exchange_records[0]).insert()
- controller.validate_exchange_rates_exist()
+ cart_settings.validate_exchange_rates_exist()
def test_tax_rule_validation(self):
frappe.db.sql("update `tabTax Rule` set use_for_shopping_cart = 0")
diff --git a/erpnext/shopping_cart/test_shopping_cart.py b/erpnext/shopping_cart/test_shopping_cart.py
index dc3b4fe..61536ac 100644
--- a/erpnext/shopping_cart/test_shopping_cart.py
+++ b/erpnext/shopping_cart/test_shopping_cart.py
@@ -4,7 +4,7 @@
from __future__ import unicode_literals
import unittest
import frappe
-from erpnext.shopping_cart import get_quotation, set_item_in_cart, get_party
+from erpnext.shopping_cart.cart import _get_cart_quotation, update_cart, get_customer
class TestShoppingCart(unittest.TestCase):
"""
@@ -23,23 +23,11 @@
self.login_as_new_user()
# test if lead is created and quotation with new lead is fetched
- quotation = get_quotation()
- self.assertEquals(quotation.quotation_to, "Lead")
- self.assertEquals(frappe.db.get_value("Lead", quotation.lead, "email_id"),
+ quotation = _get_cart_quotation()
+ self.assertEquals(quotation.quotation_to, "Customer")
+ self.assertEquals(frappe.db.get_value("Contact", {"customer": quotation.customer}, "email_id"),
"test_cart_user@example.com")
- self.assertEquals(quotation.customer, None)
- self.assertEquals(quotation.contact_email, frappe.session.user)
-
- return quotation
-
- def test_get_cart_lead(self):
- self.login_as_lead()
-
- # test if quotation with lead is fetched
- quotation = get_quotation()
- self.assertEquals(quotation.quotation_to, "Lead")
- self.assertEquals(quotation.lead, frappe.db.get_value("Lead", {"email_id": "test_cart_lead@example.com"}))
- self.assertEquals(quotation.customer, None)
+ self.assertEquals(quotation.lead, None)
self.assertEquals(quotation.contact_email, frappe.session.user)
return quotation
@@ -48,7 +36,7 @@
self.login_as_customer()
# test if quotation with customer is fetched
- quotation = get_quotation()
+ quotation = _get_cart_quotation()
self.assertEquals(quotation.quotation_to, "Customer")
self.assertEquals(quotation.customer, "_Test Customer")
self.assertEquals(quotation.lead, None)
@@ -57,21 +45,21 @@
return quotation
def test_add_to_cart(self):
- self.login_as_lead()
+ self.login_as_customer()
# remove from cart
self.remove_all_items_from_cart()
# add first item
- set_item_in_cart("_Test Item", 1)
- quotation = self.test_get_cart_lead()
+ update_cart("_Test Item", 1)
+ quotation = self.test_get_cart_customer()
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("items")[0].qty, 1)
self.assertEquals(quotation.get("items")[0].amount, 10)
# add second item
- set_item_in_cart("_Test Item 2", 1)
- quotation = self.test_get_cart_lead()
+ update_cart("_Test Item 2", 1)
+ quotation = self.test_get_cart_customer()
self.assertEquals(quotation.get("items")[1].item_code, "_Test Item 2")
self.assertEquals(quotation.get("items")[1].qty, 1)
self.assertEquals(quotation.get("items")[1].amount, 20)
@@ -83,8 +71,8 @@
self.test_add_to_cart()
# update first item
- set_item_in_cart("_Test Item", 5)
- quotation = self.test_get_cart_lead()
+ update_cart("_Test Item", 5)
+ quotation = self.test_get_cart_customer()
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item")
self.assertEquals(quotation.get("items")[0].qty, 5)
self.assertEquals(quotation.get("items")[0].amount, 50)
@@ -96,8 +84,8 @@
self.test_add_to_cart()
# remove first item
- set_item_in_cart("_Test Item", 0)
- quotation = self.test_get_cart_lead()
+ update_cart("_Test Item", 0)
+ quotation = self.test_get_cart_customer()
self.assertEquals(quotation.get("items")[0].item_code, "_Test Item 2")
self.assertEquals(quotation.get("items")[0].qty, 1)
self.assertEquals(quotation.get("items")[0].amount, 20)
@@ -105,11 +93,11 @@
self.assertEquals(len(quotation.get("items")), 1)
# remove second item
- set_item_in_cart("_Test Item 2", 0)
- quotation = self.test_get_cart_lead()
- self.assertEquals(quotation.net_total, 0)
- self.assertEquals(len(quotation.get("items")), 0)
+ update_cart("_Test Item 2", 0)
+ quotation = self.test_get_cart_customer()
+ self.assertEquals(len(quotation.get("items")), 0)
+ self.assertEquals(quotation.net_total, 0)
def test_tax_rule(self):
self.login_as_customer()
@@ -133,7 +121,7 @@
"doctype": "Quotation",
"quotation_to": "Customer",
"order_type": "Shopping Cart",
- "customer": get_party(frappe.session.user).name,
+ "customer": get_customer(frappe.session.user).name,
"docstatus": 0,
"contact_email": frappe.session.user,
"selling_price_list": "_Test Price List Rest of the World",
@@ -167,20 +155,10 @@
settings.update({
"enabled": 1,
"company": "_Test Company",
- "default_territory": "_Test Territory Rest Of The World",
"default_customer_group": "_Test Customer Group",
- "quotation_series": "_T-Quotation-"
+ "quotation_series": "_T-Quotation-",
+ "price_list": "_Test Price List India"
})
- settings.set("price_lists", [
- # price lists
- {"doctype": "Shopping Cart Price List", "parentfield": "price_lists",
- "selling_price_list": "_Test Price List India"},
- {"doctype": "Shopping Cart Price List", "parentfield": "price_lists",
- "selling_price_list": "_Test Price List Rest of the World"}
- ])
- settings.set("shipping_rules", {"doctype": "Shopping Cart Shipping Rule", "parentfield": "shipping_rules",
- "shipping_rule": "_Test Shipping Rule - India"})
-
settings.save()
frappe.local.shopping_cart_settings = None
@@ -194,54 +172,11 @@
def login_as_new_user(self):
frappe.set_user("test_cart_user@example.com")
- def login_as_lead(self):
- self.create_lead()
- frappe.set_user("test_cart_lead@example.com")
-
def login_as_customer(self):
frappe.set_user("test_contact_customer@example.com")
- def create_lead(self):
- if frappe.db.get_value("Lead", {"email_id": "test_cart_lead@example.com"}):
- return
-
- lead = frappe.get_doc({
- "doctype": "Lead",
- "email_id": "test_cart_lead@example.com",
- "lead_name": "_Test Website Lead",
- "status": "Open",
- "territory": "_Test Territory Rest Of The World",
- "company": "_Test Company"
- })
- lead.insert(ignore_permissions=True)
-
- frappe.get_doc({
- "doctype": "Address",
- "address_line1": "_Test Address Line 1",
- "address_title": "_Test Cart Lead Address",
- "address_type": "Office",
- "city": "_Test City",
- "country": "United States",
- "lead": lead.name,
- "lead_name": "_Test Website Lead",
- "is_primary_address": 1,
- "phone": "+91 0000000000"
- }).insert(ignore_permissions=True)
-
- frappe.get_doc({
- "doctype": "Address",
- "address_line1": "_Test Address Line 1",
- "address_title": "_Test Cart Lead Address",
- "address_type": "Personal",
- "city": "_Test City",
- "country": "India",
- "lead": lead.name,
- "lead_name": "_Test Website Lead",
- "phone": "+91 0000000000"
- }).insert(ignore_permissions=True)
-
def remove_all_items_from_cart(self):
- quotation = get_quotation()
+ quotation = _get_cart_quotation()
quotation.set("items", [])
quotation.save(ignore_permissions=True)
diff --git a/erpnext/stock/doctype/price_list/price_list.js b/erpnext/stock/doctype/price_list/price_list.js
index 54a7773..f109633 100644
--- a/erpnext/stock/doctype/price_list/price_list.js
+++ b/erpnext/stock/doctype/price_list/price_list.js
@@ -2,10 +2,6 @@
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
- onload: function() {
- erpnext.add_applicable_territory();
- },
-
refresh: function() {
cur_frm.add_custom_button(__("Add / Edit Prices"), function() {
frappe.route_options = {
@@ -14,4 +10,4 @@
frappe.set_route("Report", "Item Price");
}, "icon-money");
}
-});
\ No newline at end of file
+});
diff --git a/erpnext/stock/doctype/price_list/test_records.json b/erpnext/stock/doctype/price_list/test_records.json
index d91f887..ca8a620 100644
--- a/erpnext/stock/doctype/price_list/test_records.json
+++ b/erpnext/stock/doctype/price_list/test_records.json
@@ -1,67 +1,34 @@
[
{
- "buying": 1,
- "currency": "INR",
- "doctype": "Price List",
- "enabled": 1,
- "price_list_name": "_Test Price List",
- "selling": 1,
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "All Territories"
- }
- ]
- },
+ "buying": 1,
+ "currency": "INR",
+ "doctype": "Price List",
+ "enabled": 1,
+ "price_list_name": "_Test Price List",
+ "selling": 1
+ },
{
- "buying": 1,
- "currency": "INR",
- "doctype": "Price List",
- "enabled": 1,
- "price_list_name": "_Test Price List 2",
- "selling": 1,
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- }
- ]
- },
+ "buying": 1,
+ "currency": "INR",
+ "doctype": "Price List",
+ "enabled": 1,
+ "price_list_name": "_Test Price List 2",
+ "selling": 1
+ },
{
- "buying": 1,
- "currency": "INR",
- "doctype": "Price List",
- "enabled": 1,
- "price_list_name": "_Test Price List India",
- "selling": 1,
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory India"
- }
- ]
- },
+ "buying": 1,
+ "currency": "INR",
+ "doctype": "Price List",
+ "enabled": 1,
+ "price_list_name": "_Test Price List India",
+ "selling": 1
+ },
{
- "buying": 1,
- "currency": "USD",
- "doctype": "Price List",
- "enabled": 1,
- "price_list_name": "_Test Price List Rest of the World",
- "selling": 1,
- "territories": [
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory Rest Of The World"
- },
- {
- "doctype": "Applicable Territory",
- "parentfield": "territories",
- "territory": "_Test Territory United States"
- }
- ]
+ "buying": 1,
+ "currency": "USD",
+ "doctype": "Price List",
+ "enabled": 1,
+ "price_list_name": "_Test Price List Rest of the World",
+ "selling": 1
}
-]
\ No newline at end of file
+]
diff --git a/erpnext/templates/pages/user.py b/erpnext/templates/pages/user.py
index c944289..5ab5545 100644
--- a/erpnext/templates/pages/user.py
+++ b/erpnext/templates/pages/user.py
@@ -5,36 +5,31 @@
import frappe
from frappe import _
from frappe.utils import cstr
-from erpnext.shopping_cart.cart import get_lead_or_customer
+from erpnext.shopping_cart.cart import get_customer
no_cache = 1
no_sitemap = 1
def get_context(context):
- party = get_lead_or_customer()
- if party.doctype == "Lead":
- mobile_no = party.mobile_no
- phone = party.phone
- else:
- mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
- "customer": party.name}, ["mobile_no", "phone"])
-
+ party = get_customer()
+ mobile_no, phone = frappe.db.get_value("Contact", {"email_id": frappe.session.user,
+ "customer": party.name}, ["mobile_no", "phone"])
+
return {
"company_name": cstr(party.customer_name if party.doctype == "Customer" else party.company_name),
"mobile_no": cstr(mobile_no),
"phone": cstr(phone)
}
-
+
@frappe.whitelist()
def update_user(fullname, password=None, company_name=None, mobile_no=None, phone=None):
from erpnext.shopping_cart.cart import update_party
update_party(fullname, company_name, mobile_no, phone)
-
+
if not fullname:
return _("Name is required")
-
+
frappe.db.set_value("User", frappe.session.user, "first_name", fullname)
frappe.local.cookie_manager.set_cookie("full_name", fullname)
-
+
return _("Updated")
-
\ No newline at end of file