From 7e76ca350cf8810a8c7b7510eceb4b402957dbfe Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Aug 2013 13:33:42 +0530 Subject: [PATCH 1/8] [fix] default float precision = 3, changed description of float precision in global defaults [issue] webnotes/erpnext#712 --- setup/doctype/global_defaults/global_defaults.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 8f5b940fb1..fbfa8ca14d 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-02 17:53:24", "docstatus": 0, - "modified": "2013-08-02 13:45:12", + "modified": "2013-08-06 11:22:22", "modified_by": "Administrator", "owner": "Administrator" }, @@ -71,7 +71,8 @@ "read_only": 0 }, { - "description": "Precision for Float fields (quantities, discounts, percentages etc) only for display. Floats will still be calculated up to 6 decimals.", + "default": "3", + "description": "Precision for Float fields (quantities, discounts, percentages etc). Floats will be rounded up to specified decimals. Default = 3", "doctype": "DocField", "fieldname": "float_precision", "fieldtype": "Select", From 41006c545ecba1778d61e853774c5e2166bd309f Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Aug 2013 14:45:22 +0530 Subject: [PATCH 2/8] [fix] [minor] warehouse-wise stock balance filter [issue] webnotes/erpnext#724 --- .../warehouse_wise_stock_balance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py index 6ecfe7a312..4d42c229f2 100644 --- a/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py +++ b/stock/report/warehouse_wise_stock_balance/warehouse_wise_stock_balance.py @@ -29,8 +29,8 @@ def get_columns(filters): """return columns based on filters""" columns = ["Item:Link/Item:100", "Item Name::150", "Description::150", \ - "Warehouse:Link/Warehouse:100", "Opening Qty::90", \ - "In Qty::80", "Out Qty::80", "Balance Qty::90", "Company:Link/Company:100"] + "Warehouse:Link/Warehouse:100", "Opening Qty:Float:90", \ + "In Qty:Float:80", "Out Qty:Float:80", "Balance Qty:Float:90", "Company:Link/Company:100"] return columns From d5b06f78a5705c5539a7747e7607defae77b4a28 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Aug 2013 15:21:43 +0530 Subject: [PATCH 3/8] [fix] leave approver selection --- hr/doctype/employee/employee.js | 11 ++++++----- hr/doctype/leave_application/leave_application.js | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hr/doctype/employee/employee.js b/hr/doctype/employee/employee.js index 92dc7f986d..9ee7c618e6 100644 --- a/hr/doctype/employee/employee.js +++ b/hr/doctype/employee/employee.js @@ -30,11 +30,12 @@ erpnext.hr.EmployeeController = wn.ui.form.Controller.extend({ return this.frm.call({ method:"hr.utils.get_leave_approver_list", callback: function(r) { - me.frm.fields_dict.employee_leave_approvers.grid - .get_field("leave_approver").df.options = - $.map(r.message, function(profile) { - return {value: profile, label: wn.user_info(profile).fullname}; - }); + var df = wn.meta.get_docfield("Employee Leave Approver", "leave_approver", + me.frm.doc.name); + df.options = $.map(r.message, function(profile) { + return {value: profile, label: wn.user_info(profile).fullname}; + }); + me.frm.fields_dict.employee_leave_approvers.refresh(); } }); }, diff --git a/hr/doctype/leave_application/leave_application.js b/hr/doctype/leave_application/leave_application.js index 87264039c8..4c7d356c15 100755 --- a/hr/doctype/leave_application/leave_application.js +++ b/hr/doctype/leave_application/leave_application.js @@ -10,7 +10,6 @@ cur_frm.cscript.onload = function(doc, dt, dn) { cur_frm.set_value("status", "Open"); cur_frm.cscript.calculate_total_days(doc, dt, dn); } - cur_frm.set_df_property("leave_approver", "options", ""); return cur_frm.call({ method:"hr.utils.get_leave_approver_list", callback: function(r) { From 0d462745d28cf1a940350c9f271786d2119233b6 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 6 Aug 2013 15:26:52 +0530 Subject: [PATCH 4/8] Update sales_invoice.js --- accounts/doctype/sales_invoice/sales_invoice.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index a8894c5918..55460c4680 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -25,10 +25,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.frm.set_df_property("debit_to", "print_hide", 0); } } - - // if(this.frm.doc.is_pos && this.frm.doc.docstatus===0) { - // cur_frm.cscript.toggle_pos(true); - // } }, refresh: function(doc, dt, dn) { From d9f4d174d10724b66477acdaacdfd9074d360514 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 6 Aug 2013 15:28:55 +0530 Subject: [PATCH 5/8] [minor] [fix] --- accounts/doctype/sales_invoice/sales_invoice.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 55460c4680..bc36f58a48 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -25,6 +25,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.frm.set_df_property("debit_to", "print_hide", 0); } } + // if(this.frm.doc.is_pos && this.frm.doc.docstatus===0) { + // cur_frm.cscript.toggle_pos(true); + // } }, refresh: function(doc, dt, dn) { From c1541526d67fcf5aaafcac0db0312cbd08967687 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 6 Aug 2013 16:10:30 +0530 Subject: [PATCH 6/8] [fix] [minor] validate reserved warehouse --- stock/doctype/delivery_note/delivery_note.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 26b7f25e79..679d743d28 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -289,6 +289,9 @@ class DocType(SellingController): if d['reserved_qty'] < 0 : # Reduce reserved qty from reserved warehouse mentioned in so + if not d["reserved_warehouse"]: + webnotes.throw(_("Reserved Warehouse is missing in Sales Order")) + args = { "item_code": d['item_code'], "voucher_type": self.doc.doctype, From 220b597b0655957433a62cd5a57dbb32580c4452 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Aug 2013 17:01:28 +0530 Subject: [PATCH 7/8] [newsletter] show send progess [issue] webnotes/erpnext#531 --- support/doctype/newsletter/newsletter.js | 51 ++++++++++++++++++++---- support/doctype/newsletter/newsletter.py | 15 +++++-- website/helpers/blog.py | 23 ++--------- 3 files changed, 58 insertions(+), 31 deletions(-) diff --git a/support/doctype/newsletter/newsletter.js b/support/doctype/newsletter/newsletter.js index 8cbf8fc470..05311963cb 100644 --- a/support/doctype/newsletter/newsletter.js +++ b/support/doctype/newsletter/newsletter.js @@ -1,6 +1,17 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. // License: GNU General Public License v3. See license.txt +cur_frm.cscript.onload = function(doc) { + return wn.call({ + method: "support.doctype.newsletter.newsletter.get_lead_options", + type: "GET", + callback: function(r) { + set_field_options("lead_source", r.message.sources.join("\n")) + set_field_options("lead_status", r.message.statuses.join("\n")) + } + }); +} + cur_frm.cscript.refresh = function(doc) { erpnext.hide_naming_series(); if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved @@ -11,18 +22,42 @@ cur_frm.cscript.refresh = function(doc) { }); }) } + + cur_frm.cscript.setup_dashboard(); if(doc.__islocal && !doc.send_from) { cur_frm.set_value("send_from", repl("%(fullname)s <%(email)s>", wn.user_info(doc.owner))); } - - return wn.call({ - method: "support.doctype.newsletter.newsletter.get_lead_options", - type: "GET", - callback: function(r) { - set_field_options("lead_source", r.message.sources.join("\n")) - set_field_options("lead_status", r.message.statuses.join("\n")) +} + +cur_frm.cscript.setup_dashboard = function() { + cur_frm.dashboard.reset(); + if(!cur_frm.doc.__islocal && cint(cur_frm.doc.email_sent) && cur_frm.doc.__status_count) { + var stat = cur_frm.doc.__status_count; + var total = wn.utils.sum($.map(stat, function(v) { return v; })); + if(total) { + $.each(stat, function(k, v) { + stat[k] = flt(v * 100 / total, 2); + }); + + cur_frm.dashboard.add_progress("Status", [ + { + title: stat["Sent"] + "% Sent", + width: stat["Sent"], + progress_class: "progress-bar-success" + }, + { + title: stat["Sending"] + "% Sending", + width: stat["Sending"], + progress_class: "progress-bar-warning" + }, + { + title: stat["Error"] + "% Error", + width: stat["Error"], + progress_class: "progress-bar-danger" + } + ]); } - }) + } } \ No newline at end of file diff --git a/support/doctype/newsletter/newsletter.py b/support/doctype/newsletter/newsletter.py index cdfd3701e1..b201cc5586 100644 --- a/support/doctype/newsletter/newsletter.py +++ b/support/doctype/newsletter/newsletter.py @@ -11,6 +11,12 @@ from webnotes import _ class DocType(): def __init__(self, d, dl): self.doc, self.doclist = d, dl + + def onload(self): + if self.doc.email_sent: + self.doc.fields["__status_count"] = dict(webnotes.conn.sql("""select status, count(*) + from `tabBulk Email` where ref_doctype=%s and ref_docname=%s + group by status""", (self.doc.doctype, self.doc.name))) or None def test_send(self, doctype="Lead"): self.recipients = self.doc.test_email_id.split(",") @@ -74,7 +80,8 @@ class DocType(): send(recipients = self.recipients, sender = sender, subject = self.doc.subject, message = self.doc.message, - doctype = self.send_to_doctype, email_field = "email_id") + doctype = self.send_to_doctype, email_field = "email_id", + ref_doctype = self.doc.doctype, ref_docname = self.doc.name) webnotes.conn.auto_commit_on_many_writes = False @@ -91,8 +98,10 @@ class DocType(): @webnotes.whitelist() def get_lead_options(): return { - "sources": ["All"] + webnotes.conn.sql_list("""select distinct source from tabLead"""), - "statuses": ["All"]+ webnotes.conn.sql_list("""select distinct status from tabLead""") + "sources": ["All"] + filter(None, + webnotes.conn.sql_list("""select distinct source from tabLead""")), + "statuses": ["All"] + filter(None, + webnotes.conn.sql_list("""select distinct status from tabLead""")) } diff --git a/website/helpers/blog.py b/website/helpers/blog.py index 005bdb882c..f8f7a421d6 100644 --- a/website/helpers/blog.py +++ b/website/helpers/blog.py @@ -41,7 +41,7 @@ def get_blog_list(start=0, by=None, category=None): import webnotes.utils for res in result: - from webnotes.utils import global_date_format, get_fullname + from webnotes.utils import global_date_format res['published'] = global_date_format(res['creation']) if not res['content']: res['content'] = webnotes.webutils.get_html(res['page_name']) @@ -101,28 +101,11 @@ def add_comment(args=None): doctype='Comment', email_field='comment_by', subject='New Comment on Blog: ' + blog.title, - message='%(comment)s

By %(comment_by_fullname)s

' % args) + message='%(comment)s

By %(comment_by_fullname)s

' % args, + ref_doctype='Blog Post', ref_docname=blog.name) return comment_html.replace("\n", "") -@webnotes.whitelist(allow_guest=True) -def add_subscriber(name, email_id): - """add blog subscriber to lead""" - name = webnotes.conn.sql("""select name from tabLead where email_id=%s""", email) - - from webnotes.model.doc import Document - if name: - lead = Document('Lead', name[0][0]) - else: - lead = Document('Lead') - - if not lead.source: lead.source = 'Blog' - lead.unsubscribed = 0 - lead.blog_subscriber = 1 - lead.lead_name = name - lead.email_id = email - lead.save() - def get_blog_content(blog_page_name): import webnotes.webutils content = webnotes.webutils.get_html(blog_page_name) From 5e4e5d78df330f3ea426813c8785a6bfc5546119 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 6 Aug 2013 17:23:44 +0530 Subject: [PATCH 8/8] [minor] [fix] bring back onload_post_render in transaction.js - ref: a9b1c091665bc35bdc516d9556e859de3b472bd5 --- patches/august_2013/p01_hr_settings.py | 1 + public/js/transaction.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/patches/august_2013/p01_hr_settings.py b/patches/august_2013/p01_hr_settings.py index 302611bb6f..d34ef52149 100644 --- a/patches/august_2013/p01_hr_settings.py +++ b/patches/august_2013/p01_hr_settings.py @@ -1,6 +1,7 @@ # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. # License: GNU General Public License v3. See license.txt +from __future__ import unicode_literals import webnotes def execute(): diff --git a/public/js/transaction.js b/public/js/transaction.js index 7a1dc0c6c4..67204f3a83 100644 --- a/public/js/transaction.js +++ b/public/js/transaction.js @@ -32,6 +32,21 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ } }, + onload_post_render: function() { + if(this.frm.doc.__islocal && this.frm.doc.company && !this.frm.doc.customer) { + var me = this; + return this.frm.call({ + doc: this.frm.doc, + method: "onload_post_render", + freeze: true, + callback: function(r) { + // remove this call when using client side mapper + me.set_default_values(); + } + }); + } + }, + refresh: function() { this.frm.clear_custom_buttons(); erpnext.hide_naming_series(); @@ -44,6 +59,17 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ this.calculate_taxes_and_totals(); }, + set_default_values: function() { + $.each(wn.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) { + var updated = wn.model.set_default_values(doc); + if(doc.parentfield) { + refresh_field(doc.parentfield); + } else { + refresh_field(updated); + } + }); + }, + company: function() { if(this.frm.doc.company && this.frm.fields_dict.currency) { if(!this.frm.doc.currency) {