separated communication view
This commit is contained in:
@@ -37,15 +37,9 @@ class DocType:
|
||||
else:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '')
|
||||
|
||||
#----------------------
|
||||
# Call to Validate
|
||||
#----------------------
|
||||
def validate(self):
|
||||
self.validate_primary_contact()
|
||||
|
||||
#----------------------
|
||||
# Validate that there can only be one primary contact for particular customer, supplier
|
||||
#----------------------
|
||||
def validate_primary_contact(self):
|
||||
sql = webnotes.conn.sql
|
||||
if self.doc.is_primary_contact == 1:
|
||||
@@ -65,3 +59,9 @@ class DocType:
|
||||
elif self.doc.sales_partner:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
|
||||
self.doc.is_primary_contact = 1
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""update tabCommunication set contact='' where contact=%s""",
|
||||
self.doc.name)
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""",
|
||||
self.doc.name)
|
||||
@@ -241,3 +241,18 @@ class TransactionBase:
|
||||
def get_formatted_message(self, args):
|
||||
""" get formatted message for auto notification"""
|
||||
return get_obj('Notification Control').get_formatted_message(args)
|
||||
|
||||
def add_communication_list(self):
|
||||
# remove communications if present
|
||||
self.doclist = webnotes.doclist(self.doclist).get({
|
||||
"doctype": ["!=", "Communcation"]})
|
||||
|
||||
comm_list = webnotes.conn.sql("""select * from tabCommunication
|
||||
where %s=%s order by modified desc limit 20""" \
|
||||
% (self.doc.doctype.replace(" ", "_").lower(), "%s"),
|
||||
self.doc.name, as_dict=1)
|
||||
|
||||
[d.update({"doctype":"Communication"}) for d in comm_list]
|
||||
|
||||
self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \
|
||||
for d in comm_list]))
|
||||
Reference in New Issue
Block a user