From 9a4a13cb73ad69174a579c87764032565878486b Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 31 Dec 2013 17:38:21 +0530 Subject: [PATCH] Moved Portal and Shopping Cart to Shopping Cart app, and some minor fixes --- .../doctype/pos_setting/pos_setting.js | 2 +- .../sales_taxes_and_charges_master.py | 7 +- erpnext/hooks.txt | 2 - erpnext/hr/doctype/employee/employee.js | 2 +- .../june_2013/p08_shopping_cart_settings.py | 14 - erpnext/patches/patch_list.py | 1 - erpnext/public/js/controllers/accounts.js | 2 +- erpnext/public/js/queries.js | 2 +- erpnext/public/js/website_utils.js | 73 +-- erpnext/selling/doctype/lead/lead.js | 4 +- .../doctype/sales_order/templates/__init__.py | 0 .../sales_order/templates/pages/__init__.py | 0 .../sales_order/templates/pages/order.html | 5 - .../sales_order/templates/pages/order.py | 32 -- .../sales_order/templates/pages/orders.html | 1 - .../sales_order/templates/pages/orders.py | 30 -- .../shopping_cart_price_list/__init__.py | 0 .../shopping_cart_price_list.py | 11 - .../shopping_cart_price_list.txt | 36 -- .../shopping_cart_settings/__init__.py | 0 .../shopping_cart_settings.js | 10 - .../shopping_cart_settings.py | 154 ------ .../shopping_cart_settings.txt | 129 ----- .../test_shopping_cart_settings.py | 81 --- .../shopping_cart_shipping_rule/__init__.py | 0 .../shopping_cart_shipping_rule.py | 11 - .../shopping_cart_shipping_rule.txt | 36 -- .../__init__.py | 0 .../shopping_cart_taxes_and_charges_master.py | 11 - ...shopping_cart_taxes_and_charges_master.txt | 36 -- .../selling/page/selling_home/selling_home.js | 6 - .../selling/{utils/__init__.py => utils.py} | 2 +- erpnext/selling/utils/cart.py | 462 ------------------ erpnext/selling/utils/product.py | 128 ----- .../authorization_rule/authorization_rule.js | 4 +- .../setup/doctype/item_group/item_group.py | 38 +- .../doctype/sales_partner/sales_partner.py | 15 - .../sales_partner/templates/__init__.py | 0 .../templates/generators/__init__.py | 0 .../templates/generators/partner.html | 26 - .../templates/generators/partner.py | 2 - .../sales_partner/templates/pages/__init__.py | 0 .../templates/pages/partners.html | 30 -- .../sales_partner/templates/pages/partners.py | 7 - erpnext/startup/event_handlers.py | 7 - erpnext/startup/webutils.py | 23 +- erpnext/stock/doctype/item/item.py | 11 +- .../stock/doctype/item/templates/__init__.py | 0 .../stock/doctype/price_list/price_list.py | 3 - erpnext/templates/generators/__init__.py | 0 erpnext/templates/generators/item.html | 87 ---- erpnext/templates/generators/item.py | 2 - erpnext/templates/generators/item_group.html | 52 -- erpnext/templates/generators/item_group.py | 2 - erpnext/templates/includes/cart.js | 294 ----------- .../includes/product_breadcrumbs.html | 10 - .../templates/includes/product_in_grid.html | 14 - .../templates/includes/product_in_list.html | 15 - erpnext/templates/includes/product_list.js | 52 -- .../includes/product_missing_image.html | 1 - erpnext/templates/includes/product_page.css | 13 - erpnext/templates/includes/product_page.js | 78 --- .../includes/product_search_box.html | 28 -- erpnext/templates/includes/transactions.html | 60 --- erpnext/templates/pages/__init__.py | 0 erpnext/templates/pages/address.html | 114 ----- erpnext/templates/pages/address.py | 30 -- erpnext/templates/pages/addresses.html | 51 -- erpnext/templates/pages/addresses.py | 6 - erpnext/templates/pages/cart.html | 57 --- erpnext/templates/pages/cart.py | 7 - erpnext/templates/pages/invoice.html | 5 - erpnext/templates/pages/invoice.py | 30 -- erpnext/templates/pages/invoices.html | 1 - erpnext/templates/pages/invoices.py | 28 -- erpnext/templates/pages/product_search.html | 33 -- erpnext/templates/pages/product_search.py | 6 - erpnext/templates/pages/profile.html | 55 --- erpnext/templates/pages/profile.py | 40 -- erpnext/templates/pages/shipment.html | 1 - erpnext/templates/pages/shipment.py | 16 - erpnext/templates/pages/shipments.html | 1 - erpnext/templates/pages/shipments.py | 24 - erpnext/templates/pages/ticket.html | 121 ----- erpnext/templates/pages/ticket.py | 37 -- erpnext/templates/pages/tickets.html | 87 ---- erpnext/templates/pages/tickets.py | 38 -- erpnext/templates/sale.html | 89 ---- erpnext/templates/sales_transactions.html | 32 -- erpnext/templates/utils.py | 53 -- 90 files changed, 35 insertions(+), 3091 deletions(-) delete mode 100644 erpnext/patches/june_2013/p08_shopping_cart_settings.py delete mode 100644 erpnext/selling/doctype/sales_order/templates/__init__.py delete mode 100644 erpnext/selling/doctype/sales_order/templates/pages/__init__.py delete mode 100644 erpnext/selling/doctype/sales_order/templates/pages/order.html delete mode 100644 erpnext/selling/doctype/sales_order/templates/pages/order.py delete mode 100644 erpnext/selling/doctype/sales_order/templates/pages/orders.html delete mode 100644 erpnext/selling/doctype/sales_order/templates/pages/orders.py delete mode 100644 erpnext/selling/doctype/shopping_cart_price_list/__init__.py delete mode 100644 erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py delete mode 100644 erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt delete mode 100644 erpnext/selling/doctype/shopping_cart_settings/__init__.py delete mode 100644 erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.js delete mode 100644 erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.py delete mode 100644 erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt delete mode 100644 erpnext/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py delete mode 100644 erpnext/selling/doctype/shopping_cart_shipping_rule/__init__.py delete mode 100644 erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py delete mode 100644 erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt delete mode 100644 erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py delete mode 100644 erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py delete mode 100644 erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt rename erpnext/selling/{utils/__init__.py => utils.py} (99%) delete mode 100644 erpnext/selling/utils/cart.py delete mode 100644 erpnext/selling/utils/product.py delete mode 100644 erpnext/setup/doctype/sales_partner/templates/__init__.py delete mode 100644 erpnext/setup/doctype/sales_partner/templates/generators/__init__.py delete mode 100644 erpnext/setup/doctype/sales_partner/templates/generators/partner.html delete mode 100644 erpnext/setup/doctype/sales_partner/templates/generators/partner.py delete mode 100644 erpnext/setup/doctype/sales_partner/templates/pages/__init__.py delete mode 100644 erpnext/setup/doctype/sales_partner/templates/pages/partners.html delete mode 100644 erpnext/setup/doctype/sales_partner/templates/pages/partners.py delete mode 100644 erpnext/stock/doctype/item/templates/__init__.py delete mode 100644 erpnext/templates/generators/__init__.py delete mode 100644 erpnext/templates/generators/item.html delete mode 100644 erpnext/templates/generators/item.py delete mode 100644 erpnext/templates/generators/item_group.html delete mode 100644 erpnext/templates/generators/item_group.py delete mode 100644 erpnext/templates/includes/cart.js delete mode 100644 erpnext/templates/includes/product_breadcrumbs.html delete mode 100644 erpnext/templates/includes/product_in_grid.html delete mode 100644 erpnext/templates/includes/product_in_list.html delete mode 100644 erpnext/templates/includes/product_list.js delete mode 100644 erpnext/templates/includes/product_missing_image.html delete mode 100644 erpnext/templates/includes/product_page.css delete mode 100644 erpnext/templates/includes/product_page.js delete mode 100644 erpnext/templates/includes/product_search_box.html delete mode 100644 erpnext/templates/includes/transactions.html delete mode 100644 erpnext/templates/pages/__init__.py delete mode 100644 erpnext/templates/pages/address.html delete mode 100644 erpnext/templates/pages/address.py delete mode 100644 erpnext/templates/pages/addresses.html delete mode 100644 erpnext/templates/pages/addresses.py delete mode 100644 erpnext/templates/pages/cart.html delete mode 100644 erpnext/templates/pages/cart.py delete mode 100644 erpnext/templates/pages/invoice.html delete mode 100644 erpnext/templates/pages/invoice.py delete mode 100644 erpnext/templates/pages/invoices.html delete mode 100644 erpnext/templates/pages/invoices.py delete mode 100644 erpnext/templates/pages/product_search.html delete mode 100644 erpnext/templates/pages/product_search.py delete mode 100644 erpnext/templates/pages/profile.html delete mode 100644 erpnext/templates/pages/profile.py delete mode 100644 erpnext/templates/pages/shipment.html delete mode 100644 erpnext/templates/pages/shipment.py delete mode 100644 erpnext/templates/pages/shipments.html delete mode 100644 erpnext/templates/pages/shipments.py delete mode 100644 erpnext/templates/pages/ticket.html delete mode 100644 erpnext/templates/pages/ticket.py delete mode 100644 erpnext/templates/pages/tickets.html delete mode 100644 erpnext/templates/pages/tickets.py delete mode 100644 erpnext/templates/sale.html delete mode 100644 erpnext/templates/sales_transactions.html diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index 8c5f254a52..a1ebb59602 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -74,5 +74,5 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) cur_frm.fields_dict.user.get_query = function(doc,cdt,cdn) { - return{ query:"core.doctype.profile.profile.profile_query"} + return{ query:"webnotes.core.doctype.profile.profile.profile_query"} } diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py index 64bf6c6a73..82412c66d0 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py @@ -14,9 +14,4 @@ class DocType(DocListController): (self.doc.name, self.doc.company)) # at least one territory - self.validate_table_has_rows("valid_for_territories") - - def on_update(self): - cart_settings = webnotes.get_obj("Shopping Cart Settings") - if cint(cart_settings.doc.enabled): - cart_settings.validate_tax_masters() \ No newline at end of file + self.validate_table_has_rows("valid_for_territories") \ No newline at end of file diff --git a/erpnext/hooks.txt b/erpnext/hooks.txt index 8cda9a69ee..9d4291b2e3 100644 --- a/erpnext/hooks.txt +++ b/erpnext/hooks.txt @@ -21,7 +21,6 @@ update_website_context = erpnext.startup.webutils.update_website_context mail_footer = erpnext.startup.mail_footer on_session_creation = erpnext.startup.event_handlers.on_session_creation -on_logout = erpnext.startup.event_handlers.on_logut # Boot Events # ------------------------- @@ -37,7 +36,6 @@ bean_event = *:on_trash:webnotes.core.doctype.notification_count.notification_co bean_event = Stock Entry:on_submit:erpnext.stock.doctype.material_request.material_request.update_completed_qty bean_event = Stock Entry:on_cancel:erpnext.stock.doctype.material_request.material_request.update_completed_qty -standard_queries = Warehouse:erpnext.stock.utils.get_warehouse_list standard_queries = Customer:erpnext.selling.utils.get_customer_list # Schedulers diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index 1df6175fae..23d50670fb 100644 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -5,7 +5,7 @@ wn.provide("erpnext.hr"); erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({ setup: function() { this.frm.fields_dict.user_id.get_query = function(doc,cdt,cdn) { - return { query:"core.doctype.profile.profile.profile_query"} } + return { query:"webnotes.core.doctype.profile.profile.profile_query"} } this.frm.fields_dict.reports_to.get_query = function(doc,cdt,cdn) { return{ query: "erpnext.controllers.queries.employee_query"} } }, diff --git a/erpnext/patches/june_2013/p08_shopping_cart_settings.py b/erpnext/patches/june_2013/p08_shopping_cart_settings.py deleted file mode 100644 index 45028c8731..0000000000 --- a/erpnext/patches/june_2013/p08_shopping_cart_settings.py +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -import webnotes - -def execute(): - webnotes.reload_doc("selling", "doctype", "shopping_cart_settings") - - # create two default territories, one for home country and one named Rest of the World - from erpnext.setup.page.setup_wizard.setup_wizard import create_territories - create_territories() - - webnotes.conn.set_value("Shopping Cart Settings", None, "default_territory", "Rest of the World") - \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 350ca37432..e455913f59 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -161,7 +161,6 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Sales Orders Pending To Be Delivered')", "patches.june_2013.p05_remove_unused_doctypes", "patches.june_2013.p06_drop_unused_tables", - "patches.june_2013.p08_shopping_cart_settings", "patches.june_2013.p09_update_global_defaults", "patches.june_2013.p10_lead_address", "patches.july_2013.p01_remove_doctype_mappers", diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 201c47e2bb..789d72bfd5 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -8,7 +8,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { } else if(d.account_head && d.charge_type!=="Actual") { wn.call({ type:"GET", - method: "controllers.accounts_controller.get_tax_rate", + method: "erpnext.controllers.accounts_controller.get_tax_rate", args: {"account_head":d.account_head}, callback: function(r) { wn.model.set_value(cdt, cdn, "rate", r.message || 0); diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index 621e340ff7..dbaa27d2de 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -5,7 +5,7 @@ wn.provide("erpnext.queries"); $.extend(erpnext.queries, { profile: function() { - return { query: "core.doctype.profile.profile.profile_query" }; + return { query: "webnotes.core.doctype.profile.profile.profile_query" }; }, lead: function() { diff --git a/erpnext/public/js/website_utils.js b/erpnext/public/js/website_utils.js index fda30b8af6..1c797dca15 100644 --- a/erpnext/public/js/website_utils.js +++ b/erpnext/public/js/website_utils.js @@ -1,14 +1,14 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -if(!window.erpnext) erpnext = {}; +if(!window.erpnext) window.erpnext = {}; // Add / update a new Lead / Communication // subject, sender, description wn.send_message = function(opts, btn) { return wn.call({ type: "POST", - method: "erpnext.portal.utils.send_message", + method: "erpnext.templates.utils.send_message", btn: btn, args: opts, callback: opts.callback @@ -16,71 +16,4 @@ wn.send_message = function(opts, btn) { }; // for backward compatibility -erpnext.send_message = wn.send_message; - -// Setup the user tools -// -$(document).ready(function() { - // update login - erpnext.cart.set_cart_count(); - - // update profile - if(full_name) { - $('.navbar li[data-label="Profile"] a') - .html(' ' + full_name); - } - -}); - -// shopping cart -if(!erpnext.cart) erpnext.cart = {}; - -$.extend(erpnext.cart, { - update_cart: function(opts) { - if(!full_name) { - if(localStorage) { - localStorage.setItem("last_visited", window.location.href.split("/").slice(-1)[0]); - localStorage.setItem("pending_add_to_cart", opts.item_code); - } - window.location.href = "login"; - } else { - return wn.call({ - type: "POST", - method: "erpnext.selling.utils.cart.update_cart", - args: { - item_code: opts.item_code, - qty: opts.qty, - with_doclist: opts.with_doclist - }, - btn: opts.btn, - callback: function(r) { - if(opts.callback) - opts.callback(r); - - erpnext.cart.set_cart_count(); - } - }); - } - }, - - set_cart_count: function() { - var cart_count = getCookie("cart_count"); - var $cart = $("#website-post-login").find('[data-label="Cart"]'); - var $badge = $cart.find(".badge"); - var $cog = $("#website-post-login").find(".dropdown-toggle"); - var $cog_count = $cog.find(".cart-count"); - if(cart_count) { - if($badge.length === 0) { - var $badge = $('').appendTo($cart.find("a")); - } - $badge.html(cart_count); - if($cog_count.length === 0) { - var $cog_count = $('').insertAfter($cog.find(".icon-cog")); - } - $cog_count.html(cart_count); - } else { - $badge.remove(); - $cog_count.remove(); - } - } -}); \ No newline at end of file +erpnext.send_message = wn.send_message; \ No newline at end of file diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 4ab1067089..41f679e34a 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -14,12 +14,12 @@ erpnext.LeadController = wn.ui.form.Controller.extend({ onload: function() { if(cur_frm.fields_dict.lead_owner.df.options.match(/^Profile/)) { cur_frm.fields_dict.lead_owner.get_query = function(doc,cdt,cdn) { - return { query:"core.doctype.profile.profile.profile_query" } } + return { query:"webnotes.core.doctype.profile.profile.profile_query" } } } if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) { cur_frm.fields_dict.contact_by.get_query = function(doc,cdt,cdn) { - return { query:"core.doctype.profile.profile.profile_query" } } + return { query:"webnotes.core.doctype.profile.profile.profile_query" } } } if(in_list(user_roles,'System Manager')) { diff --git a/erpnext/selling/doctype/sales_order/templates/__init__.py b/erpnext/selling/doctype/sales_order/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/sales_order/templates/pages/__init__.py b/erpnext/selling/doctype/sales_order/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/sales_order/templates/pages/order.html b/erpnext/selling/doctype/sales_order/templates/pages/order.html deleted file mode 100644 index 45867eabdf..0000000000 --- a/erpnext/selling/doctype/sales_order/templates/pages/order.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "templates/sale.html" %} - -{% block status -%} - {% if doc.status %}{{ doc.status }}{% endif %} -{%- endblock %} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/templates/pages/order.py b/erpnext/selling/doctype/sales_order/templates/pages/order.py deleted file mode 100644 index e172c09507..0000000000 --- a/erpnext/selling/doctype/sales_order/templates/pages/order.py +++ /dev/null @@ -1,32 +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 webnotes -from webnotes import _ - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_transaction_context - context = get_transaction_context("Sales Order", webnotes.form_dict.name) - modify_status(context.get("doc")) - context.update({ - "parent_link": "orders", - "parent_title": "My Orders" - }) - return context - -def modify_status(doc): - doc.status = [] - if 0 < doc.per_billed < 100: - doc.status.append(("label-warning", "icon-ok", _("Partially Billed"))) - elif doc.per_billed == 100: - doc.status.append(("label-success", "icon-ok", _("Billed"))) - - if 0 < doc.per_delivered < 100: - doc.status.append(("label-warning", "icon-truck", _("Partially Delivered"))) - elif doc.per_delivered == 100: - doc.status.append(("label-success", "icon-truck", _("Delivered"))) - doc.status = " " + " ".join((' %s' % s - for s in doc.status)) diff --git a/erpnext/selling/doctype/sales_order/templates/pages/orders.html b/erpnext/selling/doctype/sales_order/templates/pages/orders.html deleted file mode 100644 index 0467f34ae6..0000000000 --- a/erpnext/selling/doctype/sales_order/templates/pages/orders.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "templates/sales_transactions.html" %} \ No newline at end of file diff --git a/erpnext/selling/doctype/sales_order/templates/pages/orders.py b/erpnext/selling/doctype/sales_order/templates/pages/orders.py deleted file mode 100644 index 5d28d5bf6d..0000000000 --- a/erpnext/selling/doctype/sales_order/templates/pages/orders.py +++ /dev/null @@ -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 webnotes - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_currency_context - context = get_currency_context() - context.update({ - "title": "My Orders", - "method": "selling.doctype.sales_order.templates.pages.orders.get_orders", - "icon": "icon-list", - "empty_list_message": "No Orders Yet", - "page": "order", - }) - return context - -@webnotes.whitelist() -def get_orders(start=0): - from erpnext.templates.utils import get_transaction_list - from erpnext.selling.doctype.sales_order.templates.pages.order import modify_status - orders = get_transaction_list("Sales Order", start, ["per_billed", "per_delivered"]) - for d in orders: - modify_status(d) - - return orders - \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_price_list/__init__.py b/erpnext/selling/doctype/shopping_cart_price_list/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py b/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py deleted file mode 100644 index e5468e553e..0000000000 --- a/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt b/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt deleted file mode 100644 index 7cd61f7370..0000000000 --- a/erpnext/selling/doctype/shopping_cart_price_list/shopping_cart_price_list.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-06-20 16:00:18", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "selling_price_list", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Price List", - "name": "__common__", - "options": "Price List", - "parent": "Shopping Cart Price List", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Price List" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_settings/__init__.py b/erpnext/selling/doctype/shopping_cart_settings/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.js b/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.js deleted file mode 100644 index 7505dc2c4f..0000000000 --- a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -$.extend(cur_frm.cscript, { - onload: function() { - if(cur_frm.doc.__quotation_series) { - cur_frm.fields_dict.quotation_series.df.options = cur_frm.doc.__quotation_series; - } - } -}); \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.py b/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.py deleted file mode 100644 index 923936e8a5..0000000000 --- a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.py +++ /dev/null @@ -1,154 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes -from webnotes import _, msgprint -from webnotes.utils import comma_and -from webnotes.model.controller import DocListController - -class ShoppingCartSetupError(webnotes.ValidationError): pass - -class DocType(DocListController): - def onload(self): - self.doc.fields["__quotation_series"] = webnotes.get_doctype("Quotation").get_options("naming_series") - - def validate(self): - if self.doc.enabled: - self.validate_price_lists() - self.validate_tax_masters() - self.validate_exchange_rates_exist() - - def on_update(self): - webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0) - webnotes.conn.set_default("shopping_cart_quotation_series", self.doc.fields.get("quotation_series")) - - def validate_overlapping_territories(self, parentfield, fieldname): - # for displaying message - doctype = self.meta.get_field(parentfield).options - - # specify atleast one entry in the table - self.validate_table_has_rows(parentfield, raise_exception=ShoppingCartSetupError) - - territory_name_map = self.get_territory_name_map(parentfield, fieldname) - for territory, names in territory_name_map.items(): - if len(names) > 1: - msgprint(_("Error for") + " " + _(doctype) + ": " + comma_and(names) + - " " + _("have a common territory") + ": " + territory, - raise_exception=ShoppingCartSetupError) - - return territory_name_map - - def validate_price_lists(self): - territory_name_map = self.validate_overlapping_territories("price_lists", - "selling_price_list") - - # validate that a Shopping Cart Price List exists for the root territory - # as a catch all! - from erpnext.setup.utils import get_root_of - root_territory = get_root_of("Territory") - - if root_territory not in territory_name_map.keys(): - msgprint(_("Please specify a Price List which is valid for Territory") + - ": " + root_territory, raise_exception=ShoppingCartSetupError) - - def validate_tax_masters(self): - self.validate_overlapping_territories("sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - - def get_territory_name_map(self, parentfield, fieldname): - territory_name_map = {} - - # entries in table - names = [doc.fields.get(fieldname) for doc in self.doclist.get({"parentfield": parentfield})] - - if names: - # for condition in territory check - parenttype = self.meta.get_field(fieldname, parentfield=parentfield).options - - # to validate territory overlap - # make a map of territory: [list of names] - # if list against each territory has more than one element, raise exception - territory_name = webnotes.conn.sql("""select `territory`, `parent` - from `tabApplicable Territory` - where `parenttype`=%s and `parent` in (%s)""" % - ("%s", ", ".join(["%s"]*len(names))), tuple([parenttype] + names)) - - for territory, name in territory_name: - territory_name_map.setdefault(territory, []).append(name) - - if len(territory_name_map[territory]) > 1: - territory_name_map[territory].sort(key=lambda val: names.index(val)) - - return territory_name_map - - def validate_exchange_rates_exist(self): - """check if exchange rates exist for all Price List currencies (to company's currency)""" - company_currency = webnotes.conn.get_value("Company", self.doc.company, "default_currency") - if not company_currency: - msgprint(_("Please specify currency in Company") + ": " + self.doc.company, - raise_exception=ShoppingCartSetupError) - - price_list_currency_map = webnotes.conn.get_values("Price List", - [d.selling_price_list for d in self.doclist.get({"parentfield": "price_lists"})], - "currency") - - # check if all price lists have a currency - for price_list, currency in price_list_currency_map.items(): - if not currency: - webnotes.throw("%s: %s" % (_("Currency is missing for Price List"), price_list)) - - expected_to_exist = [currency + "-" + company_currency - for currency in price_list_currency_map.values() - if currency != company_currency] - - if expected_to_exist: - exists = webnotes.conn.sql_list("""select name from `tabCurrency Exchange` - where name in (%s)""" % (", ".join(["%s"]*len(expected_to_exist)),), - tuple(expected_to_exist)) - - missing = list(set(expected_to_exist).difference(exists)) - - if missing: - msgprint(_("Missing Currency Exchange Rates for" + ": " + comma_and(missing)), - raise_exception=ShoppingCartSetupError) - - def get_name_from_territory(self, territory, parentfield, fieldname): - name = None - territory_name_map = self.get_territory_name_map(parentfield, fieldname) - - if territory_name_map.get(territory): - name = territory_name_map.get(territory) - else: - territory_ancestry = self.get_territory_ancestry(territory) - for ancestor in territory_ancestry: - if territory_name_map.get(ancestor): - name = territory_name_map.get(ancestor) - break - - return name - - def get_price_list(self, billing_territory): - price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list") - return price_list and price_list[0] or None - - def get_tax_master(self, billing_territory): - tax_master = self.get_name_from_territory(billing_territory, "sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - return tax_master and tax_master[0] or None - - def get_shipping_rules(self, shipping_territory): - return self.get_name_from_territory(shipping_territory, "shipping_rules", "shipping_rule") - - def get_territory_ancestry(self, territory): - from erpnext.setup.utils import get_ancestors_of - - if not hasattr(self, "_territory_ancestry"): - self._territory_ancestry = {} - - if not self._territory_ancestry.get(territory): - self._territory_ancestry[territory] = get_ancestors_of("Territory", territory) - - return self._territory_ancestry[territory] \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt b/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt deleted file mode 100644 index f52cc60c7f..0000000000 --- a/erpnext/selling/doctype/shopping_cart_settings/shopping_cart_settings.txt +++ /dev/null @@ -1,129 +0,0 @@ -[ - { - "creation": "2013-06-19 15:57:32", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "description": "Default settings for Shopping Cart", - "doctype": "DocType", - "icon": "icon-shopping-cart", - "issingle": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "name": "__common__", - "parent": "Shopping Cart Settings", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0 - }, - { - "create": 1, - "doctype": "DocPerm", - "email": 1, - "name": "__common__", - "parent": "Shopping Cart Settings", - "parentfield": "permissions", - "parenttype": "DocType", - "permlevel": 0, - "print": 1, - "read": 1, - "role": "Website Manager", - "write": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Settings" - }, - { - "doctype": "DocField", - "fieldname": "enabled", - "fieldtype": "Check", - "label": "Enable Shopping Cart" - }, - { - "doctype": "DocField", - "fieldname": "section_break_2", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "company", - "fieldtype": "Link", - "label": "Company", - "options": "Company", - "reqd": 1 - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "default_territory", - "fieldtype": "Link", - "label": "Default Territory", - "options": "Territory", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break_4", - "fieldtype": "Column Break" - }, - { - "description": "Add / Edit", - "doctype": "DocField", - "fieldname": "default_customer_group", - "fieldtype": "Link", - "label": "Default Customer Group", - "options": "Customer Group", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "quotation_series", - "fieldtype": "Select", - "label": "Quotation Series", - "reqd": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_6", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "price_lists", - "fieldtype": "Table", - "label": "Shopping Cart Price Lists", - "options": "Shopping Cart Price List", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "shipping_rules", - "fieldtype": "Table", - "label": "Shopping Cart Shipping Rules", - "options": "Shopping Cart Shipping Rule", - "reqd": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break_10", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "sales_taxes_and_charges_masters", - "fieldtype": "Table", - "label": "Shopping Cart Taxes and Charges Masters", - "options": "Shopping Cart Taxes and Charges Master", - "reqd": 0 - }, - { - "doctype": "DocPerm" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py b/erpnext/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py deleted file mode 100644 index be67f6fe83..0000000000 --- a/erpnext/selling/doctype/shopping_cart_settings/test_shopping_cart_settings.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes -import unittest -from erpnext.selling.doctype.shopping_cart_settings.shopping_cart_settings import ShoppingCartSetupError - -class TestShoppingCartSettings(unittest.TestCase): - def setUp(self): - webnotes.conn.sql("""delete from `tabSingles` where doctype="Shipping Cart Settings" """) - webnotes.conn.sql("""delete from `tabShopping Cart Price List`""") - webnotes.conn.sql("""delete from `tabShopping Cart Taxes and Charges Master`""") - webnotes.conn.sql("""delete from `tabShopping Cart Shipping Rule`""") - - def get_cart_settings(self): - return webnotes.bean({"doctype": "Shopping Cart Settings", - "company": "_Test Company"}) - - def test_price_list_territory_overlap(self): - cart_settings = self.get_cart_settings() - - def _add_price_list(price_list): - cart_settings.doclist.append({ - "doctype": "Shopping Cart Price List", - "parentfield": "price_lists", - "selling_price_list": price_list - }) - - for price_list in ("_Test Price List Rest of the World", "_Test Price List India", - "_Test Price List"): - _add_price_list(price_list) - - controller = cart_settings.make_controller() - controller.validate_overlapping_territories("price_lists", "selling_price_list") - - _add_price_list("_Test Price List 2") - - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, - "price_lists", "selling_price_list") - - return cart_settings - - def test_taxes_territory_overlap(self): - cart_settings = self.get_cart_settings() - - def _add_tax_master(tax_master): - cart_settings.doclist.append({ - "doctype": "Shopping Cart Taxes and Charges Master", - "parentfield": "sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master": tax_master - }) - - for tax_master in ("_Test Sales Taxes and Charges Master", "_Test India Tax Master"): - _add_tax_master(tax_master) - - controller = cart_settings.make_controller() - controller.validate_overlapping_territories("sales_taxes_and_charges_masters", - "sales_taxes_and_charges_master") - - _add_tax_master("_Test Sales Taxes and Charges Master 2") - - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_overlapping_territories, - "sales_taxes_and_charges_masters", "sales_taxes_and_charges_master") - - def test_exchange_rate_exists(self): - webnotes.conn.sql("""delete from `tabCurrency Exchange`""") - - cart_settings = self.test_price_list_territory_overlap() - controller = cart_settings.make_controller() - self.assertRaises(ShoppingCartSetupError, controller.validate_exchange_rates_exist) - - from erpnext.setup.doctype.currency_exchange.test_currency_exchange import test_records as \ - currency_exchange_records - webnotes.bean(currency_exchange_records[0]).insert() - controller.validate_exchange_rates_exist() - diff --git a/erpnext/selling/doctype/shopping_cart_shipping_rule/__init__.py b/erpnext/selling/doctype/shopping_cart_shipping_rule/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py b/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py deleted file mode 100644 index e5468e553e..0000000000 --- a/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt b/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt deleted file mode 100644 index 91b41c2fb4..0000000000 --- a/erpnext/selling/doctype/shopping_cart_shipping_rule/shopping_cart_shipping_rule.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-07-03 13:15:34", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "shipping_rule", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Shipping Rule", - "name": "__common__", - "options": "Shipping Rule", - "parent": "Shopping Cart Shipping Rule", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Shipping Rule" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py b/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py b/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py deleted file mode 100644 index e5468e553e..0000000000 --- a/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -# For license information, please see license.txt - -from __future__ import unicode_literals -import webnotes - -class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl \ No newline at end of file diff --git a/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt b/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt deleted file mode 100644 index ba4419997b..0000000000 --- a/erpnext/selling/doctype/shopping_cart_taxes_and_charges_master/shopping_cart_taxes_and_charges_master.txt +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "creation": "2013-06-20 16:57:03", - "docstatus": 0, - "modified": "2013-12-20 19:21:47", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "istable": 1, - "module": "Selling", - "name": "__common__" - }, - { - "doctype": "DocField", - "fieldname": "sales_taxes_and_charges_master", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Tax Master", - "name": "__common__", - "options": "Sales Taxes and Charges Master", - "parent": "Shopping Cart Taxes and Charges Master", - "parentfield": "fields", - "parenttype": "DocType", - "permlevel": 0, - "reqd": 1 - }, - { - "doctype": "DocType", - "name": "Shopping Cart Taxes and Charges Master" - }, - { - "doctype": "DocField" - } -] \ No newline at end of file diff --git a/erpnext/selling/page/selling_home/selling_home.js b/erpnext/selling/page/selling_home/selling_home.js index a64ed48f2b..54b4edc182 100644 --- a/erpnext/selling/page/selling_home/selling_home.js +++ b/erpnext/selling/page/selling_home/selling_home.js @@ -65,12 +65,6 @@ wn.module_page["Selling"] = [ "doctype":"Selling Settings", "description": wn._("Settings for Selling Module") }, - { - "route":"Form/Shopping Cart Settings", - "label":wn._("Shopping Cart Settings"), - "description":wn._("Setup of Shopping Cart."), - doctype:"Shopping Cart Settings" - }, { label: wn._("Sales Taxes and Charges Master"), description: wn._("Sales taxes template."), diff --git a/erpnext/selling/utils/__init__.py b/erpnext/selling/utils.py similarity index 99% rename from erpnext/selling/utils/__init__.py rename to erpnext/selling/utils.py index c73d76ea46..7949e472dd 100644 --- a/erpnext/selling/utils/__init__.py +++ b/erpnext/selling/utils.py @@ -207,4 +207,4 @@ def apply_pos_settings(pos_settings, opts): if out.get("warehouse"): out["actual_qty"] = get_available_qty(opts.item_code, out.get("warehouse")).get("actual_qty") - return out + return out \ No newline at end of file diff --git a/erpnext/selling/utils/cart.py b/erpnext/selling/utils/cart.py deleted file mode 100644 index f23a5716a2..0000000000 --- a/erpnext/selling/utils/cart.py +++ /dev/null @@ -1,462 +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 webnotes, json -from webnotes import msgprint, _ -import webnotes.defaults -from webnotes.utils import flt, get_fullname, fmt_money, cstr - -class WebsitePriceListMissingError(webnotes.ValidationError): pass - -def set_cart_count(quotation=None): - if not quotation: - quotation = _get_cart_quotation() - cart_count = cstr(len(quotation.doclist.get({"parentfield": "quotation_details"}))) - webnotes._response.set_cookie("cart_count", cart_count) - -@webnotes.whitelist() -def get_cart_quotation(doclist=None): - party = get_lead_or_customer() - - if not doclist: - quotation = _get_cart_quotation(party) - doclist = quotation.doclist - set_cart_count(quotation) - - return { - "doclist": decorate_quotation_doclist(doclist), - "addresses": [{"name": address.name, "display": address.display} - for address in get_address_docs(party)], - "shipping_rules": get_applicable_shipping_rules(party) - } - -@webnotes.whitelist() -def place_order(): - quotation = _get_cart_quotation() - controller = quotation.make_controller() - for fieldname in ["customer_address", "shipping_address_name"]: - if not quotation.doc.fields.get(fieldname): - msgprint(_("Please select a") + " " + _(controller.meta.get_label(fieldname)), raise_exception=True) - - quotation.ignore_permissions = True - quotation.submit() - - from erpnext.selling.doctype.quotation.quotation import _make_sales_order - sales_order = webnotes.bean(_make_sales_order(quotation.doc.name, ignore_permissions=True)) - sales_order.ignore_permissions = True - sales_order.insert() - sales_order.submit() - webnotes._response.set_cookie("cart_count", "") - - return sales_order.doc.name - -@webnotes.whitelist() -def update_cart(item_code, qty, with_doclist=0): - quotation = _get_cart_quotation() - - qty = flt(qty) - if qty == 0: - quotation.set_doclist(quotation.doclist.get({"item_code": ["!=", item_code]})) - if not quotation.doclist.get({"parentfield": "quotation_details"}) and \ - not quotation.doc.fields.get("__islocal"): - quotation.__delete = True - - else: - quotation_items = quotation.doclist.get({"item_code": item_code}) - if not quotation_items: - quotation.doclist.append({ - "doctype": "Quotation Item", - "parentfield": "quotation_details", - "item_code": item_code, - "qty": qty - }) - else: - quotation_items[0].qty = qty - - apply_cart_settings(quotation=quotation) - - if hasattr(quotation, "__delete"): - webnotes.delete_doc("Quotation", quotation.doc.name, ignore_permissions=True) - quotation = _get_cart_quotation() - else: - quotation.ignore_permissions = True - quotation.save() - - set_cart_count(quotation) - - if with_doclist: - return get_cart_quotation(quotation.doclist) - else: - return quotation.doc.name - -@webnotes.whitelist() -def update_cart_address(address_fieldname, address_name): - from erpnext.utilities.transaction_base import get_address_display - - quotation = _get_cart_quotation() - address_display = get_address_display(webnotes.doc("Address", address_name).fields) - - if address_fieldname == "shipping_address_name": - quotation.doc.shipping_address_name = address_name - quotation.doc.shipping_address = address_display - - if not quotation.doc.customer_address: - address_fieldname == "customer_address" - - if address_fieldname == "customer_address": - quotation.doc.customer_address = address_name - quotation.doc.address_display = address_display - - - apply_cart_settings(quotation=quotation) - - quotation.ignore_permissions = True - quotation.save() - - return get_cart_quotation(quotation.doclist) - -@webnotes.whitelist() -def get_addresses(): - return [d.fields for d in get_address_docs()] - -@webnotes.whitelist() -def save_address(fields, address_fieldname=None): - party = get_lead_or_customer() - fields = json.loads(fields) - - if fields.get("name"): - bean = webnotes.bean("Address", fields.get("name")) - else: - bean = webnotes.bean({"doctype": "Address", "__islocal": 1}) - - bean.doc.fields.update(fields) - - party_fieldname = party.doctype.lower() - bean.doc.fields.update({ - party_fieldname: party.name, - (party_fieldname + "_name"): party.fields[party_fieldname + "_name"] - }) - bean.ignore_permissions = True - bean.save() - - if address_fieldname: - update_cart_address(address_fieldname, bean.doc.name) - - return bean.doc.name - -def get_address_docs(party=None): - from webnotes.model.doclist import objectify - from erpnext.utilities.transaction_base import get_address_display - - if not party: - party = get_lead_or_customer() - - address_docs = objectify(webnotes.conn.sql("""select * from `tabAddress` - where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name, - as_dict=True, update={"doctype": "Address"})) - - for address in address_docs: - address.display = get_address_display(address.fields) - address.display = (address.display).replace("\n", "
\n") - - return address_docs - -def get_lead_or_customer(): - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer") - if customer: - return webnotes.doc("Customer", customer) - - lead = webnotes.conn.get_value("Lead", {"email_id": webnotes.session.user}) - if lead: - return webnotes.doc("Lead", lead) - else: - lead_bean = webnotes.bean({ - "doctype": "Lead", - "email_id": webnotes.session.user, - "lead_name": get_fullname(webnotes.session.user), - "territory": guess_territory(), - "status": "Open" # TODO: set something better??? - }) - - if webnotes.session.user != "Guest": - lead_bean.ignore_permissions = True - lead_bean.insert() - - return lead_bean.doc - -def guess_territory(): - territory = None - geoip_country = webnotes.session.get("session_country") - if geoip_country: - territory = webnotes.conn.get_value("Territory", geoip_country) - - return territory or \ - webnotes.conn.get_value("Shopping Cart Settings", None, "territory") or \ - "All Territories" - -def decorate_quotation_doclist(doclist): - for d in doclist: - if d.item_code: - d.fields.update(webnotes.conn.get_value("Item", d.item_code, - ["website_image", "description", "page_name"], as_dict=True)) - d.formatted_rate = fmt_money(d.export_rate, currency=doclist[0].currency) - d.formatted_amount = fmt_money(d.export_amount, currency=doclist[0].currency) - elif d.charge_type: - d.formatted_tax_amount = fmt_money(d.tax_amount / doclist[0].conversion_rate, - currency=doclist[0].currency) - - doclist[0].formatted_grand_total_export = fmt_money(doclist[0].grand_total_export, - currency=doclist[0].currency) - - return [d.fields for d in doclist] - -def _get_cart_quotation(party=None): - if not party: - party = get_lead_or_customer() - - quotation = webnotes.conn.get_value("Quotation", - {party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0}) - - if quotation: - qbean = webnotes.bean("Quotation", quotation) - else: - qbean = webnotes.bean({ - "doctype": "Quotation", - "naming_series": webnotes.defaults.get_user_default("shopping_cart_quotation_series") or "QTN-CART-", - "quotation_to": party.doctype, - "company": webnotes.defaults.get_user_default("company"), - "order_type": "Shopping Cart", - "status": "Draft", - "docstatus": 0, - "__islocal": 1, - (party.doctype.lower()): party.name - }) - - if party.doctype == "Customer": - qbean.doc.contact_person = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, - "customer": party.name}) - qbean.run_method("set_contact_fields") - - qbean.run_method("onload_post_render") - apply_cart_settings(party, qbean) - - return qbean - -def update_party(fullname, company_name=None, mobile_no=None, phone=None): - party = get_lead_or_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" - - contact_name = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user, - "customer": party.name}) - contact = webnotes.bean("Contact", contact_name) - contact.doc.first_name = fullname - contact.doc.last_name = None - contact.doc.customer_name = party.customer_name - contact.doc.mobile_no = mobile_no - contact.doc.phone = phone - contact.ignore_permissions = True - contact.save() - - party_bean = webnotes.bean(party.fields) - party_bean.ignore_permissions = True - party_bean.save() - - qbean = _get_cart_quotation(party) - if not qbean.doc.fields.get("__islocal"): - qbean.doc.customer_name = company_name or fullname - qbean.run_method("set_contact_fields") - qbean.ignore_permissions = True - qbean.save() - -def apply_cart_settings(party=None, quotation=None): - if not party: - party = get_lead_or_customer() - if not quotation: - quotation = _get_cart_quotation(party) - - cart_settings = webnotes.get_obj("Shopping Cart Settings") - - billing_territory = get_address_territory(quotation.doc.customer_address) or \ - party.territory or "All Territories" - - set_price_list_and_rate(quotation, cart_settings, billing_territory) - - quotation.run_method("calculate_taxes_and_totals") - - set_taxes(quotation, cart_settings, billing_territory) - - _apply_shipping_rule(party, quotation, cart_settings) - -def set_price_list_and_rate(quotation, cart_settings, billing_territory): - """set price list based on billing territory""" - quotation.doc.selling_price_list = cart_settings.get_price_list(billing_territory) - - # reset values - quotation.doc.price_list_currency = quotation.doc.currency = \ - quotation.doc.plc_conversion_rate = quotation.doc.conversion_rate = None - for item in quotation.doclist.get({"parentfield": "quotation_details"}): - item.ref_rate = item.adj_rate = item.export_rate = item.export_amount = None - - # refetch values - quotation.run_method("set_price_list_and_item_details") - - # set it in cookies for using in product page - webnotes.local._response.set_cookie("selling_price_list", quotation.doc.selling_price_list) - -def set_taxes(quotation, cart_settings, billing_territory): - """set taxes based on billing territory""" - quotation.doc.charge = cart_settings.get_tax_master(billing_territory) - - # clear table - quotation.set_doclist(quotation.doclist.get({"parentfield": ["!=", "other_charges"]})) - - # append taxes - controller = quotation.make_controller() - controller.append_taxes_from_master("other_charges", "charge") - quotation.set_doclist(controller.doclist) - -@webnotes.whitelist() -def apply_shipping_rule(shipping_rule): - quotation = _get_cart_quotation() - - quotation.doc.shipping_rule = shipping_rule - - apply_cart_settings(quotation=quotation) - - quotation.ignore_permissions = True - quotation.save() - - return get_cart_quotation(quotation.doclist) - -def _apply_shipping_rule(party=None, quotation=None, cart_settings=None): - shipping_rules = get_shipping_rules(party, quotation, cart_settings) - - if not shipping_rules: - return - - elif quotation.doc.shipping_rule not in shipping_rules: - quotation.doc.shipping_rule = shipping_rules[0] - - quotation.run_method("apply_shipping_rule") - quotation.run_method("calculate_taxes_and_totals") - -def get_applicable_shipping_rules(party=None, quotation=None): - shipping_rules = get_shipping_rules(party, quotation) - - if shipping_rules: - rule_label_map = webnotes.conn.get_values("Shipping Rule", shipping_rules, "label") - # we need this in sorted order as per the position of the rule in the settings page - return [[rule, rule_label_map.get(rule)] for rule in shipping_rules] - -def get_shipping_rules(party=None, quotation=None, cart_settings=None): - if not party: - party = get_lead_or_customer() - if not quotation: - quotation = _get_cart_quotation() - if not cart_settings: - cart_settings = webnotes.get_obj("Shopping Cart Settings") - - # set shipping rule based on shipping territory - shipping_territory = get_address_territory(quotation.doc.shipping_address_name) or \ - party.territory - - shipping_rules = cart_settings.get_shipping_rules(shipping_territory) - - return shipping_rules - -def get_address_territory(address_name): - """Tries to match city, state and country of address to existing territory""" - territory = None - - if address_name: - address_fields = webnotes.conn.get_value("Address", address_name, - ["city", "state", "country"]) - for value in address_fields: - territory = webnotes.conn.get_value("Territory", value) - if territory: - break - - return territory - -import unittest -test_dependencies = ["Item", "Price List", "Contact", "Shopping Cart Settings"] - -class TestCart(unittest.TestCase): - def tearDown(self): - return - - cart_settings = webnotes.bean("Shopping Cart Settings") - cart_settings.ignore_permissions = True - cart_settings.doc.enabled = 0 - cart_settings.save() - - def enable_shopping_cart(self): - return - if not webnotes.conn.get_value("Shopping Cart Settings", None, "enabled"): - cart_settings = webnotes.bean("Shopping Cart Settings") - cart_settings.ignore_permissions = True - cart_settings.doc.enabled = 1 - cart_settings.save() - - def test_get_lead_or_customer(self): - webnotes.session.user = "test@example.com" - party1 = get_lead_or_customer() - party2 = get_lead_or_customer() - self.assertEquals(party1.name, party2.name) - self.assertEquals(party1.doctype, "Lead") - - webnotes.session.user = "test_contact_customer@example.com" - party = get_lead_or_customer() - self.assertEquals(party.name, "_Test Customer") - - def test_add_to_cart(self): - self.enable_shopping_cart() - webnotes.session.user = "test@example.com" - - update_cart("_Test Item", 1) - - quotation = _get_cart_quotation() - quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) - self.assertTrue(quotation_items) - self.assertEquals(quotation_items[0].qty, 1) - - return quotation - - def test_update_cart(self): - self.test_add_to_cart() - - update_cart("_Test Item", 5) - - quotation = _get_cart_quotation() - quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) - self.assertTrue(quotation_items) - self.assertEquals(quotation_items[0].qty, 5) - - return quotation - - def test_remove_from_cart(self): - quotation0 = self.test_add_to_cart() - - update_cart("_Test Item", 0) - - quotation = _get_cart_quotation() - self.assertEquals(quotation0.doc.name, quotation.doc.name) - - quotation_items = quotation.doclist.get({"parentfield": "quotation_details", "item_code": "_Test Item"}) - self.assertEquals(quotation_items, []) - - def test_place_order(self): - quotation = self.test_update_cart() - sales_order_name = place_order() - sales_order = webnotes.bean("Sales Order", sales_order_name) - self.assertEquals(sales_order.doclist.getone({"item_code": "_Test Item"}).prevdoc_docname, quotation.doc.name) - \ No newline at end of file diff --git a/erpnext/selling/utils/product.py b/erpnext/selling/utils/product.py deleted file mode 100644 index 98b7d6a9bb..0000000000 --- a/erpnext/selling/utils/product.py +++ /dev/null @@ -1,128 +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 webnotes -from webnotes.utils import cstr, cint, fmt_money -from webnotes.webutils import delete_page_cache -from erpnext.selling.utils.cart import _get_cart_quotation - -@webnotes.whitelist(allow_guest=True) -def get_product_info(item_code): - """get product price / stock info""" - if not cint(webnotes.conn.get_default("shopping_cart_enabled")): - return {} - - cart_quotation = _get_cart_quotation() - - price_list = webnotes.local.request.cookies.get("selling_price_list") - - warehouse = webnotes.conn.get_value("Item", item_code, "website_warehouse") - if warehouse: - in_stock = webnotes.conn.sql("""select actual_qty from tabBin where - item_code=%s and warehouse=%s""", (item_code, warehouse)) - if in_stock: - in_stock = in_stock[0][0] > 0 and 1 or 0 - else: - in_stock = -1 - - price = price_list and webnotes.conn.sql("""select ref_rate, currency from - `tabItem Price` where item_code=%s and price_list=%s""", - (item_code, price_list), as_dict=1) or [] - - price = price and price[0] or None - qty = 0 - - if price: - price["formatted_price"] = fmt_money(price["ref_rate"], currency=price["currency"]) - - price["currency"] = not cint(webnotes.conn.get_default("hide_currency_symbol")) \ - and (webnotes.conn.get_value("Currency", price.currency, "symbol") or price.currency) \ - or "" - - if webnotes.session.user != "Guest": - item = cart_quotation.doclist.get({"item_code": item_code}) - if item: - qty = item[0].qty - - return { - "price": price, - "stock": in_stock, - "uom": webnotes.conn.get_value("Item", item_code, "stock_uom"), - "qty": qty - } - -@webnotes.whitelist(allow_guest=True) -def get_product_list(search=None, start=0, limit=10): - # base query - query = """select name, item_name, page_name, website_image, item_group, - web_long_description as website_description - from `tabItem` where docstatus = 0 and show_in_website = 1 """ - - # search term condition - if search: - query += """and (web_long_description like %(search)s or - item_name like %(search)s or name like %(search)s)""" - search = "%" + cstr(search) + "%" - - # order by - query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit) - - data = webnotes.conn.sql(query, { - "search": search, - }, as_dict=1) - - return [get_item_for_list_in_html(r) for r in data] - - -def get_product_list_for_group(product_group=None, start=0, limit=10): - child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(product_group)]) - - # base query - query = """select name, item_name, page_name, website_image, item_group, - web_long_description as website_description - from `tabItem` where docstatus = 0 and show_in_website = 1 - and (item_group in (%s) - or name in (select parent from `tabWebsite Item Group` where item_group in (%s))) """ % (child_groups, child_groups) - - query += """order by weightage desc, modified desc limit %s, %s""" % (start, limit) - - data = webnotes.conn.sql(query, {"product_group": product_group}, as_dict=1) - - return [get_item_for_list_in_html(r) for r in data] - -def get_child_groups(item_group_name): - item_group = webnotes.doc("Item Group", item_group_name) - return webnotes.conn.sql("""select name - from `tabItem Group` where lft>=%(lft)s and rgt<=%(rgt)s - and show_in_website = 1""", item_group.fields) - -def get_group_item_count(item_group): - child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)]) - return webnotes.conn.sql("""select count(*) from `tabItem` - where docstatus = 0 and show_in_website = 1 - and (item_group in (%s) - or name in (select parent from `tabWebsite Item Group` - where item_group in (%s))) """ % (child_groups, child_groups))[0][0] - -def get_item_for_list_in_html(context): - return webnotes.get_template("templates/includes/product_in_grid.html").render(context) - -def scrub_item_for_list(r): - if not r.website_description: - r.website_description = "No description given" - if len(r.website_description.split(" ")) > 24: - r.website_description = " ".join(r.website_description.split(" ")[:24]) + "..." - -def get_parent_item_groups(item_group_name): - item_group = webnotes.doc("Item Group", item_group_name) - return webnotes.conn.sql("""select name, page_name from `tabItem Group` - where lft <= %s and rgt >= %s - and ifnull(show_in_website,0)=1 - order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True) - -def invalidate_cache_for(item_group): - for i in get_parent_item_groups(item_group): - if i.page_name: - delete_page_cache(i.page_name) \ No newline at end of file diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.js b/erpnext/setup/doctype/authorization_rule/authorization_rule.js index bd42618c53..66b14a85ba 100644 --- a/erpnext/setup/doctype/authorization_rule/authorization_rule.js +++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.js @@ -69,10 +69,10 @@ cur_frm.cscript.transaction = function(doc,cdt,cdn){ cur_frm.fields_dict.system_user.get_query = function(doc,cdt,cdn) { - return{ query:"core.doctype.profile.profile.profile_query" } } + return{ query:"webnotes.core.doctype.profile.profile.profile_query" } } cur_frm.fields_dict.approving_user.get_query = function(doc,cdt,cdn) { - return{ query:"core.doctype.profile.profile.profile_query" } } + return{ query:"webnotes.core.doctype.profile.profile.profile_query" } } cur_frm.fields_dict['approving_role'].get_query = cur_frm.fields_dict['system_role'].get_query; diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 6b989d5af6..02fe374c13 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -6,6 +6,7 @@ import webnotes from webnotes.utils.nestedset import DocTypeNestedSet from webnotes.webutils import WebsiteGenerator +from webnotes.webutils import delete_page_cache class DocType(DocTypeNestedSet, WebsiteGenerator): def __init__(self, doc, doclist=[]): @@ -19,7 +20,6 @@ class DocType(DocTypeNestedSet, WebsiteGenerator): self.validate_name_with_item() - from erpnext.selling.utils.product import invalidate_cache_for invalidate_cache_for(self.doc.name) self.validate_one_root() @@ -29,22 +29,22 @@ class DocType(DocTypeNestedSet, WebsiteGenerator): webnotes.msgprint("An item exists with same name (%s), please change the \ item group name or rename the item" % self.doc.name, raise_exception=1) - def get_context(self): - from erpnext.selling.utils.product import get_product_list_for_group, \ - get_parent_item_groups, get_group_item_count +def get_group_item_count(item_group): + child_groups = ", ".join(['"' + i[0] + '"' for i in get_child_groups(item_group)]) + return webnotes.conn.sql("""select count(*) from `tabItem` + where docstatus = 0 and show_in_website = 1 + and (item_group in (%s) + or name in (select parent from `tabWebsite Item Group` + where item_group in (%s))) """ % (child_groups, child_groups))[0][0] - self.doc.sub_groups = webnotes.conn.sql("""select name, page_name - from `tabItem Group` where parent_item_group=%s - and ifnull(show_in_website,0)=1""", self.doc.name, as_dict=1) - - for d in self.doc.sub_groups: - d.count = get_group_item_count(d.name) - - self.doc.items = get_product_list_for_group(product_group = self.doc.name, limit=100) - self.parent_groups = get_parent_item_groups(self.doc.name) - self.doc.title = self.doc.name - - if self.doc.slideshow: - from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow - get_slideshow(self) - \ No newline at end of file +def get_parent_item_groups(item_group_name): + item_group = webnotes.doc("Item Group", item_group_name) + return webnotes.conn.sql("""select name, page_name from `tabItem Group` + where lft <= %s and rgt >= %s + and ifnull(show_in_website,0)=1 + order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True) + +def invalidate_cache_for(item_group): + for i in get_parent_item_groups(item_group): + if i.page_name: + delete_page_cache(i.page_name) diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py index 4ab99b197f..c2309e8a55 100644 --- a/erpnext/setup/doctype/sales_partner/sales_partner.py +++ b/erpnext/setup/doctype/sales_partner/sales_partner.py @@ -26,18 +26,3 @@ class DocType(WebsiteGenerator): return contact_details else: return '' - - def get_context(self): - address = webnotes.conn.get_value("Address", - {"sales_partner": self.doc.name, "is_primary_address": 1}, - "*", as_dict=True) - if address: - city_state = ", ".join(filter(None, [address.city, address.state])) - address_rows = [address.address_line1, address.address_line2, - city_state, address.pincode, address.country] - - self.doc.fields.update({ - "email": address.email_id, - "partner_address": filter_strip_join(address_rows, "\n
"), - "phone": filter_strip_join(cstr(address.phone).split(","), "\n
") - }) \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/templates/__init__.py b/erpnext/setup/doctype/sales_partner/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/setup/doctype/sales_partner/templates/generators/__init__.py b/erpnext/setup/doctype/sales_partner/templates/generators/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/setup/doctype/sales_partner/templates/generators/partner.html b/erpnext/setup/doctype/sales_partner/templates/generators/partner.html deleted file mode 100644 index f0e43f0f15..0000000000 --- a/erpnext/setup/doctype/sales_partner/templates/generators/partner.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends base_template %} - -{% block content %} -
-
-
- {% if logo -%} - -

- {%- endif %} -
- {% if partner_website -%}

{{ partner_website }}

{%- endif %} - {% if partner_address -%}

{{ partner_address }}

{%- endif %} - {% if phone -%}

{{ phone }}

{%- endif %} - {% if email -%}

{{ email }}

{%- endif %} -
-
-
-

{{ partner_name }}

-

{{ description }}

-
-
-
-{% endblock %} \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/templates/generators/partner.py b/erpnext/setup/doctype/sales_partner/templates/generators/partner.py deleted file mode 100644 index 2229f0379b..0000000000 --- a/erpnext/setup/doctype/sales_partner/templates/generators/partner.py +++ /dev/null @@ -1,2 +0,0 @@ -doctype = "Sales Partner" -condition_field = "show_in_website" \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/templates/pages/__init__.py b/erpnext/setup/doctype/sales_partner/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/setup/doctype/sales_partner/templates/pages/partners.html b/erpnext/setup/doctype/sales_partner/templates/pages/partners.html deleted file mode 100644 index eabceb2855..0000000000 --- a/erpnext/setup/doctype/sales_partner/templates/pages/partners.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends base_template %} - -{% set title="Partners" %} - -{% block content %} -
-

{{ title }}

-
- {% for partner_info in partners %} -
-
- {% if partner_info.logo -%} - - - - {%- endif %} -
-
- -

{{ partner_info.partner_name }}

-
-

{{ partner_info.territory }} - {{ partner_info.partner_type }}

-

{{ partner_info.introduction }}

-
-
-
- {% endfor %} -
-{% endblock %} \ No newline at end of file diff --git a/erpnext/setup/doctype/sales_partner/templates/pages/partners.py b/erpnext/setup/doctype/sales_partner/templates/pages/partners.py deleted file mode 100644 index 5245ec0e3f..0000000000 --- a/erpnext/setup/doctype/sales_partner/templates/pages/partners.py +++ /dev/null @@ -1,7 +0,0 @@ -import webnotes - -def get_context(): - return { - "partners": webnotes.conn.sql("""select * from `tabSales Partner` - where show_in_website=1 order by name asc""", as_dict=True), - } \ No newline at end of file diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 262771dd4a..f9723e13f2 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -29,13 +29,6 @@ def on_session_creation(login_manager): login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D') webnotes.conn.commit() - if webnotes.conn.get_value("Profile", webnotes.session.user, "user_type") == "Website User": - from erpnext.selling.utils.cart import set_cart_count - set_cart_count() - -def on_logout(login_manager): - webnotes._response.set_cookie("cart_count", "") - def check_if_expired(): """check if account is expired. If expired, do not allow login""" from webnotes import conf diff --git a/erpnext/startup/webutils.py b/erpnext/startup/webutils.py index ef8c88b397..3abd192b52 100644 --- a/erpnext/startup/webutils.py +++ b/erpnext/startup/webutils.py @@ -1,29 +1,10 @@ # 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 webnotes -from webnotes.utils import cint def update_website_context(context): - post_login = [] - cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled")) - if cart_enabled: - post_login += [{"label": "Cart", "url": "cart", "icon": "icon-shopping-cart", "class": "cart-count"}, - {"class": "divider"}] - - post_login += [ - {"label": "Profile", "url": "profile", "icon": "icon-user"}, - {"label": "Addresses", "url": "addresses", "icon": "icon-map-marker"}, - {"label": "My Orders", "url": "orders", "icon": "icon-list"}, - {"label": "My Tickets", "url": "tickets", "icon": "icon-tags"}, - {"label": "Invoices", "url": "invoices", "icon": "icon-file-text"}, - {"label": "Shipments", "url": "shipments", "icon": "icon-truck"}, - {"class": "divider"} - ] - context.update({ - "shopping_cart_enabled": cart_enabled, - "post_login": post_login + context.get("post_login", []) - }) - if not context.get("favicon"): context["favicon"] = "app/images/favicon.ico" \ No newline at end of file diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index f9763cdf53..73e8dc2b09 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -198,7 +198,7 @@ class DocType(DocListController, WebsiteGenerator): self.doc.name, raise_exception=1) def update_website(self): - from erpnext.selling.utils.product import invalidate_cache_for + from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for invalidate_cache_for(self.doc.item_group) [invalidate_cache_for(d.item_group) for d in \ self.doclist.get({"doctype":"Website Item Group"})] @@ -221,15 +221,6 @@ class DocType(DocListController, WebsiteGenerator): def get_tax_rate(self, tax_type): return { "tax_rate": webnotes.conn.get_value("Account", tax_type, "tax_rate") } - def get_context(self): - from erpnext.selling.utils.product import get_parent_item_groups - self.parent_groups = get_parent_item_groups(self.doc.item_group) + [{"name":self.doc.name}] - self.doc.title = self.doc.item_name - - if self.doc.slideshow: - from webnotes.website.doctype.website_slideshow.website_slideshow import get_slideshow - get_slideshow(self) - def get_file_details(self, arg = ''): file = webnotes.conn.sql("select file_group, description from tabFile where name = %s", eval(arg)['file_name'], as_dict = 1) diff --git a/erpnext/stock/doctype/item/templates/__init__.py b/erpnext/stock/doctype/item/templates/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index d0e5d2b6d4..7644af5f23 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -29,9 +29,6 @@ class DocType(DocListController): def on_update(self): self.set_default_if_missing() self.update_item_price() - cart_settings = webnotes.get_obj("Shopping Cart Settings") - if cint(cart_settings.doc.enabled): - cart_settings.validate_price_lists() def set_default_if_missing(self): if self.doc.buying_or_selling=="Selling": diff --git a/erpnext/templates/generators/__init__.py b/erpnext/templates/generators/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/templates/generators/item.html b/erpnext/templates/generators/item.html deleted file mode 100644 index 91ea3e4917..0000000000 --- a/erpnext/templates/generators/item.html +++ /dev/null @@ -1,87 +0,0 @@ -{% extends base_template %} - -{% block javascript %} - -{% endblock %} - -{% block css %} - -{% endblock %} - -{% block content %} - {% include 'templates/includes/product_search_box.html' %} - {% include 'templates/includes/product_breadcrumbs.html' %} -
-
-
- {% if slideshow %} - {% include "templates/includes/slideshow.html" %} - {% else %} - {% if website_image %} - - {% else %} -
- {% include 'templates/includes/product_missing_image.html' %} -
- {% endif %} - {% endif %} -
-
-

{{ item_name }}

-

Item Code: {{ name }}

-

Product Description

-
- {{ web_long_description or description or "[No description given]" }} -
-
- -
-
-
- {% if obj.doclist.get({"doctype":"Item Website Specification"}) -%} -
-
-

Specifications

- - {% for d in obj.doclist.get( - {"doctype":"Item Website Specification"}) -%} - - - - - {%- endfor %} -
{{ d.label }}{{ d.description }}
-
-
- {%- endif %} -
-{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/generators/item.py b/erpnext/templates/generators/item.py deleted file mode 100644 index c9146d1640..0000000000 --- a/erpnext/templates/generators/item.py +++ /dev/null @@ -1,2 +0,0 @@ -doctype = "Item" -condition_field = "show_in_website" \ No newline at end of file diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html deleted file mode 100644 index c5fcd90b38..0000000000 --- a/erpnext/templates/generators/item_group.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends base_template %} - -{% block content %} -{% include 'templates/includes/product_search_box.html' %} -{% include 'templates/includes/product_breadcrumbs.html' %} -
- {% if slideshow %} - {% include "templates/includes/slideshow.html" %} - {% endif %} - {% if description %} -
{{ description or ""}}
- {% else %} -

{{ name }}

- {% endif %} -
-
- {% if sub_groups %} -
-
- {% for d in sub_groups %} - - {% endfor %} -
-
- {% endif %} - {% if items %} -
- {% for item in items %} - {{ item }} - {% endfor %} -
- {% if (items|length)==100 %} -
Showing top 100 items.
- {% endif %} - {% else %} -
No items listed.
- {% endif %} -
- - -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/generators/item_group.py b/erpnext/templates/generators/item_group.py deleted file mode 100644 index 12ef51378c..0000000000 --- a/erpnext/templates/generators/item_group.py +++ /dev/null @@ -1,2 +0,0 @@ -doctype = "Item Group" -condition_field = "show_in_website" \ No newline at end of file diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js deleted file mode 100644 index c521b6cb97..0000000000 --- a/erpnext/templates/includes/cart.js +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -// js inside blog page - -$(document).ready(function() { - erpnext.cart.bind_events(); - return wn.call({ - type: "POST", - method: "erpnext.selling.utils.cart.get_cart_quotation", - callback: function(r) { - $("#cart-container").removeClass("hide"); - $(".progress").remove(); - if(r.exc) { - if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) { - erpnext.cart.show_error("Oops!", wn._("Price List not configured.")); - } else if(r["403"]) { - erpnext.cart.show_error("Hey!", wn._("You need to be logged in to view your cart.")); - } else { - erpnext.cart.show_error("Oops!", wn._("Something went wrong.")); - } - } else { - erpnext.cart.set_cart_count(); - erpnext.cart.render(r.message); - } - } - }); -}); - -// shopping cart -if(!erpnext.cart) erpnext.cart = {}; -$.extend(erpnext.cart, { - show_error: function(title, text) { - $("#cart-container").html('

' + title + '

' + text + '
'); - }, - - bind_events: function() { - // bind update button - $(document).on("click", ".item-update-cart button", function() { - var item_code = $(this).attr("data-item-code"); - erpnext.cart.update_cart({ - item_code: item_code, - qty: $('input[data-item-code="'+item_code+'"]').val(), - with_doclist: 1, - btn: this, - callback: function(r) { - if(!r.exc) { - erpnext.cart.render(r.message); - var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success"); - setTimeout(function() { $button.removeClass("btn-success"); }, 1000); - } - }, - }); - }); - - $("#cart-add-shipping-address").on("click", function() { - window.location.href = "address?address_fieldname=shipping_address_name"; - }); - - $("#cart-add-billing-address").on("click", function() { - window.location.href = "address?address_fieldname=customer_address"; - }); - - $(".btn-place-order").on("click", function() { - erpnext.cart.place_order(this); - }); - }, - - render: function(out) { - var doclist = out.doclist; - var addresses = out.addresses; - - var $cart_items = $("#cart-items").empty(); - var $cart_taxes = $("#cart-taxes").empty(); - var $cart_totals = $("#cart-totals").empty(); - var $cart_billing_address = $("#cart-billing-address").empty(); - var $cart_shipping_address = $("#cart-shipping-address").empty(); - - var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0; - if(no_items) { - erpnext.cart.show_error("Empty :-(", wn._("Go ahead and add something to your cart.")); - $("#cart-addresses").toggle(false); - return; - } - - var shipping_rule_added = false; - var taxes_exist = false; - var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; }); - $.each(doclist, function(i, doc) { - if(doc.doctype === "Quotation Item") { - erpnext.cart.render_item_row($cart_items, doc); - } else if (doc.doctype === "Sales Taxes and Charges") { - if(out.shipping_rules && out.shipping_rules.length && - shipping_rule_labels.indexOf(doc.description)!==-1) { - shipping_rule_added = true; - erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); - } else { - erpnext.cart.render_tax_row($cart_taxes, doc); - } - - taxes_exist = true; - } - }); - - if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) { - erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, - out.shipping_rules); - taxes_exist = true; - } - - if(taxes_exist) - $('
').appendTo($cart_taxes); - - erpnext.cart.render_tax_row($cart_totals, { - description: "Total", - formatted_tax_amount: "" + doclist[0].formatted_grand_total_export + "" - }); - - if(!(addresses && addresses.length)) { - $cart_shipping_address.html('
'+wn._("Hey! Go ahead and add an address")+'
'); - } else { - erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); - erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); - } - }, - - render_item_row: function($cart_items, doc) { - doc.image_html = doc.website_image ? - '
' : - '{% include "stock/doctype/item/templates/includes/product_missing_image.html" %}'; - - if(doc.description === doc.item_name) doc.description = ""; - - $(repl('
\ -
\ -
\ -
%(image_html)s
\ -
\ -

%(item_name)s

\ -

%(description)s

\ -
\ -
\ -
\ -
\ -
\ - \ -
\ - \ -
\ -
\ -

at %(formatted_rate)s

\ - = %(formatted_amount)s\ -
\ -

', doc)).appendTo($cart_items); - }, - - render_tax_row: function($cart_taxes, doc, shipping_rules) { - var shipping_selector; - if(shipping_rules) { - shipping_selector = ''; - } - - var $tax_row = $(repl('
\ -
\ -
\ -
' + - (shipping_selector || '

%(description)s

') + - '
\ -
\ -
\ -
\ - %(formatted_tax_amount)s

\ -
\ -
', doc)).appendTo($cart_taxes); - - if(shipping_selector) { - $tax_row.find('select option').each(function(i, opt) { - if($(opt).html() == doc.description) { - $(opt).attr("selected", "selected"); - } - }); - $tax_row.find('select').on("change", function() { - erpnext.cart.apply_shipping_rule($(this).val(), this); - }); - } - }, - - apply_shipping_rule: function(rule, btn) { - return wn.call({ - btn: btn, - type: "POST", - method: "erpnext.selling.utils.cart.apply_shipping_rule", - args: { shipping_rule: rule }, - callback: function(r) { - if(!r.exc) { - erpnext.cart.render(r.message); - } - } - }); - }, - - render_address: function($address_wrapper, addresses, address_name) { - $.each(addresses, function(i, address) { - $(repl('
\ -
\ -
\ -
%(name)s
\ -
\ -
\ -
\ -
\ -
%(display)s
\ -
\ -
', address)) - .css({"margin": "10px auto"}) - .appendTo($address_wrapper); - }); - - $address_wrapper.find(".panel-heading") - .find(".address-title") - .css({"cursor": "pointer"}) - .on("click", function() { - $address_wrapper.find('.panel-collapse[data-address-name="' - +$(this).attr("data-address-name")+'"]').collapse("toggle"); - }); - - $address_wrapper.find('input[type="checkbox"]').on("click", function() { - if($(this).prop("checked")) { - var me = this; - $address_wrapper.find('input[type="checkbox"]').each(function(i, chk) { - if($(chk).attr("data-address-name")!=$(me).attr("data-address-name")) { - $(chk).prop("checked", false); - } - }); - - return wn.call({ - type: "POST", - method: "erpnext.selling.utils.cart.update_cart_address", - args: { - address_fieldname: $address_wrapper.attr("data-fieldname"), - address_name: $(this).attr("data-address-name") - }, - callback: function(r) { - if(!r.exc) { - erpnext.cart.render(r.message); - } - } - }); - } else { - return false; - } - }); - - $address_wrapper.find('input[type="checkbox"][data-address-name="'+ address_name +'"]') - .prop("checked", true); - - $address_wrapper.find(".panel-collapse").collapse({ - parent: $address_wrapper, - toggle: false - }); - - $address_wrapper.find('.panel-collapse[data-address-name="'+ address_name +'"]') - .collapse("show"); - }, - - place_order: function(btn) { - return wn.call({ - type: "POST", - method: "erpnext.selling.utils.cart.place_order", - btn: btn, - callback: function(r) { - if(r.exc) { - var msg = ""; - if(r._server_messages) { - msg = JSON.parse(r._server_messages || []).join("
"); - } - - $("#cart-error") - .empty() - .html(msg || wn._("Something went wrong!")) - .toggle(true); - } else { - window.location.href = "order?name=" + encodeURIComponent(r.message); - } - } - }); - } -}); \ No newline at end of file diff --git a/erpnext/templates/includes/product_breadcrumbs.html b/erpnext/templates/includes/product_breadcrumbs.html deleted file mode 100644 index e880364a6a..0000000000 --- a/erpnext/templates/includes/product_breadcrumbs.html +++ /dev/null @@ -1,10 +0,0 @@ -{% if obj.parent_groups and (obj.parent_groups|length) > 1 %} -
- -
-{% endif %} \ No newline at end of file diff --git a/erpnext/templates/includes/product_in_grid.html b/erpnext/templates/includes/product_in_grid.html deleted file mode 100644 index d99ad00294..0000000000 --- a/erpnext/templates/includes/product_in_grid.html +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/erpnext/templates/includes/product_in_list.html b/erpnext/templates/includes/product_in_list.html deleted file mode 100644 index f895ab6810..0000000000 --- a/erpnext/templates/includes/product_in_list.html +++ /dev/null @@ -1,15 +0,0 @@ - - \ No newline at end of file diff --git a/erpnext/templates/includes/product_list.js b/erpnext/templates/includes/product_list.js deleted file mode 100644 index ac84c00a3e..0000000000 --- a/erpnext/templates/includes/product_list.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -window.get_product_list = function() { - $(".more-btn .btn").click(function() { - window.get_product_list() - }); - - if(window.start==undefined) { - throw "product list not initialized (no start)" - } - - $.ajax({ - method: "GET", - url: "/", - dataType: "json", - data: { - cmd: "erpnext.selling.utils.product.get_product_list", - start: window.start, - search: window.search, - product_group: window.product_group - }, - dataType: "json", - success: function(data) { - window.render_product_list(data.message); - } - }) -} - -window.render_product_list = function(data) { - if(data.length) { - var table = $("#search-list .table"); - if(!table.length) - var table = $("").appendTo("#search-list"); - - $.each(data, function(i, d) { - $(d).appendTo(table); - }); - } - if(data.length < 10) { - if(!table) { - $(".more-btn") - .replaceWith("
No products found.
"); - } else { - $(".more-btn") - .replaceWith("
Nothing more to show.
"); - } - } else { - $(".more-btn").toggle(true) - } - window.start += (data.length || 0); -} diff --git a/erpnext/templates/includes/product_missing_image.html b/erpnext/templates/includes/product_missing_image.html deleted file mode 100644 index 81b893533f..0000000000 --- a/erpnext/templates/includes/product_missing_image.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/erpnext/templates/includes/product_page.css b/erpnext/templates/includes/product_page.css deleted file mode 100644 index 457fc6276b..0000000000 --- a/erpnext/templates/includes/product_page.css +++ /dev/null @@ -1,13 +0,0 @@ - \ No newline at end of file diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js deleted file mode 100644 index 5029b90299..0000000000 --- a/erpnext/templates/includes/product_page.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -$(document).ready(function() { - var item_code = $('[itemscope] [itemprop="productID"]').text().trim(); - var qty = 0; - - wn.call({ - type: "POST", - method: "erpnext.selling.utils.product.get_product_info", - args: { - item_code: "{{ name }}" - }, - callback: function(r) { - if(r.message && r.message.price) { - $(".item-price") - .html(r.message.price.formatted_price + " per " + r.message.uom); - - if(r.message.stock==0) { - $(".item-stock").html("
Not in stock
"); - } - else if(r.message.stock==1) { - $(".item-stock").html("
\ - Available (in stock)
"); - } - - $(".item-price-info").toggle(true); - - if(r.message.qty) { - qty = r.message.qty; - toggle_update_cart(qty); - $("#item-update-cart input").val(qty); - } - } - } - }) - - $("#item-add-to-cart button").on("click", function() { - erpnext.cart.update_cart({ - item_code: item_code, - qty: 1, - callback: function(r) { - if(!r.exc) { - toggle_update_cart(1); - qty = 1; - } - }, - btn: this, - }); - }); - - $("#item-update-cart button").on("click", function() { - erpnext.cart.update_cart({ - item_code: item_code, - qty: $("#item-update-cart input").val(), - btn: this, - callback: function(r) { - if(r.exc) { - $("#item-update-cart input").val(qty); - } else { - qty = $("#item-update-cart input").val(); - } - }, - }); - }); - - if(localStorage && localStorage.getItem("pending_add_to_cart") && full_name) { - localStorage.removeItem("pending_add_to_cart"); - $("#item-add-to-cart button").trigger("click"); - } -}); - -var toggle_update_cart = function(qty) { - $("#item-add-to-cart").toggle(qty ? false : true); - $("#item-update-cart") - .toggle(qty ? true : false) - .find("input").val(qty); -} \ No newline at end of file diff --git a/erpnext/templates/includes/product_search_box.html b/erpnext/templates/includes/product_search_box.html deleted file mode 100644 index 0f44eea72e..0000000000 --- a/erpnext/templates/includes/product_search_box.html +++ /dev/null @@ -1,28 +0,0 @@ -
- -
- - - - -
- - -
\ No newline at end of file diff --git a/erpnext/templates/includes/transactions.html b/erpnext/templates/includes/transactions.html deleted file mode 100644 index 6148f18fca..0000000000 --- a/erpnext/templates/includes/transactions.html +++ /dev/null @@ -1,60 +0,0 @@ -{% extends base_template %} - -{% block content -%} -
- - -
-
-
-
-
-
- -
-
-{%- endblock %} - -{% block javascript -%} - - - -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/__init__.py b/erpnext/templates/pages/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/erpnext/templates/pages/address.html b/erpnext/templates/pages/address.html deleted file mode 100644 index 5eaefd5948..0000000000 --- a/erpnext/templates/pages/address.html +++ /dev/null @@ -1,114 +0,0 @@ -{% extends base_template %} - -{% set title=doc and doc.name or "New Address" %} -{% set docname=(doc and doc.name or "") %} - -{% macro render_fields(docfields) -%} -{% for df in docfields -%} - {% if df.fieldtype in ["Data", "Link"] -%} -
- - -
- {% elif df.fieldtype == "Check" -%} -
- -
- {% elif df.fieldtype == "Select" -%} -
- - -
- {%- endif %} -{%- endfor %} -{%- endmacro %} - -{% block content %} -
- -

{{ title }}

- -
-
- -
-
-
- {{ render_fields(meta.left_fields) }} -
-
- {{ render_fields(meta.right_fields) }} -
- - -
- - -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/address.py b/erpnext/templates/pages/address.py deleted file mode 100644 index 9918e5f128..0000000000 --- a/erpnext/templates/pages/address.py +++ /dev/null @@ -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 webnotes -from webnotes.utils import cint - -no_cache = True - -def get_context(): - def _get_fields(fieldnames): - return [webnotes._dict(zip(["label", "fieldname", "fieldtype", "options"], - [df.label, df.fieldname, df.fieldtype, df.options])) - for df in webnotes.get_doctype("Address", processed=True).get({"fieldname": ["in", fieldnames]})] - - bean = None - if webnotes.form_dict.name: - bean = webnotes.bean("Address", webnotes.form_dict.name) - - return { - "doc": bean.doc if bean else None, - "meta": webnotes._dict({ - "left_fields": _get_fields(["address_title", "address_type", "address_line1", "address_line2", - "city", "state", "pincode", "country"]), - "right_fields": _get_fields(["email_id", "phone", "fax", "is_primary_address", - "is_shipping_address"]) - }), - "cint": cint - } - diff --git a/erpnext/templates/pages/addresses.html b/erpnext/templates/pages/addresses.html deleted file mode 100644 index 6fe36a97b4..0000000000 --- a/erpnext/templates/pages/addresses.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends base_template %} - -{% set title="My Addresses" %} - -{% block content %} -
- -

New Address

-
-
-
-
-
-
-
- - -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/addresses.py b/erpnext/templates/pages/addresses.py deleted file mode 100644 index 41f6b56cb9..0000000000 --- a/erpnext/templates/pages/addresses.py +++ /dev/null @@ -1,6 +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 - -no_cache = True \ No newline at end of file diff --git a/erpnext/templates/pages/cart.html b/erpnext/templates/pages/cart.html deleted file mode 100644 index 8aae9d92b9..0000000000 --- a/erpnext/templates/pages/cart.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends base_template %} - -{% block javascript %} - -{% endblock %} - -{% set title="Shopping Cart" %} - -{% block content %} -
-

{{ title }}

-
-
-
-
-

-
- -
-
-
-
-

Item Details

-
-
-

Qty, Amount

-

-
-
-
-
-
-
-
-
-
-
-

Shipping Address

-
- -
-
-

Billing Address

-
- -
-
-
-
-

-
-
-{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/cart.py b/erpnext/templates/pages/cart.py deleted file mode 100644 index ee55e5c1d5..0000000000 --- a/erpnext/templates/pages/cart.py +++ /dev/null @@ -1,7 +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 - -no_cache = True -no_sitemap = True \ No newline at end of file diff --git a/erpnext/templates/pages/invoice.html b/erpnext/templates/pages/invoice.html deleted file mode 100644 index 45867eabdf..0000000000 --- a/erpnext/templates/pages/invoice.html +++ /dev/null @@ -1,5 +0,0 @@ -{% extends "templates/sale.html" %} - -{% block status -%} - {% if doc.status %}{{ doc.status }}{% endif %} -{%- endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/invoice.py b/erpnext/templates/pages/invoice.py deleted file mode 100644 index 9d6a558b7c..0000000000 --- a/erpnext/templates/pages/invoice.py +++ /dev/null @@ -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 webnotes -from webnotes import _ -from webnotes.utils import flt, fmt_money - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_transaction_context - context = get_transaction_context("Sales Invoice", webnotes.form_dict.name) - modify_status(context.get("doc")) - context.update({ - "parent_link": "invoices", - "parent_title": "Invoices" - }) - return context - -def modify_status(doc): - doc.status = "" - if flt(doc.outstanding_amount): - doc.status = ' %s' % \ - ("label-warning", "icon-exclamation-sign", - _("To Pay") + " = " + fmt_money(doc.outstanding_amount, currency=doc.currency)) - else: - doc.status = ' %s' % \ - ("label-success", "icon-ok", _("Paid")) - \ No newline at end of file diff --git a/erpnext/templates/pages/invoices.html b/erpnext/templates/pages/invoices.html deleted file mode 100644 index 0467f34ae6..0000000000 --- a/erpnext/templates/pages/invoices.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "templates/sales_transactions.html" %} \ No newline at end of file diff --git a/erpnext/templates/pages/invoices.py b/erpnext/templates/pages/invoices.py deleted file mode 100644 index 448c525068..0000000000 --- a/erpnext/templates/pages/invoices.py +++ /dev/null @@ -1,28 +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 webnotes - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_currency_context - context = get_currency_context() - context.update({ - "title": "Invoices", - "method": "accounts.doctype.sales_invoice.templates.pages.invoices.get_invoices", - "icon": "icon-file-text", - "empty_list_message": "No Invoices Found", - "page": "invoice" - }) - return context - -@webnotes.whitelist() -def get_invoices(start=0): - from erpnext.templates.utils import get_transaction_list - from erpnext.accounts.doctype.sales_invoice.templates.pages.invoice import modify_status - invoices = get_transaction_list("Sales Invoice", start, ["outstanding_amount"]) - for d in invoices: - modify_status(d) - return invoices \ No newline at end of file diff --git a/erpnext/templates/pages/product_search.html b/erpnext/templates/pages/product_search.html deleted file mode 100644 index 02c161cd90..0000000000 --- a/erpnext/templates/pages/product_search.html +++ /dev/null @@ -1,33 +0,0 @@ -{% extends base_template %} - -{% set title="Product Search" %} - -{% block javascript %} - -{% endblock %} - -{% block content %} - - -{% include "stock/doctype/item/templates/includes/product_search_box.html" %} -
-

Search Results

-
- -
-
- -
-
-{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py deleted file mode 100644 index 41f6b56cb9..0000000000 --- a/erpnext/templates/pages/product_search.py +++ /dev/null @@ -1,6 +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 - -no_cache = True \ No newline at end of file diff --git a/erpnext/templates/pages/profile.html b/erpnext/templates/pages/profile.html deleted file mode 100644 index 880b8d49e3..0000000000 --- a/erpnext/templates/pages/profile.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends base_template %} - -{% set title="My Profile" %} - -{% block content %} -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- - -
- -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/profile.py b/erpnext/templates/pages/profile.py deleted file mode 100644 index 143abef418..0000000000 --- a/erpnext/templates/pages/profile.py +++ /dev/null @@ -1,40 +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 webnotes -from webnotes import _ -from webnotes.utils import cstr - -no_cache = True -no_sitemap = True - -def get_context(): - from erpnext.selling.utils.cart import get_lead_or_customer - party = get_lead_or_customer() - if party.doctype == "Lead": - mobile_no = party.mobile_no - phone = party.phone - else: - mobile_no, phone = webnotes.conn.get_value("Contact", {"email_id": webnotes.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) - } - -@webnotes.whitelist() -def update_profile(fullname, password=None, company_name=None, mobile_no=None, phone=None): - from erpnext.selling.utils.cart import update_party - update_party(fullname, company_name, mobile_no, phone) - - if not fullname: - return _("Name is required") - - webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname) - webnotes._response.set_cookie("full_name", fullname) - - return _("Updated") - \ No newline at end of file diff --git a/erpnext/templates/pages/shipment.html b/erpnext/templates/pages/shipment.html deleted file mode 100644 index d0aaa3efd5..0000000000 --- a/erpnext/templates/pages/shipment.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "templates/sale.html" %} \ No newline at end of file diff --git a/erpnext/templates/pages/shipment.py b/erpnext/templates/pages/shipment.py deleted file mode 100644 index e744685210..0000000000 --- a/erpnext/templates/pages/shipment.py +++ /dev/null @@ -1,16 +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 webnotes - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_transaction_context - context = get_transaction_context("Delivery Note", webnotes.form_dict.name) - context.update({ - "parent_link": "shipments", - "parent_title": "Shipments" - }) - return context \ No newline at end of file diff --git a/erpnext/templates/pages/shipments.html b/erpnext/templates/pages/shipments.html deleted file mode 100644 index 0467f34ae6..0000000000 --- a/erpnext/templates/pages/shipments.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "templates/sales_transactions.html" %} \ No newline at end of file diff --git a/erpnext/templates/pages/shipments.py b/erpnext/templates/pages/shipments.py deleted file mode 100644 index 03d074a19f..0000000000 --- a/erpnext/templates/pages/shipments.py +++ /dev/null @@ -1,24 +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 webnotes - -no_cache = True - -def get_context(): - from erpnext.templates.utils import get_currency_context - context = get_currency_context() - context.update({ - "title": "Shipments", - "method": "erpnext.templates.pages.shipments.get_shipments", - "icon": "icon-truck", - "empty_list_message": "No Shipments Found", - "page": "shipment" - }) - return context - -@webnotes.whitelist() -def get_shipments(start=0): - from erpnext.templates.utils import get_transaction_list - return get_transaction_list("Delivery Note", start) diff --git a/erpnext/templates/pages/ticket.html b/erpnext/templates/pages/ticket.html deleted file mode 100644 index 1732e770cb..0000000000 --- a/erpnext/templates/pages/ticket.html +++ /dev/null @@ -1,121 +0,0 @@ -{% extends base_template %} - -{% set title=doc.name %} - -{% set status_label = { - "Open": "label-success", - "To Reply": "label-danger", - "Closed": "label-default" -} %} - -{% block content %} -
- -

{{ doc.name }}

- {% if doc.name == "Not Allowed" -%} - - {% else %} -
- {%- if doc.status -%} - {% if doc.status == "Waiting for Customer" -%} - {% set status = "To Reply" %} - {% else %} - {% set status = doc.status %} - {%- endif -%} -
-
- {{ status }} -
-
-
{{ doc.subject }}
-
-
- {{ utils.formatdate(doc.creation) }} -
-
-
-

Messages

-
- - -
-
- - {%- if doclist.get({"doctype":"Communication"}) -%} -
-
- - {%- for comm in - (doclist.get({"doctype":"Communication"})|sort(reverse=True, attribute="creation")) %} - - - - {% endfor -%} - -
-
- {{ comm.sender }} on {{ utils.formatdate(comm.creation) }}
-
-

{{ webnotes.utils.is_html(comm.content) and comm.content or - comm.content.replace("\n", "
")}}

-
- - {%- else -%} -
No messages
- {%- endif -%} - {%- endif -%} - {% endif -%} - -{% endblock %} - -{% block javascript %} - -{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/ticket.py b/erpnext/templates/pages/ticket.py deleted file mode 100644 index f9e5c88040..0000000000 --- a/erpnext/templates/pages/ticket.py +++ /dev/null @@ -1,37 +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 webnotes -from webnotes import _ -from webnotes.utils import today - -no_cache = True - -def get_context(): - bean = webnotes.bean("Support Ticket", webnotes.form_dict.name) - if bean.doc.raised_by != webnotes.session.user: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } - -@webnotes.whitelist() -def add_reply(ticket, message): - if not message: - raise webnotes.throw(_("Please write something")) - - bean = webnotes.bean("Support Ticket", ticket) - if bean.doc.raised_by != webnotes.session.user: - raise webnotes.throw(_("You are not allowed to reply to this ticket."), webnotes.PermissionError) - - from webnotes.core.doctype.communication.communication import make - make(content=message, sender=bean.doc.raised_by, subject = bean.doc.subject, - doctype="Support Ticket", name=bean.doc.name, - date=today()) \ No newline at end of file diff --git a/erpnext/templates/pages/tickets.html b/erpnext/templates/pages/tickets.html deleted file mode 100644 index 6942d3bff0..0000000000 --- a/erpnext/templates/pages/tickets.html +++ /dev/null @@ -1,87 +0,0 @@ -{% extends "templates/includes/transactions.html" %} - -{% block javascript -%} -{{ super() }} - - -{%- endblock %} \ No newline at end of file diff --git a/erpnext/templates/pages/tickets.py b/erpnext/templates/pages/tickets.py deleted file mode 100644 index 7434af2075..0000000000 --- a/erpnext/templates/pages/tickets.py +++ /dev/null @@ -1,38 +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 webnotes -from webnotes.utils import cint, formatdate - -no_cache = True - -def get_context(): - return { - "title": "My Tickets", - "method": "support.doctype.support_ticket.templates.pages.tickets.get_tickets", - "icon": "icon-ticket", - "empty_list_message": "No Tickets Raised", - "page": "ticket" - } - -@webnotes.whitelist() -def get_tickets(start=0): - tickets = webnotes.conn.sql("""select name, subject, status, creation - from `tabSupport Ticket` where raised_by=%s - order by modified desc - limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True) - for t in tickets: - t.creation = formatdate(t.creation) - - return tickets - -@webnotes.whitelist() -def make_new_ticket(subject, message): - if not (subject and message): - raise webnotes.throw(_("Please write something in subject and message!")) - - from erpnext.support.doctype.support_ticket.get_support_mails import add_support_communication - ticket = add_support_communication(subject, message, webnotes.session.user) - - return ticket.doc.name \ No newline at end of file diff --git a/erpnext/templates/sale.html b/erpnext/templates/sale.html deleted file mode 100644 index 5dc72c793b..0000000000 --- a/erpnext/templates/sale.html +++ /dev/null @@ -1,89 +0,0 @@ -{% extends base_template %} - -{% set title=doc.name %} - -{% block content %} -
- -

{{ doc.name }}

- {% if doc.name == "Not Allowed" -%} - - {% else %} -
-
-
-
- {% block status -%}{%- endblock %} -
-
- {{ utils.formatdate(doc.posting_date or doc.transaction_date) }} -
-
-
-
-
- - - - - - - - - - - - {%- for row in doclist.get({"doctype": doc.doctype + " Item"}) %} - - - - - - - - - - {% endfor -%} - -
SrItem NameDescriptionQtyUoMBasic RateAmount
{{ row.idx }}{{ row.item_name }}{{ row.description }}{{ row.qty }}{{ row.stock_uom }}{{ utils.fmt_money(row.export_rate, currency=doc.currency) }}{{ utils.fmt_money(row.export_amount, currency=doc.currency) }}
-
-
-
-
-
- - - - - - - {%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%} - {%- if not charge.included_in_print_rate -%} - - - - - {%- endif -%} - {%- endfor -%} - - - - - - - - - -
Net Total{{ - utils.fmt_money(doc.net_total/doc.conversion_rate, currency=doc.currency) - }}
{{ charge.description }}{{ utils.fmt_money(charge.tax_amount / doc.conversion_rate, currency=doc.currency) }}
Grand Total{{ utils.fmt_money(doc.grand_total_export, currency=doc.currency) }}
Rounded Total{{ utils.fmt_money(doc.rounded_total_export, currency=doc.currency) }}
-
-
-
- {%- endif %} -
-{% endblock %} \ No newline at end of file diff --git a/erpnext/templates/sales_transactions.html b/erpnext/templates/sales_transactions.html deleted file mode 100644 index 4836c12dca..0000000000 --- a/erpnext/templates/sales_transactions.html +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "templates/includes/transactions.html" %} - -{% block javascript -%} - - -{{ super() }} - - -{%- endblock %} \ No newline at end of file diff --git a/erpnext/templates/utils.py b/erpnext/templates/utils.py index 9ec542262a..d75499ff53 100644 --- a/erpnext/templates/utils.py +++ b/erpnext/templates/utils.py @@ -3,59 +3,6 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cint, formatdate -import json - -def get_transaction_list(doctype, start, additional_fields=None): - # find customer id - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - if customer: - if additional_fields: - additional_fields = ", " + ", ".join(("`%s`" % f for f in additional_fields)) - else: - additional_fields = "" - - transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export - %s - from `tab%s` where customer=%s and docstatus=1 - order by creation desc - limit %s, 20""" % (additional_fields, doctype, "%s", "%s"), - (customer, cint(start)), as_dict=True) - for doc in transactions: - items = webnotes.conn.sql_list("""select item_name - from `tab%s Item` where parent=%s limit 6""" % (doctype, "%s"), doc.name) - doc.items = ", ".join(items[:5]) + ("..." if (len(items) > 5) else "") - doc.creation = formatdate(doc.creation) - return transactions - else: - return [] - -def get_currency_context(): - return { - "global_number_format": webnotes.conn.get_default("number_format") or "#,###.##", - "currency": webnotes.conn.get_default("currency"), - "currency_symbols": json.dumps(dict(webnotes.conn.sql("""select name, symbol - from tabCurrency where ifnull(enabled,0)=1"""))) - } - -def get_transaction_context(doctype, name): - customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, - "customer") - - bean = webnotes.bean(doctype, name) - if bean.doc.customer != customer: - return { - "doc": {"name": "Not Allowed"} - } - else: - return { - "doc": bean.doc, - "doclist": bean.doclist, - "webnotes": webnotes, - "utils": webnotes.utils - } @webnotes.whitelist(allow_guest=True) def send_message(subject="Website Query", message="", sender="", status="Open"):