diff --git a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt index 8bc45f1303f..2f6ae86848c 100644 --- a/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt +++ b/erpnext/accounts/Print Format/Sales Invoice Classic/Sales Invoice Classic.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-05-17 17:27:49', + 'creation': '2012-05-16 14:07:31', 'docstatus': 0, - 'modified': '2012-05-17 17:53:54', + 'modified': '2012-06-04 16:02:12', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -14,7 +14,7 @@ { 'doc_type': u'Sales Invoice', 'doctype': 'Print Format', - 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t

\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', + 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t

\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', 'module': u'Accounts', 'name': '__common__', 'standard': u'Yes' diff --git a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt index c0957980a04..114650362e5 100644 --- a/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt +++ b/erpnext/accounts/Print Format/Sales Invoice Modern/Sales Invoice Modern.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-05-17 17:27:49', + 'creation': '2012-05-16 14:07:31', 'docstatus': 0, - 'modified': '2012-05-17 17:57:23', + 'modified': '2012-06-04 16:01:46', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -14,7 +14,7 @@ { 'doc_type': u'Sales Invoice', 'doctype': 'Print Format', - 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice No.
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', + 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice No.
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', 'module': u'Accounts', 'name': '__common__', 'standard': u'Yes' diff --git a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt index 01dd7654a55..77e6ef3830a 100644 --- a/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt +++ b/erpnext/accounts/Print Format/Sales Invoice Spartan/Sales Invoice Spartan.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-05-17 17:27:49', + 'creation': '2012-05-16 14:07:31', 'docstatus': 0, - 'modified': '2012-05-17 17:58:06', + 'modified': '2012-06-04 16:01:09', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -14,7 +14,7 @@ { 'doc_type': u'Sales Invoice', 'doctype': 'Print Format', - 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t

\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', + 'html': u'\n\n\n\n\n\n\n\n\n\n\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t

\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
Name
Address
Contact
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n \n \t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t
Invoice Date
Due Date
\n
\n
\n\t\n\t\n
\n
\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t
\n\t\t\t\t\tTerms, Conditions & Other Information:
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Net Total
Grand Total
Rounded Total
\n\t\t\t\t\t
In Words
\n\t\t\t\t\t\n\t\t\t\t
\n
\n', 'module': u'Accounts', 'name': '__common__', 'standard': u'Yes' diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 501ae40720f..d5300c75b5c 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -52,7 +52,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.hide_unhide_group_ledger = function(doc) { hide_field(['convert_to_group', 'convert_to_ledger']); if (cstr(doc.group_or_ledger) == 'Group') unhide_field('convert_to_ledger'); - else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('convert_to_ledger'); + else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('convert_to_group'); } // Convert group to ledger diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py index c16bb95ef16..2f84a9c7f4b 100644 --- a/erpnext/accounts/doctype/gl_control/gl_control.py +++ b/erpnext/accounts/doctype/gl_control/gl_control.py @@ -485,7 +485,8 @@ def manage_recurring_invoices(): and notify the concerned people """ rv = webnotes.conn.sql("""select name, recurring_id from `tabSales Invoice` where ifnull(convert_into_recurring_invoice, 0) = 1 - and next_date = %s and next_date <= end_date and docstatus=1 order by next_date desc""", nowdate()) + and next_date = %s and next_date <= ifnull(end_date, '2199-12-31') and docstatus=1""", nowdate()) + for d in rv: if not webnotes.conn.sql("""select name from `tabSales Invoice` where posting_date = %s and recurring_id = %s and docstatus=1""", (nowdate(), d[1])): prev_rv = get_obj('Sales Invoice', d[0], with_children=1) @@ -503,6 +504,8 @@ def create_new_invoice(prev_rv): new_rv.doc.posting_date = new_rv.doc.next_date new_rv.doc.aging_date = new_rv.doc.next_date new_rv.doc.due_date = add_days(new_rv.doc.next_date, cint(date_diff(prev_rv.doc.due_date, prev_rv.doc.posting_date))) + new_rv.doc.invoice_period_from_date = get_next_month_date(new_rv.doc.invoice_period_from_date) + new_rv.doc.invoice_period_to_date = get_next_month_date(new_rv.doc.invoice_period_to_date) new_rv.doc.owner = prev_rv.doc.owner new_rv.doc.save() @@ -512,6 +515,21 @@ def create_new_invoice(prev_rv): return new_rv +def get_next_month_date(dt): + import datetime + m = getdate(dt).month + 1 + y = getdate(dt).year + d = getdate(dt).day + if m > 12: + m, y = 1, y+1 + try: + next_month_date = datetime.date(y, m, d) + except: + import calendar + last_day = calendar.monthrange(y, m)[1] + next_month_date = datetime.date(y, m, last_day) + return next_month_date.strftime("%Y-%m-%d") + def send_notification(new_rv): """Notify concerned persons about recurring invoice generation""" @@ -528,7 +546,7 @@ def send_notification(new_rv): ''' % (com, new_rv.doc.name, new_rv.doc.customer, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \ - getdate(add_days(add_months(new_rv.doc.posting_date, -1), 1)).strftime("%d-%m-%Y"), getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"),\ + getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\ getdate(new_rv.doc.due_date).strftime("%d-%m-%Y")) @@ -570,5 +588,4 @@ def send_notification(new_rv): msg = hd + tbl + totals from webnotes.utils.email_lib import sendmail - sendmail(recipients = new_rv.doc.notification_email_address.split(", "), \ - sender=new_rv.doc.owner, subject=subject, parts=[['text/plain', msg]]) + sendmail(new_rv.doc.notification_email_address.split(", "), subject=subject, msg = msg) \ No newline at end of file diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 428e05096f8..3f333983b06 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -292,7 +292,7 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) // Expense Head // ------------- cur_frm.fields_dict['entries'].grid.get_field("expense_head").get_query = function(doc) { - return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Debit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'; + return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Debit" OR tabAccount.account_type = "Expense Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'; } cur_frm.cscript.expense_head = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index abea87ca97b..2badf4d6be0 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -390,7 +390,7 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { // Income Account in Details Table // -------------------------------- cur_frm.fields_dict.entries.grid.get_field("income_account").get_query = function(doc) { - return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.debit_or_credit="Credit" AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'; + return 'SELECT tabAccount.name FROM tabAccount WHERE (tabAccount.debit_or_credit="Credit" OR tabAccount.account_type = "Income Account") AND tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus!=2 AND tabAccount.company="'+doc.company+'" AND tabAccount.%(key)s LIKE "%s"'; } // warehouse in detail table diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 5cf557eeaf5..620d8dd5c05 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -683,6 +683,8 @@ class DocType(TransactionBase): def convert_into_recurring(self): if self.doc.convert_into_recurring_invoice: + if not self.doc.invoice_period_from_date or not self.doc.invoice_period_to_date: + msgprint("Invoice period from date and to date is mandatory for recurring invoice", raise_exception=1) self.set_next_date() if not self.doc.recurring_id: webnotes.conn.set(self.doc, 'recurring_id', make_autoname('RECINV/.#####')) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt index b1b4f4b4c9c..d2439c81132 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt @@ -5,7 +5,7 @@ { 'creation': '2012-04-13 11:56:18', 'docstatus': 0, - 'modified': '2012-05-14 14:09:43', + 'modified': '2012-06-04 14:40:59', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -1498,11 +1498,25 @@ { 'allow_on_submit': 1, 'depends_on': u'eval:doc.convert_into_recurring_invoice==1', - 'description': u'The date on which recurring invoice will be stop', + 'description': u'Start date of the invoice period', 'doctype': u'DocField', - 'fieldname': u'end_date', + 'fieldname': u'invoice_period_from_date', 'fieldtype': u'Date', - 'label': u'End Date', + 'label': u'Invoice Period From Date', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'allow_on_submit': 1, + 'depends_on': u'eval:doc.convert_into_recurring_invoice==1', + 'description': u'End date of the invoice period', + 'doctype': u'DocField', + 'fieldname': u'invoice_period_to_date', + 'fieldtype': u'Date', + 'label': u'Invoice Period To Date', 'no_copy': 1, 'permlevel': 0, 'print_hide': 1 @@ -1559,6 +1573,20 @@ 'print_hide': 1 }, + # DocField + { + 'allow_on_submit': 1, + 'depends_on': u'eval:doc.convert_into_recurring_invoice==1', + 'description': u'The date on which recurring invoice will be stop', + 'doctype': u'DocField', + 'fieldname': u'end_date', + 'fieldtype': u'Date', + 'label': u'End Date', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 + }, + # DocField { 'doctype': u'DocField', diff --git a/erpnext/buying/doctype/supplier/supplier.js b/erpnext/buying/doctype/supplier/supplier.js index 5678e98309d..2334cdd7ede 100644 --- a/erpnext/buying/doctype/supplier/supplier.js +++ b/erpnext/buying/doctype/supplier/supplier.js @@ -15,6 +15,7 @@ // along with this program. If not, see . wn.require('erpnext/setup/doctype/contact_control/contact_control.js'); +wn.require('erpnext/support/doctype/communication/communication.js'); cur_frm.cscript.onload = function(doc,dt,dn){ @@ -28,6 +29,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){ // make contact, history list body //cur_frm.cscript.make_cl_body(); cur_frm.cscript.make_hl_body(); + cur_frm.cscript.make_communication_body(); } cur_frm.cscript.refresh = function(doc,dt,dn) { @@ -44,7 +46,8 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { // make lists cur_frm.cscript.make_address(doc,dt,dn); cur_frm.cscript.make_contact(doc,dt,dn); - cur_frm.cscript.make_history(doc,dt,dn); + cur_frm.cscript.render_communication_list(doc, cdt, cdn); + cur_frm.cscript.make_history(doc,dt,dn); } } @@ -109,44 +112,88 @@ cur_frm.cscript.make_contact = function() { // Transaction History cur_frm.cscript.make_po_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Order', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'status', width: '25%', label: 'Status', type: 'Data'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tabPurchase Order`.status", + "`tabPurchase Order`.currency", + "ifnull(`tabPurchase Order`.grand_total_import, 0) as grand_total_import", + + ]); + }, + + prepare_data: function(data) { + this._super(data); + data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import); + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '20%', content: 'name'}, + {width: '30%', content: 'status', + css: {'text-align': 'right', 'color': '#777'}}, + {width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}}, + {width: '12%', content:'modified', css: {'text-align': 'right'}} + ], + }); + + cur_frm.cscript.render_list(doc, 'Purchase Order', parent, ListView); } cur_frm.cscript.make_pr_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Receipt', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'status', width: '15%', label: 'Status', type: 'Data'}, - {fieldname: 'per_billed', width: '10%', label: '% Billed', - type: 'Percentage', style: 'text-align: right'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tabPurchase Receipt`.status", + "`tabPurchase Receipt`.currency", + "ifnull(`tabPurchase Receipt`.grand_total_import, 0) as grand_total_import", + "ifnull(`tabPurchase Receipt`.per_billed, 0) as per_billed", + ]); + }, + + prepare_data: function(data) { + this._super(data); + data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import); + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '20%', content: 'name'}, + {width: '20%', content: 'status', + css: {'text-align': 'right', 'color': '#777'}}, + {width: '35%', content: 'grand_total_import', css: {'text-align': 'right'}}, + {width: '10%', content: 'per_billed', type: 'bar-graph', label: 'Billed'}, + {width: '12%', content:'modified', css: {'text-align': 'right'}} + ], + }); + + cur_frm.cscript.render_list(doc, 'Purchase Receipt', parent, ListView); } cur_frm.cscript.make_pi_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Purchase Invoice', - [ - {fieldname: 'name', width: '30%', label: 'Id', type: 'Link'}, - {fieldname: 'modified', width: '35%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tabPurchase Invoice`.currency", + "ifnull(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import", + ]); + }, + + prepare_data: function(data) { + this._super(data); + data.grand_total_import = data.currency + " " + fmt_money(data.grand_total_import); + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '30%', content: 'name'}, + {width: '55%', content: 'grand_total_import', css: {'text-align': 'right'}}, + {width: '12%', content:'modified', css: {'text-align': 'right'}} + ], + }); + + cur_frm.cscript.render_list(doc, 'Purchase Invoice', parent, ListView); } \ No newline at end of file diff --git a/erpnext/buying/doctype/supplier/supplier.txt b/erpnext/buying/doctype/supplier/supplier.txt index 10d55916627..938633ac671 100644 --- a/erpnext/buying/doctype/supplier/supplier.txt +++ b/erpnext/buying/doctype/supplier/supplier.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-03-27 14:35:52', + 'creation': '2012-05-15 12:14:41', 'docstatus': 0, - 'modified': '2012-03-27 14:35:52', + 'modified': '2012-05-31 13:18:29', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -25,7 +25,7 @@ 'show_in_menu': 0, 'subject': u' ', 'tag_fields': u'supplier_type', - 'version': 87 + 'version': 1 }, # These values are common for all DocField @@ -53,6 +53,30 @@ 'name': u'Supplier' }, + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 0, + 'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Purchase Manager', + 'submit': 0, + 'write': 0 + }, + + # DocPerm + { + 'amend': 0, + 'cancel': 0, + 'create': 0, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Purchase Manager', + 'submit': 0, + 'write': 0 + }, + # DocPerm { 'doctype': u'DocPerm', @@ -72,30 +96,6 @@ 'write': 1 }, - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'Purchase Manager', - 'submit': 0, - 'write': 0 - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 0, - 'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'Purchase Manager', - 'submit': 0, - 'write': 0 - }, - # DocField { 'colour': u'White:FFF', @@ -218,6 +218,24 @@ 'permlevel': 1 }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'communication_history', + 'fieldtype': u'Section Break', + 'label': u'Communication History', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'communication_html', + 'fieldtype': u'HTML', + 'label': u'Communication HTML', + 'permlevel': 0 + }, + # DocField { 'doctype': u'DocField', diff --git a/erpnext/patches/may_2012/remove_communication_log.py b/erpnext/patches/may_2012/remove_communication_log.py new file mode 100644 index 00000000000..6ca05a712d1 --- /dev/null +++ b/erpnext/patches/may_2012/remove_communication_log.py @@ -0,0 +1,108 @@ +def execute(): + import webnotes + import webnotes.model.sync + webnotes.model.sync.sync('support', 'communication') + webnotes.conn.commit() + webnotes.conn.begin() + + # change doctype property setter and custom fields, and save them + move_customizations() + + try: + remove_communication_log() + except Exception, e: + if e.args[0] != 1146: + raise e + +def move_customizations(): + import webnotes.model.doc + import webnotes.model.doctype + + res = webnotes.conn.sql("""\ + delete from `tabProperty Setter` + where property='previous_field' + and doc_type = 'Communication Log'""") + + res = webnotes.conn.sql("""\ + select name from `tabCustom Field` + where dt='Communication Log'""") + for r in res: + d = webnotes.model.doc.Document('Custom Field', r[0]) + d.dt = 'Communication' + d.save() + from webnotes.model.db_schema import updatedb + updatedb('Communication') + + res = webnotes.conn.sql("""\ + select field_name from `tabProperty Setter` + where doc_type='Communication Log' and field_name is not null""") + + doclist = webnotes.model.doctype.get('Communication', 0) + field_list = [d.fieldname for d in doclist if d.doctype=='DocField'] + for r in res: + if r[0] in field_list: + webnotes.conn.sql("""\ + update `tabProperty Setter` + set doc_type = 'Communication' + where field_name=%s and doc_type='Communication Log'""", r[0]) + + webnotes.conn.sql("""\ + delete from `tabProperty Setter` + where doc_type='Communication Log'""") + + from webnotes.utils.cache import CacheItem + CacheItem('Communication').clear() + +def remove_communication_log(): + import webnotes + import webnotes.model + import webnotes.model.doc + import webnotes.model.doctype + + webnotes.conn.auto_commit_on_many_writes = True + + # get all communication log records + comm_log_list = webnotes.conn.sql("select * from `tabCommunication Log`", + as_dict=1) + + field_list = [d.fieldname for d in \ + webnotes.model.doctype.get('Communication', 0) \ + if d.doctype=='DocField'] + + # copy it to communication + for comm_log in comm_log_list: + d = webnotes.model.doc.Document('Communication') + + for key in comm_log.keys(): + if key not in webnotes.model.default_fields: + d.fields[key] = comm_log[key] + + parenttype = (comm_log.get('parenttype') or '').lower() + if parenttype in field_list: + d.fields[parenttype] = comm_log.get('parent') + + d.naming_series = 'COMM-' + d.subject = 'Follow Up' + d.content = comm_log.get('notes') or '' + d.medium = comm_log.get('follow_up_type') or '' + d.sales_person = comm_log.get('follow_up_by') + d.communication_date = comm_log.get('date') + d.category = 'Miscellaneous' + d.action = 'No Action' + d.save(ignore_fields=1) + + # delete records with parent type "Customer", "Lead", "Supplier" + webnotes.conn.sql("""\ + delete from `tabCommunication Log` + where parenttype in ('Customer', 'Lead', 'Supplier', + 'Opportunity', 'Quotation')""") + + # if all records deleted, drop table communication log + # and delete doctype communication log + # if for some reason, records remain, dont drop table and dont delete doctype + count = webnotes.conn.sql("select count(*) from `tabCommunication Log`")[0][0] + if not count: + webnotes.model.delete_doc('DocType', 'Communication Log') + webnotes.conn.commit() + webnotes.conn.sql("drop table `tabCommunication Log`") + webnotes.conn.begin() \ No newline at end of file diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 32a1e77d72e..aba4ce539e1 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -407,4 +407,9 @@ patch_list = [ 'patch_file': 'remove_euro_currency', 'description': 'Remove EURO currency and replace with EUR' }, + { + 'patch_module': 'patches.may_2012', + 'patch_file': 'remove_communication_log', + 'description': 'Remove Communication Log and replace it with Communication' + }, ] \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js index a695922bc3d..f49a1abca79 100644 --- a/erpnext/selling/doctype/customer/customer.js +++ b/erpnext/selling/doctype/customer/customer.js @@ -15,6 +15,7 @@ // along with this program. If not, see . wn.require('erpnext/setup/doctype/contact_control/contact_control.js'); +wn.require('erpnext/support/doctype/communication/communication.js'); /* ********************************* onload ********************************************* */ @@ -31,6 +32,8 @@ cur_frm.cscript.onload = function(doc,dt,dn){ //cur_frm.cscript.make_sl_body(); cur_frm.cscript.load_defaults(doc, dt, dn); + + cur_frm.cscript.make_communication_body(); } cur_frm.cscript.load_defaults = function(doc, dt, dn) { @@ -62,6 +65,7 @@ cur_frm.cscript.refresh = function(doc,dt,dn) { cur_frm.cscript.make_address(doc,dt,dn); cur_frm.cscript.make_contact(doc,dt,dn); cur_frm.cscript.make_history(doc,dt,dn); + cur_frm.cscript.render_communication_list(doc, cdt, cdn); //cur_frm.cscript.make_shipping_address(doc,dt,dn); } } @@ -143,62 +147,84 @@ cur_frm.fields_dict['lead_name'].get_query = function(doc,dt,dn){ // Transaction History -// functions called by these functions are defined in contact_control.js +// functions called by these functions are defined in communication.js cur_frm.cscript.make_qtn_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Quotation', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'status', width: '25%', label: 'Status', type: 'Data'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + cur_frm.cscript.get_common_list_view(parent, doc, 'Quotation'); } cur_frm.cscript.make_so_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Sales Order', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'status', width: '25%', label: 'Status', type: 'Data'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + cur_frm.cscript.get_common_list_view(parent, doc, 'Sales Order'); } cur_frm.cscript.make_dn_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Delivery Note', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'status', width: '25%', label: 'Status', type: 'Data'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + cur_frm.cscript.get_common_list_view(parent, doc, 'Delivery Note'); +} + +cur_frm.cscript.get_common_list_view = function(parent, doc, doctype) { + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tab" + doctype + "`.status", + "`tab" + doctype + "`.currency", + "ifnull(`tab" + doctype + "`.grand_total_export, 0) as grand_total_export", + + ]); + }, + + prepare_data: function(data) { + this._super(data); + data.grand_total_export = data.currency + " " + fmt_money(data.grand_total_export) + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '25%', content: 'name'}, + {width: '25%', content: 'status'}, + {width: '35%', content: 'grand_total_export', css: {'text-align': 'right'}}, + {width: '12%', content:'modified', css: {'text-align': 'right'}} + ], + }); + + cur_frm.cscript.render_list(doc, doctype, parent, ListView); } cur_frm.cscript.make_si_list = function(parent, doc) { - cur_frm.cscript.render_transaction_history(parent, doc, 'Sales Invoice', - [ - {fieldname: 'name', width: '28%', label: 'Id', type: 'Link'}, - {fieldname: 'outstanding_amount', width: '25%', - label: 'Outstanding Amount', - type: 'Currency', style: 'text-align: right; color: #777'}, - {fieldname: 'modified', width: '12%', label: 'Last Modified On', - type: 'Date', style: 'text-align: right; color: #777'}, - {fieldname: 'currency', width: '0%', label: 'Currency', - style: 'display: hidden'}, - {fieldname: 'grand_total', width: '35%', label: 'Grand Total', - type: 'Currency', style: 'text-align: right'}, - ]); + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "ifnull(`tabSales Invoice`.outstanding_amount, 0) as outstanding_amount", + "`tabSales Invoice`.currency", + "ifnull(`tabSales Invoice`.conversion_rate, 0) as conversion_rate", + "ifnull(`tabSales Invoice`.grand_total_export, 0) as grand_total_export", + + ]); + }, + + prepare_data: function(data) { + this._super(data); + if (data.outstanding_amount) { + data.outstanding_amount = data.currency + " " + + fmt_money(flt(data.outstanding_amount)/flt(data.conversion_rate)) + + " [outstanding]"; + + } else { + data.outstanding_amount = ''; + } + data.grand_total_export = data.currency + " " + fmt_money(data.grand_total_export); + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '25%', content: 'name'}, + {width: '25%', content: 'outstanding_amount', + css: {'text-align': 'right', 'color': '#777'}}, + {width: '35%', content: 'grand_total_export', css: {'text-align': 'right'}}, + {width: '12%', content:'modified', css: {'text-align': 'right'}} + ], + }); + + cur_frm.cscript.render_list(doc, 'Sales Invoice', parent, ListView); } \ No newline at end of file diff --git a/erpnext/selling/doctype/customer/customer.txt b/erpnext/selling/doctype/customer/customer.txt index 29144928097..e8f03d02d10 100644 --- a/erpnext/selling/doctype/customer/customer.txt +++ b/erpnext/selling/doctype/customer/customer.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-13 11:56:26', + 'creation': '2012-05-15 12:14:51', 'docstatus': 0, - 'modified': '2012-04-19 17:12:24', + 'modified': '2012-05-31 11:41:06', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -303,6 +303,24 @@ 'permlevel': 1 }, + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'communication_history', + 'fieldtype': u'Section Break', + 'label': u'Communication History', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'communication_html', + 'fieldtype': u'HTML', + 'label': u'Communication HTML', + 'permlevel': 0 + }, + # DocField { 'colour': u'White:FFF', diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 4aa460d695b..5d434495c01 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -8,19 +8,20 @@ // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program. If not, see . +// along with this program. If not, see . // Module CRM wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/support/doctype/communication/communication.js'); cur_frm.cscript.onload = function(doc, cdt, cdn) { - if(user =='Guest'){ - hide_field(['status', 'naming_series', 'order_lost_reason', + if(user =='Guest'){ + hide_field(['status', 'naming_series', 'order_lost_reason', 'customer', 'rating', 'fax', 'website', 'territory', 'address_line1', 'address_line2', 'city', 'state', 'country', 'pincode', 'address', 'lead_owner', 'market_segment', @@ -29,29 +30,33 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { 'contact_date_ref', 'to_discuss', 'more_info', 'follow_up', 'communication_history', 'cc_to', 'subject', 'message', 'lead_attachment_detail', 'Create Customer', 'Create Opportunity', 'transaction_date', 'type', 'source']); - doc.source = 'Website'; - } - if(!doc.status) set_multiple(dt,dn,{status:'Open'}); + doc.source = 'Website'; + } + if(!doc.status) set_multiple(dt,dn,{status:'Open'}); - if (!doc.date){ - doc.date = date.obj_to_str(new Date()); - } - // set naming series - if(user=='Guest') doc.naming_series = 'WebLead'; - - cur_frm.add_fetch('customer', 'customer_name', 'company_name'); + if (!doc.date){ + doc.date = date.obj_to_str(new Date()); + } + // set naming series + if(user=='Guest') doc.naming_series = 'WebLead'; + + cur_frm.add_fetch('customer', 'customer_name', 'company_name'); + + cur_frm.cscript.make_communication_body(); } cur_frm.cscript.refresh = function(doc, cdt, cdn) { - // custom buttons - //--------------- - cur_frm.clear_custom_buttons() - if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) { + // custom buttons + //--------------- + cur_frm.clear_custom_buttons() + if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) { if (doc.source != 'Existing Customer') cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']); - cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']); - cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); - } - erpnext.hide_naming_series(); + cur_frm.add_custom_button('Create Opportunity', cur_frm.cscript['Create Opportunity']); + cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); + } + erpnext.hide_naming_series(); + + if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); } @@ -59,82 +64,81 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { // =========================================================== // ************ Status ****************** cur_frm.cscript.status = function(doc, cdt, cdn){ - cur_frm.cscript.refresh(doc, cdt, cdn); + cur_frm.cscript.refresh(doc, cdt, cdn); } - //Trigger in Item Table //=================================== cur_frm.cscript.item_code=function(doc,cdt,cdn){ - var d = locals[cdt][cdn]; - if (d.item_code) { get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);} + var d = locals[cdt][cdn]; + if (d.item_code) { get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);} } // Create New Customer // =============================================================== cur_frm.cscript['Create Customer'] = function(){ - var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, - function(r,rt){ - if(r.message == 'Converted'){ - msgprint("This lead is already converted to customer"); - } - else{ - n = createLocal("Customer"); - $c('dt_map', args={ - 'docs':compress_doclist([locals["Customer"][n]]), - 'from_doctype':'Lead', - 'to_doctype':'Customer', - 'from_docname':doc.name, - 'from_to_list':"[['Lead', 'Customer']]" - }, - function(r,rt) { - loaddoc("Customer", n); - } - ); - } - } - ); + var doc = cur_frm.doc; + $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, + function(r,rt){ + if(r.message == 'Converted'){ + msgprint("This lead is already converted to customer"); + } + else{ + n = createLocal("Customer"); + $c('dt_map', args={ + 'docs':compress_doclist([locals["Customer"][n]]), + 'from_doctype':'Lead', + 'to_doctype':'Customer', + 'from_docname':doc.name, + 'from_to_list':"[['Lead', 'Customer']]" + }, + function(r,rt) { + loaddoc("Customer", n); + } + ); + } + } + ); } // send email // =============================================================== cur_frm.cscript.send_email = function(doc,cdt,cdn){ - if(doc.__islocal != 1){ - $c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){}); - }else{ - msgprint("Please save lead first before sending email") - } + if(doc.__islocal != 1){ + $c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){}); + }else{ + msgprint("Please save lead first before sending email") + } } // Create New Opportunity // =============================================================== cur_frm.cscript['Create Opportunity'] = function(){ - var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, - function(r,rt){ - if(r.message == 'Converted'){ - msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer"); - } - else{ - n = createLocal("Opportunity"); - $c('dt_map', args={ - 'docs':compress_doclist([locals["Opportunity"][n]]), - 'from_doctype':'Lead', - 'to_doctype':'Opportunity', - 'from_docname':doc.name, - 'from_to_list':"[['Lead', 'Opportunity']]" - } - , function(r,rt) { - loaddoc("Opportunity", n); - } - ); - } - } - ); + var doc = cur_frm.doc; + $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])}, + function(r,rt){ + if(r.message == 'Converted'){ + msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer"); + } + else{ + n = createLocal("Opportunity"); + $c('dt_map', args={ + 'docs':compress_doclist([locals["Opportunity"][n]]), + 'from_doctype':'Lead', + 'to_doctype':'Opportunity', + 'from_docname':doc.name, + 'from_to_list':"[['Lead', 'Opportunity']]" + } + , function(r,rt) { + loaddoc("Opportunity", n); + } + ); + } + } + ); } //get query select Territory cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) { - return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; + return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; } diff --git a/erpnext/selling/doctype/lead/lead.txt b/erpnext/selling/doctype/lead/lead.txt index e7148587eab..b6aa8397d7d 100644 --- a/erpnext/selling/doctype/lead/lead.txt +++ b/erpnext/selling/doctype/lead/lead.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-02 16:02:08', + 'creation': '2012-05-15 12:14:52', 'docstatus': 0, - 'modified': '2012-04-30 15:20:50', + 'modified': '2012-05-30 12:43:03', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -314,13 +314,13 @@ # DocField { 'allow_on_submit': 0, + 'colour': u'White:FFF', 'doctype': u'DocField', - 'fieldname': u'follow_up', - 'fieldtype': u'Table', - 'label': u'Communication Log', + 'fieldname': u'communication_html', + 'fieldtype': u'HTML', + 'label': u'Communication HTML', 'oldfieldname': u'follow_up', 'oldfieldtype': u'Table', - 'options': u'Communication Log', 'permlevel': 0 }, diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index ba4b538139b..c672aa11f3a 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -15,6 +15,7 @@ // along with this program. If not, see . wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); +wn.require('erpnext/support/doctype/communication/communication.js'); cur_frm.cscript.refresh = function(doc, cdt, cdn){ erpnext.hide_naming_series(); @@ -25,7 +26,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){ cur_frm.add_custom_button('Opportunity Lost', cur_frm.cscript['Declare Opportunity Lost']); cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); } - + if(!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); } // ONLOAD @@ -49,6 +50,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { // setup fetch cur_frm.cscript.set_fetch(); + cur_frm.cscript.make_communication_body(); } cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { diff --git a/erpnext/selling/doctype/opportunity/opportunity.txt b/erpnext/selling/doctype/opportunity/opportunity.txt index ddf3b96be6a..0913b625add 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.txt +++ b/erpnext/selling/doctype/opportunity/opportunity.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-02 16:02:08', + 'creation': '2012-05-15 12:14:52', 'docstatus': 0, - 'modified': '2012-04-30 15:34:34', + 'modified': '2012-05-31 12:42:38', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -282,12 +282,11 @@ 'allow_on_submit': 1, 'colour': u'White:FFF', 'doctype': u'DocField', - 'fieldname': u'follow_up', - 'fieldtype': u'Table', - 'label': u'Communication Log', + 'fieldname': u'communication_html', + 'fieldtype': u'HTML', + 'label': u'Communication HTML', 'oldfieldname': u'follow_up', 'oldfieldtype': u'Table', - 'options': u'Communication Log', 'permlevel': 0 }, diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js index 280726063f8..e89ad15de2b 100644 --- a/erpnext/selling/doctype/quotation/quotation.js +++ b/erpnext/selling/doctype/quotation/quotation.js @@ -25,6 +25,7 @@ wn.require('erpnext/selling/doctype/sales_common/sales_common.js'); wn.require('erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js'); wn.require('erpnext/utilities/doctype/sms_control/sms_control.js'); wn.require('erpnext/setup/doctype/notification_control/notification_control.js'); +wn.require('erpnext/support/doctype/communication/communication.js'); // ONLOAD // =================================================================================== @@ -39,7 +40,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { 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.quotation_to) { if(doc.quotation_to == 'Customer') { hide_field(['lead', 'lead_name']); @@ -48,9 +49,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']); } } + cur_frm.cscript.make_communication_body(); + } -cur_frm.cscript.onload_post_render = function(doc, dt, dn) { +cur_frm.cscript.onload_post_render = function(doc, dt, dn) { var callback = function(doc, dt, dn) { // defined in sales_common.js cur_frm.cscript.update_item_details(doc, dt, dn); @@ -95,6 +98,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { if(doc.customer || doc.lead) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true); else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false); + + if (!doc.__islocal) cur_frm.cscript.render_communication_list(doc, cdt, cdn); } diff --git a/erpnext/selling/doctype/quotation/quotation.txt b/erpnext/selling/doctype/quotation/quotation.txt index aa2fd659907..e5f8e752dd7 100644 --- a/erpnext/selling/doctype/quotation/quotation.txt +++ b/erpnext/selling/doctype/quotation/quotation.txt @@ -3,9 +3,9 @@ # These values are common in all dictionaries { - 'creation': '2012-04-30 18:40:10', + 'creation': '2012-05-21 11:43:59', 'docstatus': 0, - 'modified': '2012-04-30 20:30:45', + 'modified': '2012-05-31 11:43:18', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -51,8 +51,7 @@ 'name': '__common__', 'parent': u'Quotation', 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'read': 1 + 'parenttype': u'DocType' }, # DocType, Quotation @@ -61,6 +60,13 @@ 'name': u'Quotation' }, + # DocPerm + { + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'user print' + }, + # DocPerm { 'amend': 0, @@ -68,6 +74,7 @@ 'create': 0, 'doctype': u'DocPerm', 'permlevel': 1, + 'read': 1, 'role': u'Sales Manager', 'submit': 0, 'write': 0 @@ -80,6 +87,7 @@ 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, + 'read': 1, 'role': u'Sales Manager', 'submit': 1, 'write': 1 @@ -92,6 +100,7 @@ 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, + 'read': 1, 'role': u'Sales User', 'submit': 1, 'write': 1 @@ -104,6 +113,7 @@ 'create': 0, 'doctype': u'DocPerm', 'permlevel': 1, + 'read': 1, 'role': u'Sales User', 'submit': 0, 'write': 0 @@ -114,6 +124,7 @@ 'doctype': u'DocPerm', 'match': u'customer_name', 'permlevel': 0, + 'read': 1, 'role': u'Customer' }, @@ -124,6 +135,7 @@ 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, + 'read': 1, 'role': u'Maintenance Manager', 'submit': 1, 'write': 1 @@ -133,6 +145,7 @@ { 'doctype': u'DocPerm', 'permlevel': 1, + 'read': 1, 'role': u'Maintenance Manager' }, @@ -143,6 +156,7 @@ 'create': 1, 'doctype': u'DocPerm', 'permlevel': 0, + 'read': 1, 'role': u'Maintenance User', 'submit': 1, 'write': 1 @@ -152,6 +166,7 @@ { 'doctype': u'DocPerm', 'permlevel': 1, + 'read': 1, 'role': u'Maintenance User' }, @@ -1240,12 +1255,11 @@ 'allow_on_submit': 1, 'colour': u'White:FFF', 'doctype': u'DocField', - 'fieldname': u'follow_up', - 'fieldtype': u'Table', - 'label': u'Communication Log', + 'fieldname': u'communication_html', + 'fieldtype': u'HTML', + 'label': u'Communication HTML', 'oldfieldname': u'follow_up', 'oldfieldtype': u'Table', - 'options': u'Communication Log', 'permlevel': 0, 'print_hide': 1, 'width': u'40px' diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js index 97e49f5acaa..1d172444437 100755 --- a/erpnext/setup/doctype/contact_control/contact_control.js +++ b/erpnext/setup/doctype/contact_control/contact_control.js @@ -7,9 +7,11 @@ cur_frm.cscript.make_hl_body = function(){ cur_frm.fields_dict['history_html'].wrapper.innerHTML = ''; cur_frm.history_html = $a(cur_frm.fields_dict['history_html'].wrapper,'div'); + $(cur_frm.history_html).css({ + 'min-height': '320px', + }); } - // make history // ------------- cur_frm.cscript.make_history = function(doc,dt,dn){ @@ -50,42 +52,6 @@ cur_frm.cscript.make_history_list = function(parent,doc){ } } -// run list -// --------- -cur_frm.cscript.run_list = function(lst,parent,q,q_max,doc,dn,nm){ - - parent.innerHTML = ''; - $dh(parent); - - lst.doc = doc; - lst.dn = dn; - lst.nm = nm; - lst.page_len = 10; - - lst.get_query = function(){ - this.query = q; - this.query_max = q_max; - } - - lst.make(parent); - lst.run(); - - lst.onrun = function(){ - $ds(parent); - if(!this.has_data()){ - parent.innerHTML = ''; - var dv = $a(parent,'div','help_box'); - $a(dv,'span').innerHTML = "No " + this.dn + " found. "; - - var lbl = 'Create the first ' + this.dn + ' for ' + this.doc.name; - var sp = $a(dv,'span'); - sp.nm = this.nm; - $(sp).html(lbl).addClass('link_type').click(function(){ newdoc(this.nm); }); - } - } -} - - // get sates on country trigger // ----------------------------- cur_frm.cscript.get_states=function(doc,dt,dn){ @@ -111,80 +77,3 @@ if(cur_frm.fields_dict['territory']){ return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; } } - - -// Transaction History related functions -cur_frm.cscript.render_transaction_history = function(parent, doc, doctype, args) { - $(parent).css({ 'padding-top': '10px' }); - cur_frm.transaction_list = new wn.ui.Listing({ - parent: parent, - page_length: 10, - get_query: function() { - return cur_frm.cscript.get_query_transaction_history({ - parent: doc.doctype.toLowerCase(), - parent_name: doc.name, - doctype: doctype, - fields: (function() { - var fields = []; - for(var i in args) { - fields.push(args[i].fieldname); - } - return fields.join(", "); - })(), - }); - }, - as_dict: 1, - no_result_message: repl('No %(doctype)s created for this %(parent)s', - { doctype: doctype, parent: doc.doctype }), - render_row: function(wrapper, data) { - render_html = cur_frm.cscript.render_transaction_history_row(data, args, doctype); - $(wrapper).html(render_html); - }, - }); - cur_frm.transaction_list.run(); -} - -cur_frm.cscript.render_transaction_history_row = function(data, args, doctype) { - var content = []; - var currency = data.currency; - for (var a in args) { - for (var d in data) { - if (args[a].fieldname === d && args[a].fieldname !== 'currency') { - if (args[a].type === 'Link') { - data[d] = repl('\ - %(name)s', { doctype: doctype, name: data[d]}); - } else if (args[a].type === 'Currency') { - data[d] = currency + " " + fmt_money(data[d]); - } else if (args[a].type === 'Percentage') { - data[d] = flt(data[d]) + '%'; - } else if (args[a].type === 'Date') { - data[d] = wn.datetime.only_date(data[d]); - } - if (args[a].style == undefined) { - args[a].style = ''; - } - data[d] = repl('\ - \ - %(content)s', - { - content: data[d], - width: args[a].width, - title: args[a].label, - style: args[a].style, - }); - content.push(data[d]); - break; - } - } - } - content = content.join("\n"); - return '' + content + '
'; -} - -cur_frm.cscript.get_query_transaction_history = function(args) { - var query = repl("\ - select %(fields)s from `tab%(doctype)s` \ - where %(parent)s = '%(parent_name)s' \ - order by modified desc", args); - return query; -} diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 4a5d5d09df5..161ce4e1b4c 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -52,7 +52,7 @@ class DocType: def validate(self): if self.doc.lft and self.doc.rgt: - res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_item_group,self.doc.item_group_name)) + res = sql("select name from `tabItem Group` where is_group = 'Yes' and docstatus!= 2 and name ='%s' and name !='%s'"%(self.doc.parent_item_group,self.doc.item_group_name)) if not res: msgprint("Please enter proper parent item group.") raise Exception diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py index 5f71cf6535b..606efa8ef93 100644 --- a/erpnext/setup/doctype/territory/territory.py +++ b/erpnext/setup/doctype/territory/territory.py @@ -61,7 +61,7 @@ class DocType: def validate(self): if self.doc.lft and self.doc.rgt: - res = sql("select name from `tabTerritory` where is_group = 'Yes' and docstatus!= 2 and (rgt > %s or lft < %s) and name ='%s' and name !='%s'"%(self.doc.rgt,self.doc.lft,self.doc.parent_territory,self.doc.territory_name)) + res = sql("select name from `tabTerritory` where is_group = 'Yes' and docstatus!= 2 and name ='%s' and name !='%s'"%(self.doc.parent_territory,self.doc.territory_name)) if not res: msgprint("Please enter proper parent territory.") raise Exception diff --git a/erpnext/support/doctype/communication/__init__.py b/erpnext/support/doctype/communication/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/erpnext/support/doctype/communication/communication.js b/erpnext/support/doctype/communication/communication.js new file mode 100644 index 00000000000..afa853ddbf0 --- /dev/null +++ b/erpnext/support/doctype/communication/communication.js @@ -0,0 +1,92 @@ +cur_frm.cscript.refresh = function(doc, dt, dn) { + if(!doc.__islocal) { + var field_list = ['lead', 'customer', 'supplier', 'contact', 'opportunity', + 'quotation', 'support_ticket']; + var hide_list = []; + $.each(field_list, function(i, v) { + if(!doc[v]) hide_list.push(v); + }); + + if(hide_list.length < field_list.length) hide_field(hide_list); + } +} + + +cur_frm.cscript.make_communication_body = function() { + var communication_wrapper = cur_frm.fields_dict.communication_html.wrapper; + communication_wrapper.innerHTML = ''; + cur_frm.communication_html = $a(communication_wrapper, 'div'); + $(cur_frm.communication_html).css({ + 'min-height': '275px', + }); +} + +cur_frm.cscript.render_communication_list = function(doc, dt, dn) { + var ListView = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tabCommunication`.communication_date", + "`tabCommunication`.category", + "`tabCommunication`.subject", + "`tabCommunication`.content" + ]); + this.order_by = "`tabCommunication`.communication_date desc"; + }, + + prepare_data: function(data) { + this._super(data); + data.creation = wn.datetime.str_to_user(data.communication_date); + + data.content = cstr(data.subject) + " | " + cstr(data.content); + + if(data.content && data.content.length > 50) { + data.content = '' + + data.description.substr(0,50) + '...'; + } + + }, + + columns: [ + {width: '3%', content: 'docstatus'}, + {width: '15%', content: 'name'}, + {width: '15%', content: 'category'}, + {width: '55%', content: 'content'}, + {width: '12%', content:'communication_date', + css: {'text-align': 'right', 'color':'#777'}} + ], + + }); + + cur_frm.cscript.render_list(doc, 'Communication', cur_frm.communication_html, + ListView, function(doctype) { + var new_doc = LocalDB.create(doctype); + new_doc = locals[doctype][new_doc]; + new_doc[doc.doctype.toLowerCase()] = doc.name; + loaddoc(new_doc.doctype, new_doc.name); + }); +} + + +// Render List +cur_frm.cscript.render_list = function(doc, doctype, wrapper, ListView, make_new_doc) { + wn.model.with_doctype(doctype, function(r) { + if(r && r['403']) { + return; + } + var RecordListView = wn.views.RecordListView.extend({ + default_docstatus: ['0', '1', '2'], + default_filters: [ + [doctype, doc.doctype.toLowerCase(), '=', doc.name], + ], + }); + + if (make_new_doc) { + RecordListView = RecordListView.extend({ + make_new_doc: make_new_doc, + }); + } + + var record_list_view = new RecordListView(doctype, wrapper, ListView); + }); +} \ No newline at end of file diff --git a/erpnext/support/doctype/communication/communication.py b/erpnext/support/doctype/communication/communication.py new file mode 100644 index 00000000000..c99422da9b1 --- /dev/null +++ b/erpnext/support/doctype/communication/communication.py @@ -0,0 +1,26 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import webnotes +from webnotes.model.doc import make_autoname + +class DocType(): + def __init__(self, doc, doclist=[]): + self.doc = doc + self.doclist = doclist + + def autoname(self): + self.doc.name = make_autoname(self.doc.naming_series+'.#####') diff --git a/erpnext/support/doctype/communication/communication.txt b/erpnext/support/doctype/communication/communication.txt new file mode 100644 index 00000000000..d6efd104af4 --- /dev/null +++ b/erpnext/support/doctype/communication/communication.txt @@ -0,0 +1,377 @@ +# DocType, Communication +[ + + # These values are common in all dictionaries + { + 'creation': '2012-05-29 16:56:41', + 'docstatus': 0, + 'modified': '2012-05-31 16:14:39', + 'modified_by': u'Administrator', + 'owner': u'Administrator' + }, + + # These values are common for all DocType + { + 'allow_attach': 1, + 'description': u'Keep a track of all communications', + 'doctype': 'DocType', + 'module': u'Support', + 'name': '__common__', + 'version': 1 + }, + + # These values are common for all DocField + { + 'doctype': u'DocField', + 'name': '__common__', + 'parent': u'Communication', + 'parentfield': u'fields', + 'parenttype': u'DocType' + }, + + # These values are common for all DocPerm + { + 'doctype': u'DocPerm', + 'name': '__common__', + 'parent': u'Communication', + 'parentfield': u'permissions', + 'parenttype': u'DocType', + 'read': 1, + 'write': 1 + }, + + # DocType, Communication + { + 'doctype': 'DocType', + 'name': u'Communication' + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Support Team' + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales Manager' + }, + + # DocPerm + { + 'create': 1, + 'doctype': u'DocPerm', + 'permlevel': 0, + 'role': u'Sales User' + }, + + # DocPerm + { + 'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Sales Manager' + }, + + # DocPerm + { + 'doctype': u'DocPerm', + 'permlevel': 1, + 'role': u'Support Manager' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'basic_info', + 'fieldtype': u'Section Break', + 'label': u'Basic Info', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'default': u'COMM-', + 'doctype': u'DocField', + 'fieldname': u'naming_series', + 'fieldtype': u'Select', + 'hidden': 1, + 'label': u'Naming Series', + 'options': u'COMM-', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'category', + 'fieldtype': u'Select', + 'label': u'Category', + 'options': u'\nSales\nComplaint\nHelp\nSuggestion\nMiscellaneous', + 'permlevel': 0, + 'reqd': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'action', + 'fieldtype': u'Select', + 'label': u'Action', + 'options': u'\nCreated Opportunity\nSent Quotation\nCreated Support Ticket\nCreated Customer Issue\nNo Action', + 'permlevel': 0, + 'reqd': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break2', + 'fieldtype': u'Column Break', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'subject', + 'fieldtype': u'Small Text', + 'label': u'Subject', + 'permlevel': 0, + 'reqd': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'section_break1', + 'fieldtype': u'Section Break', + 'options': u'simple', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'content', + 'fieldtype': u'Text Editor', + 'label': u'Content', + 'permlevel': 0, + 'reqd': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'additional_info', + 'fieldtype': u'Section Break', + 'label': u'Additional Info', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'doctype': u'DocField', + 'fieldname': u'column_break3', + 'fieldtype': u'Column Break', + 'label': u'Communication With / Related To', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'lead', + 'fieldtype': u'Link', + 'hidden': 0, + 'label': u'Lead', + 'options': u'Lead', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'contact', + 'fieldtype': u'Link', + 'label': u'Contact', + 'options': u'Contact', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'customer', + 'fieldtype': u'Link', + 'label': u'Customer', + 'options': u'Customer', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'supplier', + 'fieldtype': u'Link', + 'label': u'Supplier', + 'options': u'Supplier', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'opportunity', + 'fieldtype': u'Link', + 'label': u'Opportunity', + 'options': u'Opportunity', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'quotation', + 'fieldtype': u'Link', + 'label': u'Quotation', + 'options': u'Quotation', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'support_ticket', + 'fieldtype': u'Link', + 'label': u'Support Ticket', + 'options': u'Support Ticket', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break1', + 'fieldtype': u'Column Break', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'communication_medium', + 'fieldtype': u'Select', + 'label': u'Communication Medium', + 'options': u'\nChat\nPhone\nEmail\nSMS\nVisit\nOther', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'phone_no', + 'fieldtype': u'Data', + 'label': u'Phone No.', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'email_address', + 'fieldtype': u'Data', + 'label': u'Email Address', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'section_break2', + 'fieldtype': u'Section Break', + 'options': u'simple', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break4', + 'fieldtype': u'Column Break', + 'label': u'Communication Carried Out By', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'default': u'__user', + 'doctype': u'DocField', + 'fieldname': u'user', + 'fieldtype': u'Link', + 'label': u'User', + 'options': u'Profile', + 'permlevel': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'sales_person', + 'fieldtype': u'Link', + 'label': u'Sales Person', + 'options': u'Sales Person', + 'permlevel': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'column_break5', + 'fieldtype': u'Column Break', + 'label': u'Communication Carried Out On', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'default': u'Today', + 'doctype': u'DocField', + 'fieldname': u'communication_date', + 'fieldtype': u'Date', + 'label': u'Date', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'file_list', + 'fieldtype': u'Text', + 'hidden': 1, + 'label': u'File List', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'_user_tags', + 'fieldtype': u'Data', + 'hidden': 1, + 'label': u'User Tags', + 'no_copy': 1, + 'permlevel': 0, + 'print_hide': 1 + } +] \ No newline at end of file diff --git a/erpnext/support/doctype/communication/listview.js b/erpnext/support/doctype/communication/listview.js new file mode 100644 index 00000000000..8d3da060e23 --- /dev/null +++ b/erpnext/support/doctype/communication/listview.js @@ -0,0 +1,35 @@ +wn.doclistviews['Communication'] = wn.views.ListView.extend({ + init: function(doclistview) { + this._super(doclistview); + this.fields = this.fields.concat([ + "`tabCommunication`.creation", + "`tabCommunication`.category", + "`tabCommunication`.subject", + "`tabCommunication`.content" + ]); + this.order_by = "`tabCommunication`.creation desc"; + this.stats = this.stats.concat(['category']); + }, + + prepare_data: function(data) { + this._super(data); + data.creation = wn.datetime.only_date(data.creation); + + data.content = cstr(data.subject) + " | " + cstr(data.content); + + if(data.content && data.content.length > 50) { + data.content = '' + + data.content.substr(0,50) + '...'; + } + }, + + columns: [ + {width: '5%', content: 'avatar'}, + {width: '3%', content: 'docstatus'}, + {width: '15%', content: 'name'}, + {width: '15%', content: 'category'}, + {width: '55%', content: 'content+tags'}, + {width: '12%', content:'creation', + css: {'text-align': 'right', 'color':'#777'}} + ], +}); \ No newline at end of file diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py index c8035dc549c..27ec01e5e57 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py @@ -114,7 +114,7 @@ class DocType(TransactionBase): """ Add calendar event for Maintenece Schedule in calendar of Allocated person""" event = Document('Event') event.owner = incharge_email - event.description = "Item Code:%s and Reference:%s" %(item_code,self.doc.name) + event.description = "Reference:%s, Item Code:%s and Customer: %s" %(self.doc.name, item_code, self.doc.customer) event.event_date = scheduled_date event.event_hour = '10:00' event.event_type = 'Private' diff --git a/erpnext/support/page/support_home/support_home.html b/erpnext/support/page/support_home/support_home.html index dcabe1ce95a..9404f12ac75 100644 --- a/erpnext/support/page/support_home/support_home.html +++ b/erpnext/support/page/support_home/support_home.html @@ -15,6 +15,9 @@

Maintenance Visit

Visit report for maintenance visit

+
+

Communication

+

Communication Log

Serial No

diff --git a/public/js/all-app.js b/public/js/all-app.js index 7358058ad08..f7a507d4a05 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -305,9 +305,9 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico if(icon){$('').addClass(icon).appendTo($button);} $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');} -if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');} +if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.make_new_doc(me.new_doctype);},'icon-plus');} if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');} -if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') +if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') this.onrun=a0;if(a0&&a0.callback) this.onrun=a0.callback;if(!a1&&!(a0&&a0.append)) this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1} @@ -321,7 +321,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct * lib/js/wn/ui/filters.js */ wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length) -this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field) +this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field) values.push(f.get_value());}) return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);}) this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname) @@ -968,13 +968,13 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=d
\
',{label:this.label}));this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs($('').appendTo(this.appframe.$titlebar),locals.DocType[this.doctype].module);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);} -this.listview.parent=this;},init_list:function(){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.$page.find('.wnlist-area'),start:0,page_length:20,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:true,no_result_message:this.make_no_result(),columns:this.listview.fields});this.run();},make_no_result:function(){return repl('

No %(doctype_label)s found

\ +this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){return repl('

No %(doctype_label)s found

\ %(description)s\
\

\ -

',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[]}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length) +

',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||'')});},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length) return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;} me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('').click(function(){me.reload_stats();}).appendTo($('
').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('

Tags

\ @@ -1021,7 +1021,7 @@ if(diff==2){data.when='2 days ago'} if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';} for(key in data){if(data[key]==null){data[key]='';}}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('
');} $.each(data._user_tags.split(','),function(i,t){if(t){$('' -+strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}}) ++strip(t)+'').click(function(){me.doclistview.set_filter('_user_tags',$(this).text())}).appendTo(parent);}});}},show_hide_check_column:function(){if(!this.doclistview.can_delete){this.columns=$.map(this.columns,function(v,i){if(v.content!='check')return v});}}});wn.provide('wn.views.RecordListView');wn.views.RecordListView=wn.views.DocListView.extend({init:function(doctype,wrapper,ListView){this.doctype=doctype;this.wrapper=wrapper;this.listview=new ListView(this);this.listview.parent=this;this.setup();},setup:function(){var me=this;me.page_length=10;$(me.wrapper).empty();me.init_list();},get_args:function(){var args=this._super();$.each((this.default_filters||[]),function(i,f){args.filters.push(f);});args.docstatus=args.docstatus.concat((this.default_docstatus||[]));return args;},}); /* * lib/js/wn/views/formview.js */ diff --git a/public/js/all-web.js b/public/js/all-web.js index 25bd1ba71a4..150f298c781 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -192,9 +192,9 @@ if(this.show_filters){this.make_filters();}},add_button:function(label,click,ico if(icon){$('').addClass(icon).appendTo($button);} $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);} if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');} -if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){newdoc(me.new_doctype);},'icon-plus');} +if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.make_new_doc(me.new_doctype);},'icon-plus');} if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');} -if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') +if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function') this.onrun=a0;if(a0&&a0.callback) this.onrun=a0.callback;if(!a1&&!(a0&&a0.append)) this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1} @@ -208,7 +208,7 @@ if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:funct * lib/js/wn/ui/filters.js */ wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length) -this.add_filter();},add_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));if(fieldname){this.$w.find('.show_filters').toggle(true);}},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field) +this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field) values.push(f.get_value());}) return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);}) this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)