cleanup of notification control: now in boot
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index ad774fe..87d6f1c 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -25,7 +25,6 @@
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
// On Load
// -------
@@ -506,11 +505,9 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Sales Invoice',
- doctype: 'Sales Invoice'
+ if(cint(wn.boot.notification_settings.sales_invoice)) {
+ cur_frm.email_doc(wn.boot.notification_settings.sales_invoice);
}
- cur_frm.cscript.notify(doc, args);
}
cur_frm.cscript.invoice_period_from_date = function(doc, dt, dn) {
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 3763abb..aa2e52b 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -40,11 +40,9 @@
self.tname = 'Sales Invoice Item'
self.fname = 'entries'
-
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
-
def set_pos_fields(self):
"""Set retail related fields from pos settings"""
pos = webnotes.conn.sql("select * from `tabPOS Setting` where ifnull(user,'') = '%s' and company = '%s'" % (session['user'], self.doc.company), as_dict=1)
diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js
index 584648d..e31cfd7 100644
--- a/buying/doctype/purchase_order/purchase_order.js
+++ b/buying/doctype/purchase_order/purchase_order.js
@@ -21,7 +21,6 @@
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
// set missing values in parent doc
@@ -220,9 +219,7 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Purchase Order',
- doctype: 'Purchase Order'
+ if(cint(wn.boot.notification_settings.purchase_order)) {
+ cur_frm.email_doc(wn.boot.notification_settings.purchase_order);
}
- cur_frm.cscript.notify(doc, args);
}
diff --git a/buying/doctype/supplier/supplier.js b/buying/doctype/supplier/supplier.js
index 4fd94f5..1b7f369 100644
--- a/buying/doctype/supplier/supplier.js
+++ b/buying/doctype/supplier/supplier.js
@@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/setup/doctype/contact_control/contact_control.js');
-wn.require('app/support/doctype/communication/communication.js');
cur_frm.cscript.onload = function(doc,dt,dn){
@@ -29,7 +28,6 @@
// 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) {
@@ -46,8 +44,13 @@
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
- cur_frm.cscript.render_communication_list(doc, cdt, cdn);
cur_frm.cscript.make_history(doc,dt,dn);
+
+ cur_frm.communication_view = new wn.views.CommunicationList({
+ list: wn.model.get("Communication", {"supplier": doc.name}),
+ parent: cur_frm.fields_dict.communication_html.wrapper,
+ doc: doc
+ })
}
}
diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py
index d7f69d6..fec18af 100644
--- a/buying/doctype/supplier/supplier.py
+++ b/buying/doctype/supplier/supplier.py
@@ -18,26 +18,23 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
-from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, getchildren, make_autoname
-from webnotes.model.wrapper import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, msgprint, errprint
+from webnotes.utils import cint, cstr, get_defaults
+from webnotes.model.code import get_obj
+from webnotes import form, msgprint
-set = webnotes.conn.set
sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
-# -----------------------------------------------------------------------------------------
+from utilities.transaction_base import TransactionBase
-class DocType:
+class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
+ def onload(self):
+ self.add_communication_list()
+
def autoname(self):
#get default naming conventional from control panel
supp_master_name = get_defaults()['supp_master_name']
@@ -59,22 +56,17 @@
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
- # ----------------------------------------
- # update credit days and limit in account
- # ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.name + " - " + self.get_company_abbr()))
-
def on_update(self):
if not self.doc.naming_series:
self.doc.naming_series = ''
-
# create address
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
- set(self.doc,'address', address_line)
+ webnotes.conn.set(self.doc,'address', address_line)
# create account head
self.create_account_head()
@@ -82,12 +74,9 @@
# update credit days and limit in account
self.update_credit_days_limit()
-
def check_state(self):
return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
- # ACCOUNTS
- # -------------------------------------------
def get_payables_group(self):
g = sql("select payables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
@@ -116,7 +105,6 @@
return self.doc.supplier_type + " - " + abbr
-
def validate(self):
#validation for Naming Series mandatory field...
if get_defaults()['supp_master_name'] == 'Naming Series':
@@ -124,9 +112,6 @@
msgprint("Series is Mandatory.")
raise Exception
-
- # create accont head - in tree under zone + territory
- # -------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
@@ -142,7 +127,6 @@
else :
msgprint("Please select Company under which you want to create account head")
-
def get_contacts(self,nm):
if nm:
contact_details =convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm))
@@ -172,16 +156,12 @@
from webnotes.model import delete_doc
delete_doc('Account', acc[0][0])
-
def on_trash(self):
self.delete_supplier_address()
self.delete_supplier_contact()
self.delete_supplier_communication()
self.delete_supplier_account()
-
- # on rename
- # ---------
def on_rename(self,newdn,olddn):
#update supplier_name if not naming series
if get_defaults().get('supp_master_name') == 'Supplier Name':
diff --git a/buying/doctype/supplier/supplier.txt b/buying/doctype/supplier/supplier.txt
index 833c127..a46927b 100644
--- a/buying/doctype/supplier/supplier.txt
+++ b/buying/doctype/supplier/supplier.txt
@@ -2,11 +2,12 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-07-18 20:34:42",
+ "creation": "2012-11-02 17:17:04",
"modified_by": "Administrator",
- "modified": "2012-07-18 17:41:49"
+ "modified": "2012-11-30 10:53:32"
},
{
+ "autoname": "naming_series:",
"name": "__common__",
"search_fields": "supplier_name,supplier_type",
"module": "Buying",
@@ -33,6 +34,16 @@
"doctype": "DocType"
},
{
+ "description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts",
+ "oldfieldtype": "Section Break",
+ "colour": "White:FFF",
+ "doctype": "DocField",
+ "label": "Basic Info",
+ "fieldname": "basic_info",
+ "fieldtype": "Section Break",
+ "permlevel": 0
+ },
+ {
"no_copy": 1,
"oldfieldtype": "Data",
"doctype": "DocField",
@@ -124,7 +135,6 @@
},
{
"doctype": "DocField",
- "label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0
@@ -246,8 +256,7 @@
"write": 1,
"role": "Purchase Master Manager",
"cancel": 1,
- "permlevel": 0,
- "match": ""
+ "permlevel": 0
},
{
"amend": 0,
diff --git a/hr/doctype/expense_claim/expense_claim.js b/hr/doctype/expense_claim/expense_claim.js
index 5ed0d37..d890102 100644
--- a/hr/doctype/expense_claim/expense_claim.js
+++ b/hr/doctype/expense_claim/expense_claim.js
@@ -100,8 +100,6 @@
cur_frm.cscript.calculate_total(doc,cdt,cdn);
}
-wn.require('app/setup/doctype/notification_control/notification_control.js');
-
cur_frm.cscript.approve = function(doc,cdt,cdn){
cur_frm.cscript.calculate_total(doc,cdt,cdn);
@@ -248,12 +246,9 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Expense Claim',
- doctype: 'Expense Claim',
- send_to: doc.exp_approver
+ if(cint(wn.boot.notification_settings.expense_claim)) {
+ cur_frm.email_doc(wn.boot.notification_settings.expense_claim);
}
- cur_frm.cscript.notify(doc, args);
}
cur_frm.fields_dict.employee.get_query = erpnext.utils.employee_query;
\ No newline at end of file
diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js
index 2031fe8..d20b0c9 100644
--- a/selling/doctype/customer/customer.js
+++ b/selling/doctype/customer/customer.js
@@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/setup/doctype/contact_control/contact_control.js');
-wn.require('app/support/doctype/communication/communication.js');
-
-/* ********************************* onload ********************************************* */
cur_frm.cscript.onload = function(doc,dt,dn){
// history doctypes and scripts
@@ -32,8 +29,6 @@
//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) {
@@ -47,8 +42,6 @@
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
-/* ********************************* refresh ********************************************* */
-
cur_frm.cscript.refresh = function(doc,dt,dn) {
if(sys_defaults.cust_master_name == 'Customer Name')
hide_field('naming_series');
@@ -57,16 +50,18 @@
if(doc.__islocal){
hide_field(['address_html','contact_html']);
- //cur_frm.cscript.set_hl_msg(doc);
- //cur_frm.cscript.set_sl_msg(doc);
}else{
unhide_field(['address_html','contact_html']);
// 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_shipping_address(doc,dt,dn);
+
+ cur_frm.communication_view = new wn.views.CommunicationList({
+ list: wn.model.get("Communication", {"customer": doc.name}),
+ parent: cur_frm.fields_dict.communication_html.wrapper,
+ doc: doc
+ });
}
}
@@ -117,11 +112,6 @@
}
-/* ********************************* client triggers ************************************** */
-
-// ---------------
-// customer group
-// ---------------
cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
}
@@ -130,8 +120,6 @@
cur_frm.fields_dict.lead_name.get_query = erpnext.utils.lead_query;
-// Transaction History
-// functions called by these functions are defined in communication.js
cur_frm.cscript.make_qtn_list = function(parent, doc) {
cur_frm.cscript.get_common_list_view(parent, doc, 'Quotation');
}
@@ -173,7 +161,6 @@
cur_frm.cscript.render_list(doc, doctype, parent, ListView);
}
-
cur_frm.cscript.make_si_list = function(parent, doc) {
var ListView = wn.views.ListView.extend({
init: function(doclistview) {
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index 0bf499b..975dd89 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -18,24 +18,24 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import cstr, date_diff, flt, formatdate, get_defaults, getdate, has_common, now, nowdate, replace_newlines, sendmail, set_default, user_format, validate_email_add
+from webnotes.utils import cstr, get_defaults
from webnotes.model.doc import Document, make_autoname
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
-set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
-convert_to_lists = webnotes.conn.convert_to_lists
-# -----------------------------------------------------------------------------------------
+from utilities.transaction_base import TransactionBase
-class DocType:
+class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
-# ******************************************************* autoname ***********************************************************
+ def onload(self):
+ self.add_communication_list()
+
def autoname(self):
cust_master_name = get_defaults().get('cust_master_name')
if cust_master_name == 'Customer Name':
@@ -53,17 +53,9 @@
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
-
-# ******************************************************* triggers ***********************************************************
- # ----------------
- # get company abbr
- # -----------------
def get_company_abbr(self):
return get_value('Company', self.doc.company, 'abbr')
- # -----------------------------------------------------------------------------------------------------
- # get parent account(i.e receivables group from company where default account head need to be created)
- # -----------------------------------------------------------------------------------------------------
def get_receivables_group(self):
g = sql("select receivables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
@@ -72,26 +64,15 @@
raise Exception
return g
-# ******************************************************* validate *********************************************************
- # ----------------
- # validate values
- # ----------------
def validate_values(self):
# Master name by naming series -> Series field mandatory
if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
msgprint("Series is Mandatory.")
raise Exception
- # ---------
- # validate
- # ---------
def validate(self):
self.validate_values()
-# ******************************************************* on update *********************************************************
- # ------------------------
- # create customer address
- # ------------------------
def create_customer_address(self):
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
@@ -100,15 +81,11 @@
address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1)
if self.doc.email_id:
address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id)
- set(self.doc,'address', address_line)
+ webnotes.conn.set(self.doc,'address', address_line)
telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " + "\n" + "(fax): " + cstr(self.doc.fax_1)
- set(self.doc,'telephone',telephone)
+ webnotes.conn.set(self.doc,'telephone',telephone)
-
- # ------------------------------------
- # create primary contact for customer
- # ------------------------------------
def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr):
c1 = Document('Contact')
c1.first_name = nm
@@ -126,10 +103,6 @@
c1.customer_group = self.doc.customer_group
c1.save(1)
-
- # ------------------------
- # create customer contact
- # ------------------------
def create_customer_contact(self):
contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name))
contact = contact and contact[0][0] or ''
@@ -143,18 +116,10 @@
c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1)
self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '')
-
- # -------------------
- # update lead status
- # -------------------
def update_lead_status(self):
if self.doc.lead_name:
sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
-
- # -------------------------------------------------------------------------
- # create accont head - in tree under receivables_group of selected company
- # -------------------------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
@@ -167,15 +132,9 @@
else :
msgprint("Please Select Company under which you want to create account head")
-
- # ----------------------------------------
- # update credit days and limit in account
- # ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.credit_limit, self.doc.name + " - " + self.get_company_abbr()))
-
- #create address and contact from lead
def create_lead_address_contact(self):
if self.doc.lead_name:
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, phone, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
@@ -211,9 +170,6 @@
except NameError, e:
pass
- # ----------
- # on update
- # ----------
def on_update(self):
# create customer addr
#self.create_customer_address()
@@ -257,8 +213,6 @@
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
- # on rename
- # ---------
def on_rename(self,newdn,olddn):
#update customer_name if not naming series
if get_defaults().get('cust_master_name') == 'Customer Name':
diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt
index a20a982..6b174d7 100644
--- a/selling/doctype/customer/customer.txt
+++ b/selling/doctype/customer/customer.txt
@@ -2,11 +2,12 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-10-02 11:27:30",
+ "creation": "2012-11-02 17:16:46",
"modified_by": "Administrator",
- "modified": "2012-09-28 12:31:42"
+ "modified": "2012-11-30 10:54:38"
},
{
+ "autoname": "naming_series:",
"name": "__common__",
"default_print_format": "Standard",
"allow_print": 0,
@@ -35,6 +36,17 @@
"doctype": "DocType"
},
{
+ "description": "Note: You Can Manage Multiple Address or Contacts via Addresses & Contacts",
+ "oldfieldtype": "Section Break",
+ "colour": "White:FFF",
+ "doctype": "DocField",
+ "label": "Basic Info",
+ "fieldname": "basic_info",
+ "fieldtype": "Section Break",
+ "reqd": 0,
+ "permlevel": 0
+ },
+ {
"print_hide": 0,
"no_copy": 1,
"oldfieldtype": "Data",
@@ -183,7 +195,6 @@
},
{
"doctype": "DocField",
- "label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0
diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js
index 081a57a..0c5bf87 100644
--- a/selling/doctype/lead/lead.js
+++ b/selling/doctype/lead/lead.js
@@ -73,7 +73,6 @@
doc: doc,
email: doc.email_id
})
-
}
diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js
index a729092..3da2ac8 100644
--- a/selling/doctype/opportunity/opportunity.js
+++ b/selling/doctype/opportunity/opportunity.js
@@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/support/doctype/communication/communication.js');
cur_frm.cscript.refresh = function(doc, cdt, cdn){
erpnext.hide_naming_series();
@@ -26,7 +25,6 @@
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
@@ -48,7 +46,14 @@
}
}
- cur_frm.cscript.make_communication_body();
+ if(!doc.__islocal) {
+ cur_frm.communication_view = new wn.views.CommunicationList({
+ list: wn.model.get("Communication", {"opportunity": doc.name}),
+ parent: cur_frm.fields_dict.communication_html.wrapper,
+ doc: doc,
+ email: doc.contact_email
+ });
+ }
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query;
diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py
index 398418a..4f10c80 100644
--- a/selling/doctype/opportunity/opportunity.py
+++ b/selling/doctype/opportunity/opportunity.py
@@ -18,21 +18,15 @@
from __future__ import unicode_literals
import webnotes
-from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.utils import add_days, add_years, cint, cstr, date_diff, flt, getdate
from webnotes.model import db_exists
-from webnotes.model.doc import Document, addchild, getchildren, make_autoname
-from webnotes.model.wrapper import getlist, copy_doclist
-from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
-from webnotes import session, form, msgprint, errprint
+from webnotes.model.doc import Document, addchild, make_autoname
+from webnotes.model.wrapper import getlist
+from webnotes.model.code import get_obj
+from webnotes import form, msgprint
-set = webnotes.conn.set
sql = webnotes.conn.sql
-get_value = webnotes.conn.get_value
-in_transaction = webnotes.conn.in_transaction
-convert_to_lists = webnotes.conn.convert_to_lists
-# -----------------------------------------------------------------------------------------
-
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
@@ -42,8 +36,8 @@
self.fname = 'enq_details'
self.tname = 'Opportunity Item'
- def autoname(self):
- self.doc.name = make_autoname(self.doc.naming_series+'.####')
+ def onload(self):
+ self.add_communication_list()
def get_item_details(self, item_code):
item = sql("""select item_name, stock_uom, description_html, description, item_group, brand
@@ -94,8 +88,8 @@
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
if self.doc.contact_by:
self.add_calendar_event()
- set(self.doc, 'contact_date_ref',self.doc.contact_date)
- set(self.doc, 'status', 'Draft')
+ webnotes.conn.set(self.doc, 'contact_date_ref',self.doc.contact_date)
+ webnotes.conn.set(self.doc, 'status', 'Draft')
def add_calendar_event(self):
desc=''
@@ -169,7 +163,7 @@
self.validate_lead_cust()
def on_submit(self):
- set(self.doc, 'status', 'Submitted')
+ webnotes.conn.set(self.doc, 'status', 'Submitted')
def on_cancel(self):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
@@ -177,7 +171,7 @@
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus can not be cancelled.")
raise Exception
else:
- set(self.doc, 'status', 'Cancelled')
+ webnotes.conn.set(self.doc, 'status', 'Cancelled')
def declare_enquiry_lost(self,arg):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Item` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
@@ -185,6 +179,6 @@
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Opportunity. Thus 'Opportunity Lost' can not be declared against it.")
raise Exception
else:
- set(self.doc, 'status', 'Opportunity Lost')
- set(self.doc, 'order_lost_reason', arg)
+ webnotes.conn.set(self.doc, 'status', 'Opportunity Lost')
+ webnotes.conn.set(self.doc, 'order_lost_reason', arg)
return 'true'
diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt
index f89a5d2..575cc10 100644
--- a/selling/doctype/opportunity/opportunity.txt
+++ b/selling/doctype/opportunity/opportunity.txt
@@ -2,12 +2,13 @@
{
"owner": "Administrator",
"docstatus": 0,
- "creation": "2012-11-28 11:26:19",
+ "creation": "2012-11-24 17:21:44",
"modified_by": "Administrator",
- "modified": "2012-11-16 12:27:49"
+ "modified": "2012-11-30 10:54:00"
},
{
"is_submittable": 1,
+ "autoname": "naming_series:",
"name": "__common__",
"default_print_format": "Standard",
"search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company",
@@ -35,6 +36,16 @@
"doctype": "DocType"
},
{
+ "description": "Enter customer enquiry for which you might raise a quotation in future",
+ "oldfieldtype": "Section Break",
+ "colour": "White:FFF",
+ "doctype": "DocField",
+ "label": "Basic Info",
+ "fieldname": "basic_info",
+ "fieldtype": "Section Break",
+ "permlevel": 0
+ },
+ {
"description": "To manage multiple series please go to Setup > Manage Series",
"no_copy": 1,
"oldfieldtype": "Select",
@@ -154,15 +165,14 @@
"oldfieldtype": "Section Break",
"colour": "White:FFF",
"doctype": "DocField",
- "label": "Communication History",
"fieldname": "communication_history",
"fieldtype": "Section Break",
"permlevel": 0
},
{
- "allow_on_submit": 1,
"oldfieldtype": "Table",
"colour": "White:FFF",
+ "allow_on_submit": 1,
"doctype": "DocField",
"label": "Communication HTML",
"oldfieldname": "follow_up",
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index e629975..1b03781 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -24,8 +24,6 @@
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
-wn.require('app/support/doctype/communication/communication.js');
// ONLOAD
// ===================================================================================
@@ -49,7 +47,7 @@
hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']);
}
}
- cur_frm.cscript.make_communication_body();
+ //cur_frm.cscript.make_communication_body();
if(cur_frm.fields_dict.contact_by.df.options.match(/^Profile/)) {
cur_frm.fields_dict.contact_by.get_query = erpnext.utils.profile_query;
@@ -104,7 +102,14 @@
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);
+ if (!doc.__islocal) {
+ cur_frm.communication_view = new wn.views.CommunicationList({
+ list: wn.model.get("Communication", {"quotation": doc.name}),
+ parent: cur_frm.fields_dict.communication_html.wrapper,
+ doc: doc,
+ email: doc.contact_email
+ });
+ }
}
@@ -333,9 +338,7 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Quotation',
- doctype: 'Quotation'
+ if(cint(wn.boot.notification_settings.quotation)) {
+ cur_frm.email_doc(wn.boot.notification_settings.quotation_message);
}
- cur_frm.cscript.notify(doc, args);
}
\ No newline at end of file
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index 76b1ef6..cef0abe 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -41,7 +41,10 @@
self.doclist = doclist
self.tname = 'Quotation Item'
self.fname = 'quotation_details'
-
+
+ def onload(self):
+ self.add_communication_list()
+
# Pull Opportunity Details
# --------------------
def pull_enq_details(self):
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index f720cfa..6a3dfc4 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -25,7 +25,6 @@
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
// ONLOAD
@@ -369,9 +368,7 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Sales Order',
- doctype: 'Sales Order'
+ if(cint(wn.boot.notification_settings.sales_order)) {
+ cur_frm.email_doc(wn.boot.notification_settings.sales_order);
}
- cur_frm.cscript.notify(doc, args);
}
diff --git a/setup/doctype/notification_control/notification_control.js b/setup/doctype/notification_control/notification_control.js
index b52520a..619d417 100644
--- a/setup/doctype/notification_control/notification_control.js
+++ b/setup/doctype/notification_control/notification_control.js
@@ -22,45 +22,5 @@
refresh_field('custom_message');
}
$c_obj(make_doclist(cdt, cdn),'get_message',doc.select_transaction, callback)
-}
-}
-
-cur_frm.cscript.notify = function(doc, args) {
- var doc = locals[doc.doctype][doc.name];
- $c_obj(make_doclist(doc.doctype, doc.name), 'get_formatted_message', {
- type: args['type'],
- doctype: args['doctype'],
- contact_name: args['contact_name'] || doc.contact_display
- }, function(r, rt) {
- if(!r.exc) {
- var res = JSON.parse(r.message);
- var send_from = (function() {
- if(user!='Administrator') {
- return user;
- } else {
- return (wn.control_panel.auto_email_id ||
- 'ERPNext Notification<automail@erpnext.com>');
- }
- })();
- if(res.send) {
- var print_heading = (doc.select_print_heading || args['type'])
- if(validate_email(args['send_to'] || doc.contact_email || '')) {
- sendmail(
- args['send_to'] || doc.contact_email,
- send_from,
- send_from,
- doc.company + " - " + print_heading + " - " + doc.name,
- res.message,
- res.print_format
- );
- msgprint('This ' + print_heading + ' is being sent to <b>'
- + (args['send_to'] || doc.contact_email) + '</b><br />...');
- } else {
- msgprint('Invalid/Missing Email Address of Contact. Auto notification for '
- + print_heading + ' not sent.');
- }
- }
- }
- //console.log(JSON.parse(r.message));
- });
+ }
}
diff --git a/setup/doctype/notification_control/notification_control.py b/setup/doctype/notification_control/notification_control.py
index f8b0ee2..b40ba6e 100644
--- a/setup/doctype/notification_control/notification_control.py
+++ b/setup/doctype/notification_control/notification_control.py
@@ -25,84 +25,17 @@
sql = webnotes.conn.sql
-# -----------------------------------------------------------------------------------------
-# Notification control
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
- # get message to load in custom text
- # ----------------------------------
def get_message(self, arg):
fn = arg.lower().replace(' ', '_') + '_message'
v = sql("select value from tabSingles where field=%s and doctype=%s", (fn, 'Notification Control'))
return v and v[0][0] or ''
- # set custom text
- # ---------------
def set_message(self, arg = ''):
fn = self.doc.select_transaction.lower().replace(' ', '_') + '_message'
webnotes.conn.set(self.doc, fn, self.doc.custom_message)
msgprint("Custom Message for %s updated!" % self.doc.select_transaction)
-
- def get_formatted_message(self, args):
- """
- args can contain:
- * type
- * doctype
- * contact_name
- """
- import json
- args = json.loads(args)
- res = {
- 'send': 0,
- 'message': self.prepare_message(args),
- 'print_format': self.get_default_print_format(args)
- }
-
- dt_small = args.get('doctype').replace(' ', '_').lower()
- if cint(self.doc.fields.get(dt_small)):
- res['send'] = 1
-
- return json.dumps(res)
-
-
- def prepare_message(self, args):
- """
- Prepares message body
- """
- if args.get('type'):
- msg_dict = {}
- msg_dict['message'] = args.get('message') or self.get_message(args.get('type'))
- msg_dict['company'] = Document('Control Panel', 'Control Panel').company_name
- msg_dict['salutation'] = "Hi" + (args.get('contact_name') and (" " + args.get('contact_name')) or "")
- msg_dict['send_from'] = webnotes.conn.sql("""\
- SELECT CONCAT_WS(' ', first_name, last_name)
- FROM `tabProfile`
- WHERE name = %s""", webnotes.session['user'], as_list=1)[0][0] or ''
-
- return """\
- <div>
- %(salutation)s,
-
- %(message)s
-
- Thanks,
- %(send_from)s
- %(company)s
- </div>""" % msg_dict
-
- else: return ""
-
-
- def get_default_print_format(self, args):
- """
- Get default print format from doclayer
- """
- doclayer = get_obj('Customize Form', 'Customize Form')
- doclayer.doc.doc_type = args.get('doctype')
- doclayer.get()
- if doclayer.doc.default_print_format:
- return doclayer.doc.default_print_format
- else: return 'Standard'
diff --git a/startup/event_handlers.py b/startup/event_handlers.py
index 7d1f584..07205b8 100644
--- a/startup/event_handlers.py
+++ b/startup/event_handlers.py
@@ -76,6 +76,8 @@
import webnotes.model.doctype
bootinfo['docs'] += webnotes.model.doctype.get('Event')
bootinfo['docs'] += webnotes.model.doctype.get('Search Criteria')
+ bootinfo['notification_settings'] = webnotes.doc("Notification Control",
+ "Notification Control").get_values()
bootinfo['modules_list'] = webnotes.conn.get_global('modules_list')
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 4a3910a..6295811 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -23,7 +23,6 @@
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
// ONLOAD
// ================================================================================================
@@ -327,9 +326,7 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Delivery Note',
- doctype: 'Delivery Note'
+ if(cint(wn.boot.notification_settings.delivery_note)) {
+ cur_frm.email_doc(wn.boot.notification_settings.delivery_note);
}
- cur_frm.cscript.notify(doc, args);
}
\ No newline at end of file
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js
index b943314..0ab6681 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -21,7 +21,6 @@
wn.require('app/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js');
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
-wn.require('app/setup/doctype/notification_control/notification_control.js');
//========================== On Load ================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
@@ -311,9 +310,7 @@
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
- var args = {
- type: 'Purchase Receipt',
- doctype: 'Purchase Receipt'
+ if(cint(wn.boot.notification_settings.purchase_receipt)) {
+ cur_frm.email_doc(wn.boot.notification_settings.purchase_receipt);
}
- cur_frm.cscript.notify(doc, args);
}
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 398a831..37b818e 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -238,10 +238,12 @@
return dcc
- def get_formatted_message(self, args):
- """ get formatted message for auto notification"""
- return get_obj('Notification Control').get_formatted_message(args)
-
+ def load_notification_message(self):
+ dt = self.doc.doctype.lower().replace(" ", "_")
+ if int(webnotes.conn.get_value("Notification Control", None, dt) or 0):
+ self.doc.fields["__notification_message"] = \
+ webnotes.conn.get_value("Notification Control", None, dt + "_message")
+
def add_communication_list(self):
# remove communications if present
self.doclist = webnotes.doclist(self.doclist).get({