From a33d468d3030441066b1f0a0ecdefa31394c5980 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jun 2015 17:15:42 +0530 Subject: [PATCH 1/3] [fixes] portal, issues, addresses etc --- erpnext/controllers/accounts_controller.py | 2 +- erpnext/hooks.py | 8 +- erpnext/patches.txt | 3 +- erpnext/patches/v5_0/portal_fixes.py | 3 + .../setup/fixtures/web_form/addresses.json | 167 ++++++++++++++++++ erpnext/setup/fixtures/web_form/issues.json | 57 ++++++ erpnext/setup/install.py | 10 ++ erpnext/shopping_cart/cart.py | 18 +- .../shopping_cart_settings.py | 9 +- erpnext/shopping_cart/utils.py | 3 +- erpnext/support/doctype/issue/issue.json | 4 +- erpnext/support/doctype/issue/issue.py | 8 +- erpnext/templates/includes/address_row.html | 20 +++ erpnext/templates/includes/issue_row.html | 16 ++ .../templates/includes/transaction_row.html | 7 +- erpnext/templates/pages/address.html | 112 ------------ erpnext/templates/pages/address.py | 62 ------- erpnext/templates/pages/addresses.html | 50 ------ erpnext/templates/pages/addresses.py | 13 -- erpnext/templates/pages/ticket.html | 116 ------------ erpnext/templates/pages/ticket.py | 41 ----- erpnext/templates/pages/tickets.html | 92 ---------- erpnext/templates/pages/tickets.py | 54 ------ .../utilities/doctype/address/address.json | 6 +- erpnext/utilities/doctype/address/address.py | 19 ++ 25 files changed, 330 insertions(+), 570 deletions(-) create mode 100644 erpnext/patches/v5_0/portal_fixes.py create mode 100644 erpnext/setup/fixtures/web_form/addresses.json create mode 100644 erpnext/setup/fixtures/web_form/issues.json create mode 100644 erpnext/templates/includes/address_row.html create mode 100644 erpnext/templates/includes/issue_row.html 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/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 diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index de92f13ae7..16ff4b4d29 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -334,7 +334,7 @@ class AccountsController(TransactionBase): @frappe.whitelist() def get_tax_rate(account_head): return frappe.db.get_value("Account", account_head, "tax_rate") - + @frappe.whitelist() def get_default_taxes_and_charges(master_doctype): default_tax = frappe.db.get_value(master_doctype, {"is_default": 1}) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 0d75a5312d..e9cf0c9eb2 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -38,16 +38,14 @@ website_route_rules = [ {"from_route": "/invoices", "to_route": "Sales Invoice"}, {"from_route": "/invoices/", "to_route": "print", "defaults": {"doctype": "Sales Invoice"}}, {"from_route": "/shipments", "to_route": "Delivery Note"}, - {"from_route": "/shipments/", "to_route": "print", "defaults": {"doctype": "Delivery Note"}}, - {"from_route": "/issues", "to_route": "Issue"}, - {"from_route": "/issues/", "to_route": "print", "defaults": {"doctype": "Issue"}}, - {"from_route": "/addresses", "to_route": "Address"}, + {"from_route": "/shipments/", "to_route": "print", "defaults": {"doctype": "Delivery Note"}} ] has_website_permission = { "Sales Order": "erpnext.controllers.website_list_for_contact.has_website_permission", "Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission", - "Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission" + "Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission", + "Issue": "erpnext.support.doctype.issue.issue.has_website_permission" } dump_report_map = "erpnext.startup.report_data_map.data_map" diff --git a/erpnext/patches.txt b/erpnext/patches.txt index d40db971b4..729221a35c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -161,4 +161,5 @@ erpnext.patches.v5_0.set_footer_address execute:frappe.db.set_value("Backup Manager", None, "send_backups_to_dropbox", 1 if frappe.db.get_value("Backup Manager", None, "upload_backups_to_dropbox") in ("Daily", "Weekly") else 0) execute:frappe.db.sql_list("delete from `tabDocPerm` where parent='Issue' and modified_by='Administrator' and role='Guest'") erpnext.patches.v5_0.update_item_and_description_again -erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party \ No newline at end of file +erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party +erpnext.patches.v5_0.portal_fixes diff --git a/erpnext/patches/v5_0/portal_fixes.py b/erpnext/patches/v5_0/portal_fixes.py new file mode 100644 index 0000000000..83c6d6856d --- /dev/null +++ b/erpnext/patches/v5_0/portal_fixes.py @@ -0,0 +1,3 @@ +def execute(): + import erpnext.setup.install + erpnext.setup.install.add_web_forms() diff --git a/erpnext/setup/fixtures/web_form/addresses.json b/erpnext/setup/fixtures/web_form/addresses.json new file mode 100644 index 0000000000..8051c726e0 --- /dev/null +++ b/erpnext/setup/fixtures/web_form/addresses.json @@ -0,0 +1,167 @@ +[ + { + "allow_comments": 0, + "allow_delete": 0, + "allow_edit": 1, + "allow_multiple": 1, + "breadcrumbs": null, + "doc_type": "Address", + "docstatus": 0, + "doctype": "Web Form", + "introduction_text": null, + "login_required": 1, + "modified": "2015-06-01 06:53:43.699336", + "name": "addresses", + "page_name": "addresses", + "published": 1, + "success_message": null, + "success_url": "/addresses", + "title": "Addresses", + "web_form_fields": [ + { + "default": null, + "description": "", + "fieldname": "address_title", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Title", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "address_type", + "fieldtype": "Select", + "hidden": 0, + "label": "Address Type", + "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", + "read_only": 0, + "reqd": 1 + }, + { + "default": null, + "description": null, + "fieldname": "address_line1", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Line 1", + "options": null, + "read_only": 0, + "reqd": 1 + }, + { + "default": null, + "description": null, + "fieldname": "address_line2", + "fieldtype": "Data", + "hidden": 0, + "label": "Address Line 2", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "city", + "fieldtype": "Data", + "hidden": 0, + "label": "City/Town", + "options": null, + "read_only": 0, + "reqd": 1 + }, + { + "default": null, + "description": null, + "fieldname": "state", + "fieldtype": "Data", + "hidden": 0, + "label": "State", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "pincode", + "fieldtype": "Data", + "hidden": 0, + "label": "Pincode", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "country", + "fieldtype": "Data", + "hidden": 0, + "label": "Country", + "options": "Country", + "read_only": 0, + "reqd": 1 + }, + { + "default": null, + "description": null, + "fieldname": null, + "fieldtype": "Column Break", + "hidden": null, + "label": null, + "options": null, + "read_only": null, + "reqd": null + }, + { + "default": null, + "description": null, + "fieldname": "email_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Email Id", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "phone", + "fieldtype": "Data", + "hidden": 0, + "label": "Phone", + "options": null, + "read_only": 0, + "reqd": 1 + }, + { + "default": "0", + "description": "", + "fieldname": "is_primary_address", + "fieldtype": "Check", + "hidden": 0, + "label": "Preferred Billing Address", + "options": null, + "read_only": 0, + "reqd": 0 + }, + { + "default": "0", + "description": "", + "fieldname": "is_shipping_address", + "fieldtype": "Check", + "hidden": 0, + "label": "Preferred Shipping Address", + "options": null, + "read_only": 0, + "reqd": 0 + } + ], + "web_page_link_text": null + } +] \ No newline at end of file diff --git a/erpnext/setup/fixtures/web_form/issues.json b/erpnext/setup/fixtures/web_form/issues.json new file mode 100644 index 0000000000..8561e47aeb --- /dev/null +++ b/erpnext/setup/fixtures/web_form/issues.json @@ -0,0 +1,57 @@ +[ + { + "allow_comments": 1, + "allow_delete": 1, + "allow_edit": 1, + "allow_multiple": 1, + "breadcrumbs": "[{\"title\":\"Issues\", \"name\":\"issues\"}]", + "doc_type": "Issue", + "docstatus": 0, + "doctype": "Web Form", + "introduction_text": null, + "login_required": 1, + "modified": "2015-06-01 05:59:03.697380", + "name": "issues", + "page_name": "issues", + "published": 1, + "success_message": "", + "success_url": "/issues", + "title": "Issues", + "web_form_fields": [ + { + "default": null, + "description": null, + "fieldname": "subject", + "fieldtype": "Data", + "hidden": 0, + "label": "Subject", + "options": null, + "read_only": 0, + "reqd": 1 + }, + { + "default": "Open", + "description": null, + "fieldname": "status", + "fieldtype": "Select", + "hidden": null, + "label": "Status", + "options": "Open\nReplied\nHold\nClosed", + "read_only": 1, + "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "description", + "fieldtype": "Text", + "hidden": 0, + "label": "Description", + "options": null, + "read_only": 0, + "reqd": 0 + } + ], + "web_page_link_text": null + } +] \ No newline at end of file diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py index 3fbeabc8b0..8ed6374fde 100644 --- a/erpnext/setup/install.py +++ b/erpnext/setup/install.py @@ -15,6 +15,7 @@ def after_install(): feature_setup() from erpnext.setup.page.setup_wizard.setup_wizard import add_all_roles_to add_all_roles_to("Administrator") + add_web_forms() frappe.db.commit() def feature_setup(): @@ -48,3 +49,12 @@ def set_single_defaults(): pass frappe.db.set_default("date_format", "dd-mm-yyyy") + +def add_web_forms(): + """Import web forms for Issues and Addresses""" + from frappe.modules.import_file import import_file_by_path + + import_file_by_path(frappe.get_app_path("erpnext", "setup/fixtures/web_form/issues.json"), + data_import=True) + import_file_by_path(frappe.get_app_path("erpnext", "setup/fixtures/web_form/addresses.json"), + data_import=True) diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py index 0b09eb7156..1db656a7c8 100644 --- a/erpnext/shopping_cart/cart.py +++ b/erpnext/shopping_cart/cart.py @@ -5,17 +5,18 @@ from __future__ import unicode_literals import frappe from frappe import throw, _ import frappe.defaults -from frappe.utils import flt, get_fullname, fmt_money, cstr +from frappe.utils import cint, flt, get_fullname, fmt_money, cstr from erpnext.utilities.doctype.address.address import get_address_display from frappe.utils.nestedset import get_root_of class WebsitePriceListMissingError(frappe.ValidationError): pass def set_cart_count(quotation=None): - if not quotation: - quotation = _get_cart_quotation() - cart_count = cstr(len(quotation.get("items"))) - frappe.local.cookie_manager.set_cookie("cart_count", cart_count) + if cint(frappe.db.get_singles_value("Shopping Cart Settings", "enabled")): + if not quotation: + quotation = _get_cart_quotation() + cart_count = cstr(len(quotation.get("items"))) + frappe.local.cookie_manager.set_cookie("cart_count", cart_count) @frappe.whitelist() def get_cart_quotation(doc=None): @@ -29,7 +30,7 @@ def get_cart_quotation(doc=None): return { "doc": decorate_quotation_doc(doc), "addresses": [{"name": address.name, "display": address.display} - for address in get_address_docs(party)], + for address in get_address_docs(party=party)], "shipping_rules": get_applicable_shipping_rules(party) } @@ -281,12 +282,13 @@ def get_lead_or_customer(): return lead_doc -def get_address_docs(party=None): +def get_address_docs(doctype, txt, filters, limit_start, limit_page_length=20, party=None): if not party: party = get_lead_or_customer() address_docs = frappe.db.sql("""select * from `tabAddress` - where `%s`=%s order by name""" % (party.doctype.lower(), "%s"), party.name, + where `{0}`=%s order by name limit {1}, {2}""".format(party.doctype.lower(), + limit_start, limit_page_length), party.name, as_dict=True, update={"doctype": "Address"}) for address in address_docs: diff --git a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py index 5fba1ff22f..cdfe0fd8dc 100644 --- a/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py +++ b/erpnext/shopping_cart/doctype/shopping_cart_settings/shopping_cart_settings.py @@ -8,7 +8,7 @@ import frappe from frappe import _, msgprint from frappe.utils import comma_and from frappe.model.document import Document -from frappe.utils.nestedset import get_ancestors_of +from frappe.utils.nestedset import get_ancestors_of, get_root_of from erpnext.utilities.doctype.address.address import get_territory_from_address class ShoppingCartSetupError(frappe.ValidationError): pass @@ -42,7 +42,7 @@ class ShoppingCartSettings(Document): return territory_name_map def validate_price_lists(self): - territory_name_map = self.validate_overlapping_territories("price_lists", "selling_price_list") + self.validate_overlapping_territories("price_lists", "selling_price_list") # validate that a Shopping Cart Price List exists for the default territory as a catch all! price_list_for_default_territory = self.get_name_from_territory(self.default_territory, "price_lists", @@ -131,7 +131,8 @@ class ShoppingCartSettings(Document): def get_price_list(self, billing_territory): price_list = self.get_name_from_territory(billing_territory, "price_lists", "selling_price_list") if not (price_list and price_list[0]): - price_list = self.get_name_from_territory(self.default_territory, "price_lists", "selling_price_list") + price_list = self.get_name_from_territory(self.default_territory or get_root_of("Territory"), + "price_lists", "selling_price_list") return price_list and price_list[0] or None @@ -165,7 +166,7 @@ def is_cart_enabled(): return get_shopping_cart_settings().enabled def get_default_territory(): - return get_shopping_cart_settings().default_territory + return get_shopping_cart_settings().default_territory or get_root_of("Territory") def check_shopping_cart_enabled(): if not get_shopping_cart_settings().enabled: diff --git a/erpnext/shopping_cart/utils.py b/erpnext/shopping_cart/utils.py index e63e452161..09bfa4329a 100644 --- a/erpnext/shopping_cart/utils.py +++ b/erpnext/shopping_cart/utils.py @@ -6,7 +6,6 @@ from __future__ import unicode_literals import frappe from frappe import _ import frappe.defaults -from frappe.utils import cint from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import is_cart_enabled def show_cart_count(): @@ -44,6 +43,6 @@ def update_my_account_context(context): {"label": _("Orders"), "url": "orders"}, {"label": _("Invoices"), "url": "invoices"}, {"label": _("Shipments"), "url": "shipments"}, - # {"label": _("Issues"), "url": "tickets"}, + {"label": _("Issues"), "url": "issues"}, {"label": _("Addresses"), "url": "addresses"}, ]) diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json index 5892453d9a..285804cf84 100644 --- a/erpnext/support/doctype/issue/issue.json +++ b/erpnext/support/doctype/issue/issue.json @@ -66,7 +66,7 @@ "oldfieldtype": "Data", "options": "Email", "permlevel": 0, - "reqd": 1 + "reqd": 0 }, { "fieldname": "fold", @@ -233,7 +233,7 @@ ], "icon": "icon-ticket", "idx": 1, - "modified": "2015-05-28 03:21:04.690112", + "modified": "2015-06-01 03:48:24.849210", "modified_by": "Administrator", "module": "Support", "name": "Issue", diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index 2555bfaffd..76e5a10c8e 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -17,6 +17,8 @@ class Issue(Document): return "{0}: {1}".format(_(self.status), self.subject) def validate(self): + if not self.raised_by: + self.raised_by = frappe.session.user self.update_status() self.set_lead_contact(self.raised_by) @@ -54,7 +56,8 @@ class Issue(Document): def get_list_context(context=None): return { "title": _("My Issues"), - "get_list": get_issue_list + "get_list": get_issue_list, + "row_template": "templates/includes/issue_row.html" } def get_issue_list(doctype, txt, filters, limit_start, limit_page_length=20): @@ -84,3 +87,6 @@ def set_multiple_status(names, status): names = json.loads(names) for name in names: set_status(name, status) + +def has_website_permission(doc, ptype, user, verbose=False): + return doc.raised_by==user diff --git a/erpnext/templates/includes/address_row.html b/erpnext/templates/includes/address_row.html new file mode 100644 index 0000000000..f7eaa76ae9 --- /dev/null +++ b/erpnext/templates/includes/address_row.html @@ -0,0 +1,20 @@ + diff --git a/erpnext/templates/includes/issue_row.html b/erpnext/templates/includes/issue_row.html new file mode 100644 index 0000000000..30b2ab0723 --- /dev/null +++ b/erpnext/templates/includes/issue_row.html @@ -0,0 +1,16 @@ +
+
+ +
+ + {{ doc.status }} +
+
+ {{ frappe.format_date(doc.creation) }} +
+
+
diff --git a/erpnext/templates/includes/transaction_row.html b/erpnext/templates/includes/transaction_row.html index ca03bd3574..a677fa5ad3 100644 --- a/erpnext/templates/includes/transaction_row.html +++ b/erpnext/templates/includes/transaction_row.html @@ -1,5 +1,6 @@ {% set doc = frappe.get_doc(doc) %} - + - + diff --git a/erpnext/templates/pages/address.html b/erpnext/templates/pages/address.html deleted file mode 100644 index 854460404f..0000000000 --- a/erpnext/templates/pages/address.html +++ /dev/null @@ -1,112 +0,0 @@ -{% block title %} {{ title }} {% endblock %} - -{% block header %}

{{ title }}

{% endblock %} - -{% block content %} -{% macro render_fields(docfields) -%} -{% for df in docfields -%} - {% if df.fieldtype == "Data" -%} -
- - -
- {% elif df.fieldtype == "Check" -%} -
- -
- {% elif df.fieldtype in ("Select", "Link") -%} -
- {% set select_options = frappe.get_list(df.options)|map(attribute="name") - if df.fieldtype == "Link" else df.options.split("\n") %} - - -
- {%- endif %} -{%- endfor %} -{%- endmacro %} - -
- -

{{ title }}

- -
-
- -
-
-
- {{ render_fields(meta.left_fields) }} -
-
- {{ render_fields(meta.right_fields) }} -
- - -
- - - - -{% endblock %} diff --git a/erpnext/templates/pages/address.py b/erpnext/templates/pages/address.py deleted file mode 100644 index 20f2798e11..0000000000 --- a/erpnext/templates/pages/address.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import json - -import frappe -from erpnext.shopping_cart.cart import get_lead_or_customer, update_cart_address -from frappe.desk.form.meta import get_meta - -no_cache = 1 -no_sitemap = 1 - -def get_context(context): - def _get_fields(fieldnames): - return [frappe._dict(zip(["label", "fieldname", "fieldtype", "options"], - [df.label, df.fieldname, df.fieldtype, df.options])) - for df in get_meta("Address").get("fields", {"fieldname": ["in", fieldnames]})] - - docname = doc = None - title = "New Address" - if frappe.form_dict.name: - doc = frappe.get_doc("Address", frappe.form_dict.name) - docname = doc.name - title = doc.name - - return { - "doc": doc, - "meta": frappe._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"]) - }), - "docname": docname, - "title": title - } - -@frappe.whitelist() -def save_address(fields, address_fieldname=None): - party = get_lead_or_customer() - fields = json.loads(fields) - - if fields.get("name"): - doc = frappe.get_doc("Address", fields.get("name")) - else: - doc = frappe.get_doc({"doctype": "Address", "__islocal": 1}) - - doc.update(fields) - - party_fieldname = party.doctype.lower() - doc.update({ - party_fieldname: party.name, - (party_fieldname + "_name"): party.get(party_fieldname + "_name") - }) - doc.flags.ignore_permissions = True - doc.save() - - if address_fieldname: - update_cart_address(address_fieldname, doc.name) - - return doc.name diff --git a/erpnext/templates/pages/addresses.html b/erpnext/templates/pages/addresses.html deleted file mode 100644 index a0562c6160..0000000000 --- a/erpnext/templates/pages/addresses.html +++ /dev/null @@ -1,50 +0,0 @@ -{% block title %} {{ "My Addresses" }} {% endblock %} - -{% block header %}

My Addresses

{% endblock %} - -{% block breadcrumbs %}{% include "templates/includes/breadcrumbs.html" %}{% endblock %} - -{% block content %} -
-

New Address

-
-
-
{{ _("Loading") }}...
-
-
- - - - -{% endblock %} - diff --git a/erpnext/templates/pages/addresses.py b/erpnext/templates/pages/addresses.py deleted file mode 100644 index d96ae9b20e..0000000000 --- a/erpnext/templates/pages/addresses.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from erpnext.shopping_cart.cart import get_address_docs - -no_cache = 1 -no_sitemap = 1 - -@frappe.whitelist() -def get_addresses(): - return get_address_docs() diff --git a/erpnext/templates/pages/ticket.html b/erpnext/templates/pages/ticket.html deleted file mode 100644 index 67d4800cc7..0000000000 --- a/erpnext/templates/pages/ticket.html +++ /dev/null @@ -1,116 +0,0 @@ -{% block title %} {{ title }} {% endblock %} - -{% block header %}

{{ title }}

{% endblock %} - -{% block content %} -{% set status_label = { - "Open": "label-success", - "To Reply": "label-danger", - "Closed": "label-default" -} %} - -
- - {% if not doc -%} - - {% else %} -
- {%- if doc.status -%} - {% if doc.status == "Waiting for Customer" -%} - {% set status = "To Reply" %} - {% else %} - {% set status = doc.status %} - {%- endif -%} -
-
- {{ status }} -
-
-
{{ doc.subject }}
-
-
- {{ frappe.utils.formatdate(doc.creation) }} -
-
-
-

Messages

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

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

-
-
- {%- endif -%} - {% endif -%} -
- - - - -{% endblock %} diff --git a/erpnext/templates/pages/ticket.py b/erpnext/templates/pages/ticket.py deleted file mode 100644 index 811f4fb94b..0000000000 --- a/erpnext/templates/pages/ticket.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe import _ -from frappe.utils import today - -no_cache = 1 -no_sitemap = 1 - -def get_context(context): - doc = frappe.get_doc("Issue", frappe.form_dict.name) - if doc.raised_by == frappe.session.user: - ticket_context = { - "title": doc.name, - "doc": doc - } - else: - ticket_context = {"title": "Not Allowed", "doc": {}} - - return ticket_context - -@frappe.whitelist() -def add_reply(ticket, message): - if not message: - raise frappe.throw(_("Please write something")) - - doc = frappe.get_doc("Issue", ticket) - if doc.raised_by != frappe.session.user: - raise frappe.throw(_("You are not allowed to reply to this ticket."), frappe.PermissionError) - - comm = frappe.get_doc({ - "doctype":"Communication", - "subject": doc.subject, - "content": message, - "sender": doc.raised_by, - "sent_or_received": "Received" - }) - comm.insert(ignore_permissions=True) - diff --git a/erpnext/templates/pages/tickets.html b/erpnext/templates/pages/tickets.html deleted file mode 100644 index 40cd80ece5..0000000000 --- a/erpnext/templates/pages/tickets.html +++ /dev/null @@ -1,92 +0,0 @@ -{% block title %} {{ title }} {% endblock %} - -{% block header %}

{{ title }}

{% endblock %} - -{% block content %} -{% include "templates/includes/transactions.html" %} - - - - -{% endblock %} - diff --git a/erpnext/templates/pages/tickets.py b/erpnext/templates/pages/tickets.py deleted file mode 100644 index 393c020cba..0000000000 --- a/erpnext/templates/pages/tickets.py +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.utils import cint, formatdate - -no_cache = 1 -no_sitemap = 1 - -def get_context(context): - return { - "title": "My Tickets", - "method": "erpnext.templates.pages.tickets.get_tickets", - "icon": "icon-ticket", - "empty_list_message": "No Tickets Raised", - "page": "ticket" - } - -@frappe.whitelist() -def get_tickets(start=0): - tickets = frappe.db.sql("""select name, subject, status, creation - from `tabIssue` where raised_by=%s - order by modified desc - limit %s, 20""", (frappe.session.user, cint(start)), as_dict=True) - for t in tickets: - t.creation = formatdate(t.creation) - - return tickets - -@frappe.whitelist() -def make_new_ticket(subject, message): - if not (subject and message): - raise frappe.throw(_("Please write something in subject and message!")) - - ticket = frappe.get_doc({ - "doctype":"Issue", - "subject": subject, - "raised_by": frappe.session.user, - }) - ticket.insert(ignore_permissions=True) - - comm = frappe.get_doc({ - "doctype":"Communication", - "subject": subject, - "content": message, - "sender": frappe.session.user, - "sent_or_received": "Received", - "reference_doctype": "Issue", - "reference_name": ticket.name - }) - comm.insert(ignore_permissions=True) - - return ticket.name diff --git a/erpnext/utilities/doctype/address/address.json b/erpnext/utilities/doctype/address/address.json index 49cdd834dd..7cb8d82c4e 100644 --- a/erpnext/utilities/doctype/address/address.json +++ b/erpnext/utilities/doctype/address/address.json @@ -112,7 +112,7 @@ }, { "default": "0", - "description": "Check to make primary address", + "description": "", "fieldname": "is_primary_address", "fieldtype": "Check", "label": "Preferred Billing Address", @@ -120,7 +120,7 @@ }, { "default": "0", - "description": "Check to make Shipping Address", + "description": "", "fieldname": "is_shipping_address", "fieldtype": "Check", "in_list_view": 0, @@ -199,7 +199,7 @@ "icon": "icon-map-marker", "idx": 1, "in_dialog": 0, - "modified": "2015-02-20 05:07:56.567822", + "modified": "2015-06-01 06:42:18.331818", "modified_by": "Administrator", "module": "Utilities", "name": "Address", diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py index 1592d22bfa..e2ca74f9c4 100644 --- a/erpnext/utilities/doctype/address/address.py +++ b/erpnext/utilities/doctype/address/address.py @@ -84,5 +84,24 @@ def get_territory_from_address(address): return territory +def get_list_context(context=None): + from erpnext.shopping_cart.cart import get_address_docs + return { + "title": _("My Addresses"), + "get_list": get_address_docs, + "row_template": "templates/includes/address_row.html", + } + +def has_website_permission(doc, ptype, user, verbose=False): + """Returns true if customer or lead matches with user""" + customer = frappe.db.get_value("Contact", {"email_id": frappe.session.user}, "customer") + if customer: + return doc.customer == customer + else: + lead = frappe.db.get_value("Lead", {"email_id": frappe.session.user}) + if lead: + return doc.lead == lead + + return False From aded46d33e1877b4f7c84a755ca4dc662388d938 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jun 2015 17:23:42 +0530 Subject: [PATCH 2/3] [fix] product search in new block header_actions --- erpnext/templates/generators/item.html | 5 +++- erpnext/templates/generators/item_group.html | 5 +++- .../templates/includes/product_in_grid.html | 2 +- .../templates/includes/product_in_list.html | 6 ++--- .../includes/product_search_box.html | 27 +++++++++---------- erpnext/templates/pages/product_search.html | 5 +++- 6 files changed, 28 insertions(+), 22 deletions(-) diff --git a/erpnext/templates/generators/item.html b/erpnext/templates/generators/item.html index aa02376bce..535edcdb73 100644 --- a/erpnext/templates/generators/item.html +++ b/erpnext/templates/generators/item.html @@ -2,10 +2,13 @@ {% block header %}

{{ title }}

{% endblock %} +{% block header_actions %} +{% include 'templates/includes/product_search_box.html' %} +{% endblock %} + {% block content %} {% from "erpnext/templates/includes/macros.html" import product_image %}
- {% include 'templates/includes/product_search_box.html' %}
diff --git a/erpnext/templates/generators/item_group.html b/erpnext/templates/generators/item_group.html index 348d330419..2652f6f74d 100644 --- a/erpnext/templates/generators/item_group.html +++ b/erpnext/templates/generators/item_group.html @@ -1,6 +1,9 @@ +{% block header_actions %} +{% include 'templates/includes/product_search_box.html' %} +{% endblock %} + {% block content %}
- {% include 'templates/includes/product_search_box.html' %}
{% if slideshow %} {% include "templates/includes/slideshow.html" %} diff --git a/erpnext/templates/includes/product_in_grid.html b/erpnext/templates/includes/product_in_grid.html index ea498120e8..d2c1c46ee6 100644 --- a/erpnext/templates/includes/product_in_grid.html +++ b/erpnext/templates/includes/product_in_grid.html @@ -1,6 +1,6 @@ {% from "erpnext/templates/includes/macros.html" import product_image_square %} - +
{{ product_image_square(website_image) }}
{{ item_name }}
diff --git a/erpnext/templates/includes/product_in_list.html b/erpnext/templates/includes/product_in_list.html index 98e46a7762..2a6cbe1a75 100644 --- a/erpnext/templates/includes/product_in_list.html +++ b/erpnext/templates/includes/product_in_list.html @@ -1,15 +1,15 @@
diff --git a/erpnext/templates/includes/product_search_box.html b/erpnext/templates/includes/product_search_box.html index a5592c10b5..a135396b2f 100644 --- a/erpnext/templates/includes/product_search_box.html +++ b/erpnext/templates/includes/product_search_box.html @@ -1,20 +1,17 @@ + @@ -15,7 +19,6 @@ $(document).ready(function() { }); -{% include "templates/includes/product_search_box.html" %}

Search Results

From cf29f6468dde48b39c0d44e3d05bf2479cc5e342 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 1 Jun 2015 17:47:03 +0530 Subject: [PATCH 3/3] [minor] add attachment to issue via portal: --- erpnext/setup/fixtures/web_form/issues.json | 13 ++++++++++++- erpnext/support/doctype/issue/issue.json | 10 +++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/fixtures/web_form/issues.json b/erpnext/setup/fixtures/web_form/issues.json index 8561e47aeb..84ff1c2001 100644 --- a/erpnext/setup/fixtures/web_form/issues.json +++ b/erpnext/setup/fixtures/web_form/issues.json @@ -10,7 +10,7 @@ "doctype": "Web Form", "introduction_text": null, "login_required": 1, - "modified": "2015-06-01 05:59:03.697380", + "modified": "2015-06-01 08:14:26.350792", "name": "issues", "page_name": "issues", "published": 1, @@ -50,6 +50,17 @@ "options": null, "read_only": 0, "reqd": 0 + }, + { + "default": null, + "description": null, + "fieldname": "attachment", + "fieldtype": "Attach", + "hidden": null, + "label": "Attachment", + "options": null, + "read_only": null, + "reqd": null } ], "web_page_link_text": null diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json index 285804cf84..e1d9a8fffb 100644 --- a/erpnext/support/doctype/issue/issue.json +++ b/erpnext/support/doctype/issue/issue.json @@ -229,11 +229,19 @@ "hidden": 1, "label": "Content Type", "permlevel": 0 + }, + { + "fieldname": "attachment", + "fieldtype": "Attach", + "hidden": 1, + "label": "Attachment", + "permlevel": 0, + "precision": "" } ], "icon": "icon-ticket", "idx": 1, - "modified": "2015-06-01 03:48:24.849210", + "modified": "2015-06-01 08:14:01.750421", "modified_by": "Administrator", "module": "Support", "name": "Issue",