[merge]
diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py
index c646fdb..75b2e03 100644
--- a/buying/doctype/supplier/supplier.py
+++ b/buying/doctype/supplier/supplier.py
@@ -18,9 +18,6 @@
self.doc = doc
self.doclist = doclist
- def onload(self):
- self.add_communication_list()
-
def autoname(self):
supp_master_name = webnotes.defaults.get_global_default('supp_master_name')
diff --git a/buying/doctype/supplier/supplier.txt b/buying/doctype/supplier/supplier.txt
index 8fa7067..50202dc 100644
--- a/buying/doctype/supplier/supplier.txt
+++ b/buying/doctype/supplier/supplier.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:11",
"docstatus": 0,
- "modified": "2013-08-08 14:22:08",
+ "modified": "2013-09-02 16:25:44",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -205,6 +205,14 @@
"oldfieldtype": "Data"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
diff --git a/hr/doctype/job_applicant/get_job_applications.py b/hr/doctype/job_applicant/get_job_applications.py
index 9bec43e..2e01328 100644
--- a/hr/doctype/job_applicant/get_job_applications.py
+++ b/hr/doctype/job_applicant/get_job_applications.py
@@ -37,7 +37,7 @@
mail.save_attachments_in_doc(applicant.doc)
make(content=mail.content, sender=mail.from_email,
- doctype="Job Applicant", name=applicant.doc.name, set_lead=False)
+ doctype="Job Applicant", name=applicant.doc.name)
def get_job_applications():
if cint(webnotes.conn.get_value('Jobs Email Settings', None, 'extract_emails')):
diff --git a/hr/doctype/job_applicant/job_applicant.py b/hr/doctype/job_applicant/job_applicant.py
index e9b12b0..04b6da9 100644
--- a/hr/doctype/job_applicant/job_applicant.py
+++ b/hr/doctype/job_applicant/job_applicant.py
@@ -11,9 +11,6 @@
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
- def onload(self):
- self.add_communication_list()
-
def get_sender(self, comm):
return webnotes.conn.get_value('Jobs Email Settings',None,'email_id')
diff --git a/hr/doctype/job_applicant/job_applicant.txt b/hr/doctype/job_applicant/job_applicant.txt
index ebf95f6..62b1d80 100644
--- a/hr/doctype/job_applicant/job_applicant.txt
+++ b/hr/doctype/job_applicant/job_applicant.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-29 19:25:37",
"docstatus": 0,
- "modified": "2013-07-05 14:43:11",
+ "modified": "2013-09-02 16:26:23",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -90,6 +90,14 @@
"label": "Thread HTML"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"doctype": "DocPerm"
}
]
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 2db62cf..320614a 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -258,4 +258,5 @@
"patches.august_2013.p06_fix_sle_against_stock_entry",
"execute:webnotes.bean('Style Settings').save() #2013-08-20",
"patches.september_2013.p01_fix_buying_amount_gl_entries",
+ "patches.september_2013.p01_update_communication",
]
\ No newline at end of file
diff --git a/patches/september_2013/p01_update_communication.py b/patches/september_2013/p01_update_communication.py
new file mode 100644
index 0000000..c3bd61b
--- /dev/null
+++ b/patches/september_2013/p01_update_communication.py
@@ -0,0 +1,10 @@
+import webnotes
+
+def execute():
+ for doctype in ("Contact", "Lead", "Job Applicant", "Supplier", "Customer", "Quotation", "Sales Person", "Support Ticket"):
+ fieldname = doctype.replace(" ", '_').lower()
+ webnotes.conn.sql("""update tabCommunication
+ set parenttype=%s, parentfield='communications',
+ parent=`%s`
+ where ifnull(`%s`, '')!=''""" % ("%s", fieldname, fieldname), doctype)
+
\ No newline at end of file
diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py
index 2eabf12..cb19d4f 100644
--- a/selling/doctype/customer/customer.py
+++ b/selling/doctype/customer/customer.py
@@ -17,10 +17,7 @@
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
-
- def onload(self):
- self.add_communication_list()
-
+
def autoname(self):
cust_master_name = webnotes.defaults.get_global_default('cust_master_name')
if cust_master_name == 'Customer Name':
diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt
index 7da29d2..94bd8fc 100644
--- a/selling/doctype/customer/customer.txt
+++ b/selling/doctype/customer/customer.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-06-11 14:26:44",
"docstatus": 0,
- "modified": "2013-08-08 14:22:13",
+ "modified": "2013-09-02 16:25:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -349,6 +349,15 @@
"permlevel": 0
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication",
+ "permlevel": 0
+ },
+ {
"amend": 0,
"cancel": 0,
"create": 1,
diff --git a/selling/doctype/lead/get_leads.py b/selling/doctype/lead/get_leads.py
index c63468e..91ffd70 100644
--- a/selling/doctype/lead/get_leads.py
+++ b/selling/doctype/lead/get_leads.py
@@ -12,6 +12,9 @@
lead_name = webnotes.conn.get_value("Lead", {"email_id": sender})
contact_name = webnotes.conn.get_value("Contact", {"email_id": sender})
+ parent_doctype = "Contact" if contact_name else "Lead"
+ parent_name = contact_name or lead_name
+
if not (lead_name or contact_name):
# none, create a new Lead
lead = webnotes.bean({
@@ -26,11 +29,11 @@
lead_name = lead.doc.name
message = make(content=content, sender=sender, subject=subject,
- lead=lead_name, contact=contact_name, date=date)
+ doctype = parent_doctype, name = parent_name, date=date)
if mail:
# save attachments to parent if from mail
- bean = webnotes.bean("Contact" if contact_name else "Lead", contact_name or lead_name)
+ bean = webnotes.bean(parent_doctype, parent_name)
mail.save_attachments_in_doc(bean.doc)
class SalesMailbox(POP3Mailbox):
diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py
index 2bf1aa3..063c5f0 100644
--- a/selling/doctype/lead/lead.py
+++ b/selling/doctype/lead/lead.py
@@ -24,7 +24,6 @@
})
def onload(self):
- self.add_communication_list()
customer = webnotes.conn.get_value("Customer", {"lead_name": self.doc.name})
if customer:
self.doc.fields["__is_customer"] = customer
diff --git a/selling/doctype/lead/lead.txt b/selling/doctype/lead/lead.txt
index d66c6a0..9402259 100644
--- a/selling/doctype/lead/lead.txt
+++ b/selling/doctype/lead/lead.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-04-10 11:45:37",
"docstatus": 0,
- "modified": "2013-08-08 14:22:14",
+ "modified": "2013-09-02 17:25:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -411,6 +411,14 @@
"label": "Blog Subscriber"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"cancel": 1,
"doctype": "DocPerm",
"role": "Sales Manager"
diff --git a/selling/doctype/opportunity/opportunity.py b/selling/doctype/opportunity/opportunity.py
index 906e547..a3ef197 100644
--- a/selling/doctype/opportunity/opportunity.py
+++ b/selling/doctype/opportunity/opportunity.py
@@ -25,9 +25,6 @@
"contact_by": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_by") if \
(not cint(self.doc.fields.get("__islocal"))) else None,
})
-
- 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
diff --git a/selling/doctype/opportunity/opportunity.txt b/selling/doctype/opportunity/opportunity.txt
index 5b1d93f..4ca1564 100644
--- a/selling/doctype/opportunity/opportunity.txt
+++ b/selling/doctype/opportunity/opportunity.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 18:50:30",
"docstatus": 0,
- "modified": "2013-08-08 14:22:15",
+ "modified": "2013-09-02 16:27:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -443,6 +443,14 @@
"width": "150px"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"doctype": "DocPerm",
"role": "Sales User"
},
diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py
index b6ff1d7..c1b529c 100644
--- a/selling/doctype/quotation/quotation.py
+++ b/selling/doctype/quotation/quotation.py
@@ -20,9 +20,6 @@
self.doclist = doclist
self.tname = 'Quotation Item'
self.fname = 'quotation_details'
-
- def onload(self):
- self.add_communication_list()
# Get contact person details based on customer selected
# ------------------------------------------------------
diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt
index c3b2434..9d47259 100644
--- a/selling/doctype/quotation/quotation.txt
+++ b/selling/doctype/quotation/quotation.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
- "modified": "2013-08-09 14:46:11",
+ "modified": "2013-09-02 16:25:01",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -836,6 +836,14 @@
"width": "40px"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"amend": 1,
"cancel": 1,
"create": 1,
diff --git a/setup/doctype/sales_person/sales_person.txt b/setup/doctype/sales_person/sales_person.txt
index 77ba6af..d78b5c8 100644
--- a/setup/doctype/sales_person/sales_person.txt
+++ b/setup/doctype/sales_person/sales_person.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:24",
"docstatus": 0,
- "modified": "2013-08-05 18:11:22",
+ "modified": "2013-09-02 16:26:54",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -161,6 +161,14 @@
"search_index": 0
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
diff --git a/support/doctype/support_ticket/get_support_mails.py b/support/doctype/support_ticket/get_support_mails.py
index 7e09846..fb26e57 100644
--- a/support/doctype/support_ticket/get_support_mails.py
+++ b/support/doctype/support_ticket/get_support_mails.py
@@ -46,7 +46,7 @@
make(content=mail.content, sender=mail.from_email, subject = ticket.doc.subject,
doctype="Support Ticket", name=ticket.doc.name,
- lead = ticket.doc.lead, contact=ticket.doc.contact, date=mail.date)
+ date=mail.date)
if new_ticket and cint(self.email_settings.send_autoreply) and \
"mailer-daemon" not in mail.from_email.lower():
diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py
index 2b8fe85..8e723ee 100644
--- a/support/doctype/support_ticket/support_ticket.py
+++ b/support/doctype/support_ticket/support_ticket.py
@@ -11,9 +11,6 @@
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
-
- def onload(self):
- self.add_communication_list()
def get_sender(self, comm):
return webnotes.conn.get_value('Email Settings',None,'support_email')
@@ -53,7 +50,7 @@
if not self.doc.company:
self.doc.company = webnotes.conn.get_value("Lead", self.doc.lead, "company") or \
webnotes.conn.get_default("company")
-
+
def on_trash(self):
webnotes.conn.sql("""update `tabCommunication` set support_ticket=NULL
where support_ticket=%s""", (self.doc.name,))
diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt
index dcb4520..01d0e35 100644
--- a/support/doctype/support_ticket/support_ticket.txt
+++ b/support/doctype/support_ticket/support_ticket.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-02-01 10:36:25",
"docstatus": 0,
- "modified": "2013-08-28 18:29:06",
+ "modified": "2013-09-02 16:24:24",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -262,6 +262,14 @@
"label": "Content Type"
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"cancel": 0,
"doctype": "DocPerm",
"role": "Guest"
diff --git a/utilities/doctype/contact/contact.py b/utilities/doctype/contact/contact.py
index 961bb52..9997cab 100644
--- a/utilities/doctype/contact/contact.py
+++ b/utilities/doctype/contact/contact.py
@@ -12,9 +12,6 @@
self.doc = doc
self.doclist = doclist
- def onload(self):
- self.add_communication_list()
-
def on_communication_sent(self, comm):
webnotes.conn.set(self.doc, 'status', 'Replied')
diff --git a/utilities/doctype/contact/contact.txt b/utilities/doctype/contact/contact.txt
index 63d0252..d3c7d88 100644
--- a/utilities/doctype/contact/contact.txt
+++ b/utilities/doctype/contact/contact.txt
@@ -2,7 +2,7 @@
{
"creation": "2013-01-10 16:34:32",
"docstatus": 0,
- "modified": "2013-07-05 14:32:19",
+ "modified": "2013-09-02 16:26:13",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -226,6 +226,14 @@
"read_only": 1
},
{
+ "doctype": "DocField",
+ "fieldname": "communications",
+ "fieldtype": "Table",
+ "hidden": 1,
+ "label": "Communications",
+ "options": "Communication"
+ },
+ {
"cancel": 1,
"doctype": "DocPerm",
"role": "System Manager"
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index aace0cb..22bc531 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -229,20 +229,7 @@
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({
- "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, update={"doctype":"Communication"})
-
- self.doclist.extend(webnotes.doclist([webnotes.doc(fielddata=d) \
- for d in comm_list]))
-
+
def validate_posting_time(self):
if not self.doc.posting_time:
self.doc.posting_time = now_datetime().strftime('%H:%M:%S')