From 89bd216a0c411588d273669d8b18731e30459221 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 26 Jun 2013 18:28:54 +0530 Subject: [PATCH 01/11] [Fix] SMS Center --- .../purchase_taxes_and_charges_master.js | 2 +- .../purchase_taxes_and_charges_master.py | 14 +++++++------- .../sales_invoice_item/sales_invoice_item.txt | 7 ++++--- .../supplier_quotation/supplier_quotation.js | 1 - selling/doctype/sms_center/sms_center.py | 7 ++++--- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 53588e0629..f04f895baf 100644 --- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -147,7 +147,7 @@ cur_frm.cscript.account_head = function(doc, cdt, cdn) { d.account_head = ''; } else if(d.account_head && d.charge_type) { - arg = "{'charge_type' : '" + d.charge_type +"', 'account_head' : '" + d.account_head + "'}"; + arg = "{'charge_type' : '" + d.charge_type + "', 'account_head' : '" + d.account_head + "'}"; get_server_fields('get_rate', arg, 'purchase_tax_details', doc, cdt, cdn, 1); } refresh_field('account_head',d.name,'purchase_tax_details'); diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py index 1250db5c28..995415e29a 100644 --- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py +++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py @@ -26,11 +26,11 @@ sql = webnotes.conn.sql class DocType: - def __init__(self, doc, doclist=[]): - self.doc = doc - self.doclist = doclist + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist - # Get Tax Rate if account type is Tax - # =================================================================== - def get_rate(self, arg): - return get_obj('Purchase Common').get_rate(arg, self) \ No newline at end of file + # Get Tax Rate if account type is Tax + # =================================================================== + def get_rate(self, arg): + return get_obj('Purchase Common').get_rate(arg, self) \ No newline at end of file diff --git a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt index 89c86f8219..82ad3b1527 100644 --- a/accounts/doctype/sales_invoice_item/sales_invoice_item.txt +++ b/accounts/doctype/sales_invoice_item/sales_invoice_item.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-04-19 11:00:07", + "creation": "2013-06-04 11:02:19", "docstatus": 0, - "modified": "2013-05-22 12:06:15", + "modified": "2013-06-26 14:33:21", "modified_by": "Administrator", "owner": "Administrator" }, @@ -243,7 +243,8 @@ "oldfieldname": "serial_no", "oldfieldtype": "Small Text", "print_hide": 0, - "read_only": 0 + "read_only": 0, + "reqd": 0 }, { "doctype": "DocField", diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js index 1e4f6cbfb7..bac6e9f4ef 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/buying/doctype/supplier_quotation/supplier_quotation.js @@ -87,7 +87,6 @@ cur_frm.cscript.supplier = function(doc, dt, dn) { get_server_fields('get_default_supplier_address', JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1, function() { cur_frm.refresh(); }); - cur_frm.cscript.toggle_contact_section(doc); } } diff --git a/selling/doctype/sms_center/sms_center.py b/selling/doctype/sms_center/sms_center.py index 7d50e71232..8b404e6a4d 100644 --- a/selling/doctype/sms_center/sms_center.py +++ b/selling/doctype/sms_center/sms_center.py @@ -35,11 +35,12 @@ class DocType: def create_receiver_list(self): rec, where_clause = '', '' if self.doc.send_to == 'All Customer Contact': - where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(is_customer, 0) = 1" + where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(customer, '') != ''" if self.doc.send_to == 'All Supplier Contact': - where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(is_supplier, 0) = 1" + where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(supplier, '') != ''" if self.doc.send_to == 'All Sales Partner Contact': - where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1" + where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % self.doc.sales_partner or " and ifnull(sales_partner, '') != ''" + if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']: rec = sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause) elif self.doc.send_to == 'All Lead (Open)': From 4924a9f7648cb3515fdbe282a77926527a715e9b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 27 Jun 2013 11:01:14 +0530 Subject: [PATCH 02/11] [fix] payment reconciliation tool --- .../payment_to_invoice_matching_tool.js | 1 + 1 file changed, 1 insertion(+) diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js index 8b35bc1028..ac7d9d2d14 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js +++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.js @@ -50,6 +50,7 @@ cur_frm.fields_dict.voucher_no.get_query = function(doc) { where against_voucher_type = '%(dt)s' \ and against_voucher = gle.voucher_no \ and voucher_no != gle.voucher_no \ + and account = gle.account \ and ifnull(is_cancelled, 'No') = 'No') != \ abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0)) \ ORDER BY gle.posting_date DESC, gle.voucher_no DESC LIMIT 50", From f47617c6e606e10eaa78b1168819c60f93a1d2bd Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 27 Jun 2013 11:01:36 +0530 Subject: [PATCH 03/11] [Fix] Purchase Register --- .../purchase_register/purchase_register.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py index d6233a41e0..6bc35218c9 100644 --- a/accounts/report/purchase_register/purchase_register.py +++ b/accounts/report/purchase_register/purchase_register.py @@ -40,9 +40,10 @@ def execute(filters=None): # invoice details purchase_order = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_order", []))) purchase_receipt = list(set(invoice_po_pr_map.get(inv.name, {}).get("purchase_receipt", []))) + project_name = list(set(invoice_po_pr_map.get(inv.name, {}).get("project_name", []))) row = [inv.name, inv.posting_date, inv.supplier, inv.credit_to, - account_map.get(inv.credit_to), inv.project_name, inv.bill_no, inv.bill_date, + account_map.get(inv.credit_to), ", ".join(project_name), inv.bill_no, inv.bill_date, inv.remarks, ", ".join(purchase_order), ", ".join(purchase_receipt)] # map expense values @@ -105,11 +106,10 @@ def get_conditions(filters): def get_invoices(filters): conditions = get_conditions(filters) - return webnotes.conn.sql("""select pi.name, pi.posting_date, pi.credit_to, - pii.project_name, pi.supplier, pi.bill_no, pi.bill_date, pi.remarks, pi.net_total, - pi.total_tax, pi.grand_total, pi.outstanding_amount - from `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pii - where pii.parent = pi.name and pi.docstatus = 1 %s + return webnotes.conn.sql("""select name, posting_date, credit_to, + supplier, bill_no, bill_date, remarks, net_total, + total_tax, grand_total, outstanding_amount + from `tabPurchase Invoice` where docstatus = 1 %s order by posting_date desc, name desc""" % conditions, filters, as_dict=1) @@ -138,8 +138,8 @@ def get_invoice_tax_map(invoice_list): return invoice_tax_map def get_invoice_po_pr_map(invoice_list): - pi_items = webnotes.conn.sql("""select parent, purchase_order, purchase_receipt - from `tabPurchase Invoice Item` where parent in (%s) + pi_items = webnotes.conn.sql("""select parent, purchase_order, purchase_receipt, + project_name from `tabPurchase Invoice Item` where parent in (%s) and (ifnull(purchase_order, '') != '' or ifnull(purchase_receipt, '') != '')""" % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1) @@ -151,6 +151,11 @@ def get_invoice_po_pr_map(invoice_list): if d.purchase_receipt: invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault( "purchase_receipt", []).append(d.purchase_receipt) + if d.project_name: + invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault( + "project_name", []).append(d.project_name) + + webnotes.errprint(invoice_po_pr_map) return invoice_po_pr_map From f1845cf7c977ef3dbf5c34dc7ee25675dc9810d9 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 27 Jun 2013 11:06:11 +0530 Subject: [PATCH 04/11] Removed errprint from purchase register --- accounts/report/purchase_register/purchase_register.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/accounts/report/purchase_register/purchase_register.py b/accounts/report/purchase_register/purchase_register.py index 6bc35218c9..655cf8ced0 100644 --- a/accounts/report/purchase_register/purchase_register.py +++ b/accounts/report/purchase_register/purchase_register.py @@ -154,8 +154,6 @@ def get_invoice_po_pr_map(invoice_list): if d.project_name: invoice_po_pr_map.setdefault(d.parent, webnotes._dict()).setdefault( "project_name", []).append(d.project_name) - - webnotes.errprint(invoice_po_pr_map) return invoice_po_pr_map From c35dd968af8e21a7e60c2eaa192bd84be9276382 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 27 Jun 2013 12:21:34 +0530 Subject: [PATCH 05/11] [fix] invoice with zero values --- accounts/doctype/sales_invoice/sales_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index c17654a601..956867d7ab 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -149,7 +149,7 @@ class DocType(SellingController): ret = get_obj('Sales Common').get_item_details(item.fields, self) for fieldname, value in ret.items(): if self.meta.get_field(fieldname, parentfield="entries") and \ - not item.fields.get(fieldname): + item.fields.get(fieldname) is None: item.fields[fieldname] = value # fetch pos details, if they are not fetched From d6cc5cd08f9e65b706f7a56a94a099dc1b21b58f Mon Sep 17 00:00:00 2001 From: Saurabh Date: Fri, 28 Jun 2013 10:09:46 +0530 Subject: [PATCH 06/11] [Trends Teports] cleanup --- .../purchase_invoice_trends/purchase_invoice_trends.py | 3 +-- .../report/sales_invoice_trends/sales_invoice_trends.py | 3 +-- .../report/purchase_order_trends/purchase_order_trends.py | 3 +-- selling/report/quotation_trends/quotation_trends.py | 3 +-- selling/report/sales_order_trends/sales_order_trends.py | 3 +-- stock/report/delivery_note_trends/delivery_note_trends.py | 3 +-- .../purchase_receipt_trends/purchase_receipt_trends.py | 8 ++------ 7 files changed, 8 insertions(+), 18 deletions(-) diff --git a/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py b/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py index a558a6cecf..659cb85398 100644 --- a/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py +++ b/accounts/report/purchase_invoice_trends/purchase_invoice_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Purchase Invoice" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Purchase Invoice") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/accounts/report/sales_invoice_trends/sales_invoice_trends.py b/accounts/report/sales_invoice_trends/sales_invoice_trends.py index a1068340ec..9a5eaf2f8d 100644 --- a/accounts/report/sales_invoice_trends/sales_invoice_trends.py +++ b/accounts/report/sales_invoice_trends/sales_invoice_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Sales Invoice" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Sales Invoice") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/buying/report/purchase_order_trends/purchase_order_trends.py b/buying/report/purchase_order_trends/purchase_order_trends.py index 9b294656c3..9dc986e456 100644 --- a/buying/report/purchase_order_trends/purchase_order_trends.py +++ b/buying/report/purchase_order_trends/purchase_order_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Purchase Order" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Purchase Order") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/selling/report/quotation_trends/quotation_trends.py b/selling/report/quotation_trends/quotation_trends.py index d08e0f87f1..29f9ef82c2 100644 --- a/selling/report/quotation_trends/quotation_trends.py +++ b/selling/report/quotation_trends/quotation_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns, get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Quotation" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Quotation") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/selling/report/sales_order_trends/sales_order_trends.py b/selling/report/sales_order_trends/sales_order_trends.py index 455fbd4e63..ac7c3ab97b 100644 --- a/selling/report/sales_order_trends/sales_order_trends.py +++ b/selling/report/sales_order_trends/sales_order_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Sales Order" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Sales Order") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/stock/report/delivery_note_trends/delivery_note_trends.py b/stock/report/delivery_note_trends/delivery_note_trends.py index 9878ecc867..e5b2cd094b 100644 --- a/stock/report/delivery_note_trends/delivery_note_trends.py +++ b/stock/report/delivery_note_trends/delivery_note_trends.py @@ -21,8 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Delivery Note" - conditions = get_columns(filters, trans) + conditions = get_columns(filters, "Delivery Note") data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file diff --git a/stock/report/purchase_receipt_trends/purchase_receipt_trends.py b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py index 56c0023a2f..b41ce281f7 100644 --- a/stock/report/purchase_receipt_trends/purchase_receipt_trends.py +++ b/stock/report/purchase_receipt_trends/purchase_receipt_trends.py @@ -21,11 +21,7 @@ from controllers.trends import get_columns,get_data def execute(filters=None): if not filters: filters ={} data = [] - trans = "Purchase Receipt" - conditions = get_columns(filters, trans) - data = get_data(filters, tab, conditions) - - if not data : - webnotes.msgprint("Data not found for selected criterias") + conditions = get_columns(filters, "Purchase Receipt") + data = get_data(filters, conditions) return conditions["columns"], data \ No newline at end of file From b164edc16f6a85a16445fc0c36be61b9eada4d82 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 28 Jun 2013 13:03:39 +0530 Subject: [PATCH 07/11] [fix] cleanup data --- utilities/cleanup_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/cleanup_data.py b/utilities/cleanup_data.py index ed04a94bfa..c9de4a5e23 100644 --- a/utilities/cleanup_data.py +++ b/utilities/cleanup_data.py @@ -27,7 +27,7 @@ def delete_transactions(): 'Maintenance Schedule', 'Leave Application', 'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note', 'Material Request', 'GL Entry', 'Expense Claim', 'Opportunity', 'Delivery Note', 'Customer Issue', 'Bin', 'Authorization Rule', 'Attendance', 'C-Form', - 'Appraisal', 'Installation Note', 'Communication'] + 'Appraisal', 'Installation Note', 'Communication', "Supplier Quotation"] for d in trans: for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): webnotes.conn.sql("delete from `tab%s`" % (t)) From ac24d0fa986431980510a2e0ba0487831788a576 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 1 Jul 2013 14:03:08 +0530 Subject: [PATCH 08/11] [fixes] ignore single doctypes in chekcing linked documents --- patches/patch_list.py | 1 + utilities/cleanup_data.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/patches/patch_list.py b/patches/patch_list.py index efd4d51cce..4955c75e6c 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -242,4 +242,5 @@ patch_list = [ "execute:webnotes.delete_doc('DocType', 'System Console')", "patches.june_2013.p04_fix_event_for_lead_oppty_project", "patches.june_2013.p05_remove_search_criteria_reports", + "execute:webnotes.delete_doc('DocType', 'Update Delivery Date')", ] \ No newline at end of file diff --git a/utilities/cleanup_data.py b/utilities/cleanup_data.py index c9de4a5e23..df7f4be159 100644 --- a/utilities/cleanup_data.py +++ b/utilities/cleanup_data.py @@ -20,14 +20,16 @@ import webnotes def delete_transactions(): print "Deleting transactions..." - trans = ['Timesheet', 'Task', 'Support Ticket', 'Stock Reconciliation', 'Stock Ledger Entry', + trans = ['Task', 'Support Ticket', 'Stock Reconciliation', 'Stock Ledger Entry', 'Stock Entry', 'Sales Order', 'Salary Slip','Sales Invoice', 'Quotation', 'Quality Inspection', 'Purchase Receipt', 'Purchase Order', 'Production Order', 'POS Setting', 'Period Closing Voucher', 'Purchase Invoice', 'Maintenance Visit', 'Maintenance Schedule', 'Leave Application', 'Leave Allocation', 'Lead', 'Journal Voucher', 'Installation Note', 'Material Request', 'GL Entry', 'Expense Claim', 'Opportunity', 'Delivery Note', 'Customer Issue', 'Bin', 'Authorization Rule', 'Attendance', 'C-Form', - 'Appraisal', 'Installation Note', 'Communication', "Supplier Quotation"] + 'Appraisal', 'Installation Note', 'Communication', "Supplier Quotation", "Newsletter", + "Job Applicant", "Web Page", "Website Slideshow", "Blog Post", "Blog Category", "Blogger", + "Time Log", "Time Log Batch", "Workflow"] for d in trans: for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d): webnotes.conn.sql("delete from `tab%s`" % (t)) @@ -66,6 +68,7 @@ def delete_masters(): 'Item Group': ['All Item Groups', 'Default'], 'Item': '', 'Holiday List': '', + 'Activity Type': '', 'Grade': '', 'Feed': '', 'Expense Claim Type': ['Travel', 'Medical', 'Calls', 'Food', 'Others'], From edbf3e1e190f3e58a5e862aaa1aec582fe61b266 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 2 Jul 2013 11:40:16 +0530 Subject: [PATCH 09/11] [webshop] [addresses] address selector, my addresses list --- config.json | 8 + public/js/website_utils.js | 2 +- .../stock_ledger_entry/stock_ledger_entry.py | 2 - utilities/doctype/address/address.py | 26 ++- utilities/doctype/address/address.txt | 58 +++-- utilities/transaction_base.py | 14 ++ website/css/website.css | 4 + website/helpers/cart.py | 91 +++++++- website/templates/js/cart.js | 221 ++++++++++-------- website/templates/pages/account.html | 11 +- website/templates/pages/address.html | 123 ++++++++++ website/templates/pages/addresses.html | 54 +++++ website/templates/pages/cart.html | 26 ++- website/templates/pages/order.html | 6 +- website/templates/pages/orders.html | 2 +- website/templates/pages/partners.html | 4 +- website/templates/pages/profile.html | 2 +- website/templates/pages/tickets.html | 6 +- 18 files changed, 503 insertions(+), 157 deletions(-) create mode 100644 website/templates/pages/address.html create mode 100644 website/templates/pages/addresses.html diff --git a/config.json b/config.json index 46cd8c98f2..5f9ac5e808 100644 --- a/config.json +++ b/config.json @@ -120,6 +120,14 @@ "tickets": { "template": "app/website/templates/pages/tickets" }, + "address": { + "no_cache": true, + "template": "app/website/templates/pages/address", + "args_method": "utilities.doctype.address.address.get_website_args" + }, + "addresses": { + "template": "app/website/templates/pages/addresses" + }, "writers": { "template": "app/website/templates/pages/writers", "args_method": "website.helpers.blog.get_writers_args" diff --git a/public/js/website_utils.js b/public/js/website_utils.js index 098f8da188..59614c54a6 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -10,7 +10,7 @@ erpnext.send_message = function(opts) { method: "website.helpers.contact.send_message", args: opts, callback: opts.callback - }) + }); } wn.call = function(opts) { diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 3492931451..b2a10853ac 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -121,8 +121,6 @@ class DocType(DocListController): self.doc.posting_time = '00:00' def on_doctype_update(self): - webnotes.msgprint(webnotes.conn.sql("""show index from `tabStock Ledger Entry` - where Key_name="posting_sort_index" """)) if not webnotes.conn.sql("""show index from `tabStock Ledger Entry` where Key_name="posting_sort_index" """): webnotes.conn.commit() diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index c475da12b5..90ada5fece 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -18,7 +18,7 @@ from __future__ import unicode_literals import webnotes from webnotes import msgprint -from webnotes.utils import cstr +from webnotes.utils import cstr, cint class DocType: def __init__(self, doc, doclist=[]): @@ -63,4 +63,26 @@ class DocType: if self.doc.fields.get(fieldname): webnotes.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" % (is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name)) - break \ No newline at end of file + break + +def get_website_args(): + 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 + } + \ No newline at end of file diff --git a/utilities/doctype/address/address.txt b/utilities/doctype/address/address.txt index ed39c759c5..1b54abe7f7 100644 --- a/utilities/doctype/address/address.txt +++ b/utilities/doctype/address/address.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:32", "docstatus": 0, - "modified": "2013-06-28 17:06:32", + "modified": "2013-07-01 17:24:17", "modified_by": "Administrator", "owner": "Administrator" }, @@ -40,10 +40,12 @@ "name": "Address" }, { + "description": "Name of person or organization that this address belongs to.", "doctype": "DocField", - "fieldname": "address_details", - "fieldtype": "Section Break", - "label": "Address Details" + "fieldname": "address_title", + "fieldtype": "Data", + "label": "Address Title", + "reqd": 1 }, { "doctype": "DocField", @@ -53,26 +55,18 @@ "options": "Billing\nShipping\nOffice\nPersonal\nPlant\nPostal\nShop\nSubsidiary\nWarehouse\nOther", "reqd": 1 }, - { - "description": "Name of person or organization that this address belongs to.", - "doctype": "DocField", - "fieldname": "address_title", - "fieldtype": "Data", - "label": "Address Title", - "reqd": 1 - }, { "doctype": "DocField", "fieldname": "address_line1", "fieldtype": "Data", - "label": "Address Line1", + "label": "Address Line 1", "reqd": 1 }, { "doctype": "DocField", "fieldname": "address_line2", "fieldtype": "Data", - "label": "Address Line2" + "label": "Address Line 2" }, { "doctype": "DocField", @@ -84,6 +78,15 @@ "reqd": 1, "search_index": 1 }, + { + "doctype": "DocField", + "fieldname": "state", + "fieldtype": "Data", + "in_filter": 1, + "label": "State", + "options": "Suggest", + "search_index": 0 + }, { "doctype": "DocField", "fieldname": "pincode", @@ -103,15 +106,6 @@ "reqd": 1, "search_index": 1 }, - { - "doctype": "DocField", - "fieldname": "state", - "fieldtype": "Data", - "in_filter": 1, - "label": "State", - "options": "Suggest", - "search_index": 0 - }, { "doctype": "DocField", "fieldname": "column_break0", @@ -119,6 +113,12 @@ "print_hide": 0, "width": "50%" }, + { + "doctype": "DocField", + "fieldname": "email_id", + "fieldtype": "Data", + "label": "Email Id" + }, { "doctype": "DocField", "fieldname": "phone", @@ -126,12 +126,6 @@ "label": "Phone", "reqd": 1 }, - { - "doctype": "DocField", - "fieldname": "email_id", - "fieldtype": "Data", - "label": "Email Id" - }, { "doctype": "DocField", "fieldname": "fax", @@ -181,7 +175,7 @@ "read_only": 1 }, { - "depends_on": "eval:!doc.customer && !doc.sales_partner", + "depends_on": "eval:!doc.customer && !doc.sales_partner && !doc.lead", "doctype": "DocField", "fieldname": "supplier", "fieldtype": "Link", @@ -189,7 +183,7 @@ "options": "Supplier" }, { - "depends_on": "eval:!doc.customer && !doc.sales_partner", + "depends_on": "eval:!doc.customer && !doc.sales_partner && !doc.lead", "doctype": "DocField", "fieldname": "supplier_name", "fieldtype": "Data", @@ -200,7 +194,7 @@ "search_index": 0 }, { - "depends_on": "eval:!doc.customer && !doc.supplier", + "depends_on": "eval:!doc.customer && !doc.supplier && !doc.lead", "doctype": "DocField", "fieldname": "sales_partner", "fieldtype": "Link", diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py index 2def0ea05f..ab53575aee 100644 --- a/utilities/transaction_base.py +++ b/utilities/transaction_base.py @@ -312,6 +312,20 @@ class TransactionBase(StatusUpdater): }) webnotes.bean(event_doclist).insert() + + +def get_address_display(address_dict): + meta = webnotes.get_doctype("Address") + address_sequence = (("", "address_line1"), ("\n", "address_line2"), ("\n", "city"), + ("\n", "state"), ("\n" + meta.get_label("pincode") + ": ", "pincode"), ("\n", "country"), + ("\n" + meta.get_label("phone") + ": ", "phone"), ("\n" + meta.get_label("fax") + ": ", "fax")) + + address_display = "" + for separator, fieldname in address_sequence: + if address_dict.get(fieldname): + address_display += separator + address_dict.get(fieldname) + + return address_display def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company): """common validation for currency and price list currency""" diff --git a/website/css/website.css b/website/css/website.css index 737d3d0f4e..34ff983b0b 100644 --- a/website/css/website.css +++ b/website/css/website.css @@ -126,4 +126,8 @@ a { .hidden-sm-inline { display: inline; } +} + +.accordion-heading, .accordion-inner { + padding-left: 10px; } \ No newline at end of file diff --git a/website/helpers/cart.py b/website/helpers/cart.py index a24afb57a9..bc99e7bd4b 100644 --- a/website/helpers/cart.py +++ b/website/helpers/cart.py @@ -8,6 +8,19 @@ from webnotes.utils import cint, get_fullname, fmt_money class WebsitePriceListMissingError(webnotes.ValidationError): pass +@webnotes.whitelist() +def get_cart_quotation(doclist=None): + party = get_lead_or_customer() + + if not doclist: + doclist = _get_cart_quotation(party).doclist + + return { + "doclist": decorate_quotation_doclist(doclist), + "addresses": [{"name": address.name, "display": address.display} + for address in get_address_docs(party)] + } + @webnotes.whitelist() def update_cart(item_code, qty, with_doclist=0): quotation = _get_cart_quotation() @@ -31,9 +44,79 @@ def update_cart(item_code, qty, with_doclist=0): quotation.save() if with_doclist: - return decorate_quotation_doclist(quotation.doclist) + return get_cart_quotation(quotation.doclist) else: return quotation.doc.name + +@webnotes.whitelist() +def update_cart_address(address_fieldname, address_name): + from 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 + + + 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 = webnotes.load_json(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 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") @@ -56,12 +139,6 @@ def get_lead_or_customer(): lead_bean.insert() return lead_bean.doc - - -@webnotes.whitelist() -def get_cart_quotation(): - doclist = _get_cart_quotation(get_lead_or_customer()).doclist - return decorate_quotation_doclist(doclist) def decorate_quotation_doclist(doclist): for d in doclist: diff --git a/website/templates/js/cart.js b/website/templates/js/cart.js index 3e6a344c1c..db6c5714ec 100644 --- a/website/templates/js/cart.js +++ b/website/templates/js/cart.js @@ -30,6 +30,8 @@ $(document).ready(function() { if(r.exc) { if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) { wn.cart.show_error("Oops!", "Price List not configured."); + } else if(r["403"]) { + wn.cart.show_error("Hey!", "You need to be logged in to view your cart."); } else { wn.cart.show_error("Oops!", "Something went wrong."); } @@ -66,114 +68,145 @@ $.extend(wn.cart, { }, }); }); + + $("#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"; + }); }, - render: function(doclist) { - var $cart_wrapper = $("#cart-items").empty(); + 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_billing_address = $("#cart-billing-address").empty(); + var $cart_shipping_address = $("#cart-shipping-address").empty(); - if($.map(doclist, function(d) { return d.item_code || null;}).length===0) { + var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0; + if(no_items) { wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); + $("#cart-addresses").toggle(false); return; } $.each(doclist, function(i, doc) { if(doc.doctype === "Quotation Item") { - doc.image_html = doc.image ? - '
' : - '{% include "app/website/templates/html/product_missing_image.html" %}'; - - if(!doc.web_short_description) doc.web_short_description = doc.description; - - $(repl('
\ -
\ -
\ -
%(image_html)s
\ -
\ -

%(item_name)s

\ -

%(web_short_description)s

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

at %(formatted_rate)s

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

', doc)).appendTo($cart_wrapper); - + wn.cart.render_item_row($cart_items, doc); } }); - - - return; - - if(Object.keys(wn.cart.get_cart()).length) { - - $.each(wn.cart.get_cart(), function(item_code, item) { - item.image_html = item.image ? - '
' : - '{% include "app/website/templates/html/product_missing_image.html" %}'; - item.price_html = item.price ? ('

at ' + item.price + '

') : ""; - - $(repl('
\ -
\ -
\ -
%(image_html)s
\ -
\ -

%(item_name)s

\ -

%(description)s

\ -
\ -
\ -
\ -
\ -

\ - %(price_html)s\ -
\ -

', item)).appendTo($cart_wrapper); - }); - - $('

') - .appendTo($cart_wrapper); - + if(!(addresses && addresses.length)) { + $cart_shipping_address.html('
Hey! Go ahead and add an address
'); } else { - $('

No Items added to cart.

').appendTo($cart_wrapper); + wn.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); + wn.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); } }, - // bind_events: function() { - // // on change of qty - // $(".cart-input-qty").on("change", function on_change_of_qty() { - // wn.cart.set_value_in_cart($(this).attr("item_code"), "qty", $(this).val()); - // }); - // - // // shopping cart button - // $(".checkout-btn").on("click", function() { - // console.log("checkout!"); - // console.log(wn.cart.get_cart()); - // - // var user_is_logged_in = getCookie("full_name"); - // if(user_is_logged_in) { - // wn.call({ - // method: "website.helpers.cart.checkout", - // args: {cart: wn.cart.get_cart()}, - // btn: this, - // callback: function(r) { - // console.log(r); - // } - // }); - // } else { - // window.location.href = "login?from=cart"; - // } - // }); - // } + render_item_row: function($cart_items, doc) { + doc.image_html = doc.image ? + '
' : + '{% include "app/website/templates/html/product_missing_image.html" %}'; + + if(!doc.web_short_description) doc.web_short_description = doc.description; + + $(repl('
\ +
\ +
\ +
%(image_html)s
\ +
\ +

%(item_name)s

\ +

%(web_short_description)s

\ +
\ +
\ +
\ +
\ +
\ + \ +
\ + \ +
\ +
\ +

at %(formatted_rate)s

\ + = %(formatted_amount)s\ +
\ +

', doc)).appendTo($cart_items); + }, + + 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(".accordion-heading") + .css({ + "background-color": "#eee", + "padding": "10px", + }) + .find(".address-title") + .css({"cursor": "pointer"}) + .on("click", function() { + $address_wrapper.find('.accordion-body[data-address-name="' + +$(this).attr("data-address-name")+'"]').collapse("toggle"); + }); + + $address_wrapper.find('input[type="checkbox"]').on("click", function() { + if($(this).is(":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).removeAttr("checked"); + } + }); + + wn.call({ + type: "POST", + method: "website.helpers.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) { + wn.cart.render(r.message); + } + } + }); + } else { + return false; + } + }); + + $address_wrapper.find('input[type="checkbox"][data-address-name="'+ address_name +'"]') + .attr("checked", "checked"); + + $address_wrapper.find(".accordion-body").collapse({ + parent: $address_wrapper, + toggle: false + }); + + $address_wrapper.find('.accordion-body[data-address-name="'+ address_name +'"]') + .collapse("show"); + } }); \ No newline at end of file diff --git a/website/templates/pages/account.html b/website/templates/pages/account.html index f6992e13f5..b3fe5df3c9 100644 --- a/website/templates/pages/account.html +++ b/website/templates/pages/account.html @@ -5,14 +5,15 @@ {% block content %} {% endblock %} \ No newline at end of file diff --git a/website/templates/pages/address.html b/website/templates/pages/address.html new file mode 100644 index 0000000000..5b90928164 --- /dev/null +++ b/website/templates/pages/address.html @@ -0,0 +1,123 @@ +{% extends "app/website/templates/html/page.html" %} + +{% 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 %} + +{% block css %} + +{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/addresses.html b/website/templates/pages/addresses.html new file mode 100644 index 0000000000..85266667f5 --- /dev/null +++ b/website/templates/pages/addresses.html @@ -0,0 +1,54 @@ +{% extends "app/website/templates/html/page.html" %} + +{% set title="My Addresses" %} + +{% block content %} +
+ +

My Addresses

+
+

New Address

+
+
+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/website/templates/pages/cart.html b/website/templates/pages/cart.html index 2619dec08c..9d5f100da9 100644 --- a/website/templates/pages/cart.html +++ b/website/templates/pages/cart.html @@ -8,7 +8,7 @@ {% block content %}
-

Shopping Cart

+

{{ title }}

@@ -20,17 +20,35 @@
-
Item Details
+

Item Details

-
Qty
+

Qty


-
+
+
+
+

Shipping Address

+
+ +
+
+

Billing Address

+
+ +
+ +
+
diff --git a/website/templates/pages/order.html b/website/templates/pages/order.html index 2588d39479..61afe322b6 100644 --- a/website/templates/pages/order.html +++ b/website/templates/pages/order.html @@ -5,9 +5,9 @@ {% block content %}

{{ doc.name }}

diff --git a/website/templates/pages/orders.html b/website/templates/pages/orders.html index f43a474877..bb72fc3087 100644 --- a/website/templates/pages/orders.html +++ b/website/templates/pages/orders.html @@ -14,7 +14,7 @@ wn.currency_symbols = {{ currency_symbols }};
  • My Account /
  • My Orders
  • -

    My Orders

    +

    My Orders


    diff --git a/website/templates/pages/partners.html b/website/templates/pages/partners.html index 93cef3c73a..c09022727f 100644 --- a/website/templates/pages/partners.html +++ b/website/templates/pages/partners.html @@ -1,10 +1,10 @@ {% extends "app/website/templates/html/page.html" %} -{% set title="Sales Partners" %} +{% set title="Partners" %} {% block content %}
    -

    Partners

    +

    {{ title }}


    {% for partner_info in partners %}
    diff --git a/website/templates/pages/profile.html b/website/templates/pages/profile.html index 40d6a197fc..993839eb79 100644 --- a/website/templates/pages/profile.html +++ b/website/templates/pages/profile.html @@ -27,7 +27,7 @@
    - +
    diff --git a/website/templates/pages/tickets.html b/website/templates/pages/tickets.html index f1ee58a9be..901453d071 100644 --- a/website/templates/pages/tickets.html +++ b/website/templates/pages/tickets.html @@ -5,11 +5,11 @@ {% block content %}
    -

    My Tickets

    +

    My Tickets


    From b66891a49d960a1bfcee963770f951ca41299e70 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 2 Jul 2013 12:07:58 +0530 Subject: [PATCH 10/11] [serial nos] allow rename --- stock/doctype/serial_no/serial_no.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt index 33160c785f..20f074b1ac 100644 --- a/stock/doctype/serial_no/serial_no.txt +++ b/stock/doctype/serial_no/serial_no.txt @@ -2,13 +2,13 @@ { "creation": "2013-05-16 10:59:15", "docstatus": 0, - "modified": "2013-06-20 11:23:01", + "modified": "2013-07-02 12:07:21", "modified_by": "Administrator", "owner": "Administrator" }, { "allow_attach": 1, - "allow_rename": 0, + "allow_rename": 1, "autoname": "field:serial_no", "description": "Distinct unit of an Item", "doctype": "DocType", From 2eb7ceabdadcb9f1586305c6b4555521f9de8971 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 2 Jul 2013 18:13:26 +0530 Subject: [PATCH 11/11] [forms] cleanup, fixing usability and added form dashboard --- .../production_order/production_order.txt | 17 ++++++++- .../production_planning_tool.py | 1 - selling/doctype/customer/customer.js | 35 +++++++++++++++++-- selling/doctype/customer/customer.py | 23 +++++++++++- selling/doctype/opportunity/opportunity.js | 22 +++++++++--- selling/doctype/opportunity/opportunity.txt | 8 ++++- selling/doctype/quotation/quotation.js | 10 +++++- selling/doctype/quotation/quotation.txt | 8 ++++- selling/page/selling_home/selling_home.js | 10 +++--- 9 files changed, 116 insertions(+), 18 deletions(-) diff --git a/manufacturing/doctype/production_order/production_order.txt b/manufacturing/doctype/production_order/production_order.txt index 53b7f1ceb7..38a98fefab 100644 --- a/manufacturing/doctype/production_order/production_order.txt +++ b/manufacturing/doctype/production_order/production_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:16", "docstatus": 0, - "modified": "2013-01-29 17:17:31", + "modified": "2013-07-02 11:56:54", "modified_by": "Administrator", "owner": "Administrator" }, @@ -106,6 +106,14 @@ "read_only": 0, "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "wip_warehouse", + "fieldtype": "Link", + "label": "Work-in-Progress Warehouse", + "options": "Warehouse", + "reqd": 1 + }, { "doctype": "DocField", "fieldname": "column_break1", @@ -172,6 +180,13 @@ "options": "Sales Order", "read_only": 0 }, + { + "doctype": "DocField", + "fieldname": "description", + "fieldtype": "Small Text", + "label": "Item Description", + "read_only": 1 + }, { "doctype": "DocField", "fieldname": "project_name", diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py index ed7f7bfb3f..26644ad787 100644 --- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -210,7 +210,6 @@ class DocType: "wip_warehouse" : "", "fg_warehouse" : "", "status" : "Draft", - "fiscal_year" : webnotes.conn.get_default("fiscal_year") } return bom_dict, item_dict diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js index 35a6f59a03..c0f6eab9cf 100644 --- a/selling/doctype/customer/customer.js +++ b/selling/doctype/customer/customer.js @@ -32,6 +32,7 @@ cur_frm.add_fetch('lead_name', 'company_name', 'customer_name'); cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate'); cur_frm.cscript.refresh = function(doc,dt,dn) { + cur_frm.layout.clear_dashboard(); if(sys_defaults.cust_master_name == 'Customer Name') hide_field('naming_series'); else @@ -39,7 +40,8 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { if(doc.__islocal){ hide_field(['address_html','contact_html']); - }else{ + }else{ + cur_frm.cscript.setup_dashboard(doc); unhide_field(['address_html','contact_html']); // make lists cur_frm.cscript.make_address(doc,dt,dn); @@ -53,6 +55,35 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { } } +cur_frm.cscript.setup_dashboard = function(doc) { + cur_frm.layout.dashboard.toggle(true); + var headline = $('
    \ + Loading...
    ') + .appendTo(cur_frm.layout.dashboard); + + cur_frm.layout.add_doctype_badge(wn._("Opportunities"), "Opportunity", "customer"); + cur_frm.layout.add_doctype_badge(wn._("Quotations"), "Quotation", "customer"); + cur_frm.layout.add_doctype_badge(wn._("Sales Orders"), "Sales Order", "customer"); + cur_frm.layout.add_doctype_badge(wn._("Delivery Notes"), "Delivery Note", "customer"); + cur_frm.layout.add_doctype_badge(wn._("Sales Invoices"), "Sales Invoice", "customer"); + + wn.call({ + type: "GET", + method:"selling.doctype.customer.customer.get_dashboard_info", + args: { + customer: cur_frm.doc.name + }, + callback: function(r) { + cur_frm.layout.dashboard.find(".form-headline") + .html(wn._("Total Billing This Year: ") + "" + + format_currency(r.message.total_billing, cur_frm.doc.default_currency) + + ' / ' + wn._("Unpaid") + ": " + + format_currency(r.message.total_unpaid, cur_frm.doc.default_currency) + ''); + cur_frm.layout.set_badge_count(r.message); + } + }) +} + cur_frm.cscript.make_address = function() { if(!cur_frm.address_list) { cur_frm.address_list = new wn.ui.Listing({ @@ -95,4 +126,4 @@ cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) { } -cur_frm.fields_dict.lead_name.get_query = erpnext.utils.lead_query; +cur_frm.fields_dict.lead_name.get_query = erpnext.utils.lead_query; \ No newline at end of file diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 10d2ce52fb..83c10a5452 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -173,4 +173,25 @@ class DocType(TransactionBase): #update master_name in doctype account webnotes.conn.sql("""update `tabAccount` set master_name = %s, - master_type = 'Customer' where master_name = %s""", (new,old)) \ No newline at end of file + master_type = 'Customer' where master_name = %s""", (new,old)) + +@webnotes.whitelist() +def get_dashboard_info(customer): + if not webnotes.has_permission("Customer", customer): + webnotes.msgprint("No Permission", raise_exception=True) + + out = {} + for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: + out[doctype] = webnotes.conn.get_value(doctype, + {"customer": customer, "docstatus": ["!=", 2] }, "count(*)") + + billing = webnotes.conn.sql("""select sum(grand_total), sum(outstanding_amount) + from `tabSales Invoice` + where customer=%s + and docstatus = 1 + and fiscal_year = %s""", (customer, webnotes.conn.get_default("fiscal_year"))) + + out["total_billing"] = billing[0][0] + out["total_unpaid"] = billing[0][1] + + return out \ No newline at end of file diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 3a56d4dbcb..a4c84af8c5 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -34,11 +34,21 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){ // =============================================================== cur_frm.cscript.onload = function(doc, cdt, cdn) { - if(!doc.enquiry_from) hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']); - if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'}); - if(!doc.date) doc.transaction_date = date.obj_to_str(new Date()); - if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company}); - if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year}); + if(!doc.enquiry_from && doc.customer) + doc.enquiry_from = "Customer"; + if(!doc.enquiry_from && doc.lead) + doc.enquiry_from = "Lead"; + + if(!doc.enquiry_from) + hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']); + if(!doc.status) + set_multiple(cdt,cdn,{status:'Draft'}); + if(!doc.date) + doc.transaction_date = date.obj_to_str(new Date()); + if(!doc.company && sys_defaults.company) + set_multiple(cdt,cdn,{company:sys_defaults.company}); + if(!doc.fiscal_year && sys_defaults.fiscal_year) + set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year}); if(doc.enquiry_from) { if(doc.enquiry_from == 'Customer') { @@ -61,6 +71,8 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) { cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query; } + + if(doc.customer && !doc.customer_name) cur_frm.cscript.customer(doc); } cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt index fc4d0412e8..7b86df2d33 100644 --- a/selling/doctype/opportunity/opportunity.txt +++ b/selling/doctype/opportunity/opportunity.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 18:50:30", "docstatus": 0, - "modified": "2013-06-11 16:03:41", + "modified": "2013-07-02 17:22:21", "modified_by": "Administrator", "owner": "Administrator" }, @@ -43,6 +43,12 @@ "doctype": "DocType", "name": "Opportunity" }, + { + "doctype": "DocField", + "fieldname": "from_section", + "fieldtype": "Section Break", + "label": "From" + }, { "description": "To manage multiple series please go to Setup > Manage Series", "doctype": "DocField", diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 4276193696..654779ca44 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -26,8 +26,16 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js'); wn.require('app/selling/doctype/sales_common/sales_common.js'); erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ + onload: function(doc, dt, dn) { + this._super(doc, dt, dn); + if(doc.customer && !doc.quotation_to) + doc.quotation_to = "Customer"; + else if(doc.lead && !doc.quotation_to) + doc.quotation_to = "Lead"; + + }, refresh: function(doc, dt, dn) { - this._super(); + this._super(doc, dt, dn); if(doc.docstatus == 1 && doc.status!='Order Lost') { cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']); diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index b9772c8379..433ccf3aa4 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-06-28 12:47:10", + "modified": "2013-07-02 16:49:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -42,6 +42,12 @@ "doctype": "DocType", "name": "Quotation" }, + { + "doctype": "DocField", + "fieldname": "customer_section", + "fieldtype": "Section Break", + "label": "Customer" + }, { "doctype": "DocField", "fieldname": "column_break0", diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 8eae737ddb..be0d9dd434 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -7,6 +7,11 @@ wn.module_page["Selling"] = [ title: wn._("Documents"), icon: "icon-copy", items: [ + { + label: wn._("Customer"), + description: wn._("Customer database."), + doctype:"Customer" + }, { label: wn._("Lead"), description: wn._("Database of potential customers."), @@ -33,11 +38,6 @@ wn.module_page["Selling"] = [ title: wn._("Masters"), icon: "icon-book", items: [ - { - label: wn._("Customer"), - description: wn._("Customer database."), - doctype:"Customer" - }, { label: wn._("Contact"), description: wn._("All Contacts."),