minor changes
This commit is contained in:
parent
7cbf5b4e67
commit
a4e0a1c061
@ -10,52 +10,49 @@ from webnotes.model.bean import copy_doclist
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import msgprint
|
||||
|
||||
|
||||
# ----------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def create_receiver_list(self):
|
||||
rec, where_clause = '', ''
|
||||
if self.doc.send_to == 'All Customer Contact':
|
||||
where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(customer, '') != ''"
|
||||
if self.doc.send_to == 'All Supplier Contact':
|
||||
where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(supplier, '') != ''"
|
||||
if self.doc.send_to == 'All Sales Partner Contact':
|
||||
where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % self.doc.sales_partner or " and ifnull(sales_partner, '') != ''"
|
||||
def create_receiver_list(self):
|
||||
rec, where_clause = '', ''
|
||||
if self.doc.send_to == 'All Customer Contact':
|
||||
where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(customer, '') != ''"
|
||||
if self.doc.send_to == 'All Supplier Contact':
|
||||
where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(supplier, '') != ''"
|
||||
if self.doc.send_to == 'All Sales Partner Contact':
|
||||
where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_partner = '%s'" % self.doc.sales_partner or " and ifnull(sales_partner, '') != ''"
|
||||
|
||||
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
|
||||
rec = webnotes.conn.sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
|
||||
elif self.doc.send_to == 'All Lead (Open)':
|
||||
rec = webnotes.conn.sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
|
||||
elif self.doc.send_to == 'All Employee (Active)':
|
||||
where_clause = self.doc.department and " and department = '%s'" % self.doc.department or ""
|
||||
where_clause += self.doc.branch and " and branch = '%s'" % self.doc.branch or ""
|
||||
rec = webnotes.conn.sql("select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s" % where_clause)
|
||||
elif self.doc.send_to == 'All Sales Person':
|
||||
rec = webnotes.conn.sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
|
||||
rec_list = ''
|
||||
for d in rec:
|
||||
rec_list += d[0] + ' - ' + d[1] + '\n'
|
||||
self.doc.receiver_list = rec_list
|
||||
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
|
||||
rec = webnotes.conn.sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
|
||||
elif self.doc.send_to == 'All Lead (Open)':
|
||||
rec = webnotes.conn.sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
|
||||
elif self.doc.send_to == 'All Employee (Active)':
|
||||
where_clause = self.doc.department and " and department = '%s'" % self.doc.department or ""
|
||||
where_clause += self.doc.branch and " and branch = '%s'" % self.doc.branch or ""
|
||||
rec = webnotes.conn.sql("select employee_name, cell_number from `tabEmployee` where status = 'Active' and docstatus < 2 and ifnull(cell_number,'')!='' %s" % where_clause)
|
||||
elif self.doc.send_to == 'All Sales Person':
|
||||
rec = webnotes.conn.sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
|
||||
rec_list = ''
|
||||
for d in rec:
|
||||
rec_list += d[0] + ' - ' + d[1] + '\n'
|
||||
self.doc.receiver_list = rec_list
|
||||
|
||||
def get_receiver_nos(self):
|
||||
receiver_nos = []
|
||||
for d in self.doc.receiver_list.split('\n'):
|
||||
receiver_no = d
|
||||
if '-' in d:
|
||||
receiver_no = receiver_no.split('-')[1]
|
||||
if receiver_no.strip():
|
||||
receiver_nos.append(cstr(receiver_no).strip())
|
||||
return receiver_nos
|
||||
def get_receiver_nos(self):
|
||||
receiver_nos = []
|
||||
for d in self.doc.receiver_list.split('\n'):
|
||||
receiver_no = d
|
||||
if '-' in d:
|
||||
receiver_no = receiver_no.split('-')[1]
|
||||
if receiver_no.strip():
|
||||
receiver_nos.append(cstr(receiver_no).strip())
|
||||
return receiver_nos
|
||||
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please enter message before sending")
|
||||
else:
|
||||
receiver_list = self.get_receiver_nos()
|
||||
if receiver_list:
|
||||
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.doc.message)))
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please enter message before sending")
|
||||
else:
|
||||
receiver_list = self.get_receiver_nos()
|
||||
if receiver_list:
|
||||
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.doc.message)))
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from webnotes import throw, _
|
||||
|
||||
class ItemPriceDuplicateItem(webnotes.ValidationError): pass
|
||||
|
||||
@ -28,7 +28,7 @@ class DocType:
|
||||
if webnotes.conn.sql("""select name from `tabItem Price`
|
||||
where item_code=%s and price_list=%s and name!=%s""",
|
||||
(self.doc.item_code, self.doc.price_list, self.doc.name)):
|
||||
webnotes.throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
|
||||
throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{
|
||||
"duplicate_item": _("Duplicate Item"),
|
||||
"item_code": self.doc.item_code,
|
||||
"already": _("already available in Price List"),
|
||||
|
@ -7,7 +7,7 @@ import webnotes, json
|
||||
from webnotes.utils import nowdate, cstr
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes import msgprint
|
||||
from webnotes import msgprint, throw, _
|
||||
from webnotes.model.bean import getlist, copy_doclist
|
||||
|
||||
class DocType:
|
||||
@ -26,7 +26,7 @@ class DocType:
|
||||
validated_receiver_list.append(d)
|
||||
|
||||
if not validated_receiver_list:
|
||||
msgprint("Please enter valid mobile nos", raise_exception=1)
|
||||
throw(_("Please enter valid mobile nos"))
|
||||
|
||||
return validated_receiver_list
|
||||
|
||||
@ -37,12 +37,12 @@ class DocType:
|
||||
'ERPNXT'
|
||||
if len(sender_name) > 6 and \
|
||||
webnotes.conn.get_value("Control Panel", None, "country") == "India":
|
||||
msgprint("""
|
||||
throw(_("""
|
||||
As per TRAI rule, sender name must be exactly 6 characters.
|
||||
Kindly change sender name in Setup --> Global Defaults.
|
||||
|
||||
Note: Hyphen, space, numeric digit, special characters are not allowed.
|
||||
""", raise_exception=1)
|
||||
"""))
|
||||
return sender_name
|
||||
|
||||
def get_contact_number(self, arg):
|
||||
|
Loading…
Reference in New Issue
Block a user