mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 18:21:22 +00:00
Merge branch 'wsgi' of https://github.com/webnotes/erpnext into i18n
Conflicts: accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js public/js/complete_setup.js selling/doctype/opportunity/opportunity.js selling/doctype/quotation/quotation.js
This commit is contained in:
@@ -7,7 +7,6 @@ import webnotes
|
||||
from webnotes import session, msgprint
|
||||
from webnotes.utils import today
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
@@ -28,7 +27,7 @@ class DocType(TransactionBase):
|
||||
self.doc.resolved_by = webnotes.session.user
|
||||
|
||||
def on_cancel(self):
|
||||
lst = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t2.prevdoc_docname = '%s' and t1.docstatus!=2"%(self.doc.name))
|
||||
lst = webnotes.conn.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t2.prevdoc_docname = '%s' and t1.docstatus!=2"%(self.doc.name))
|
||||
if lst:
|
||||
lst1 = ','.join([x[0] for x in lst])
|
||||
msgprint("Maintenance Visit No. "+lst1+" already created against this customer issue. So can not be Cancelled")
|
||||
|
||||
@@ -9,7 +9,6 @@ from webnotes.model.doc import addchild
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase, delete_events
|
||||
@@ -20,7 +19,7 @@ class DocType(TransactionBase):
|
||||
self.doclist = doclist
|
||||
|
||||
def get_item_details(self, item_code):
|
||||
item = sql("select item_name, description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
||||
item = webnotes.conn.sql("select item_name, description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
||||
ret = {
|
||||
'item_name': item and item[0]['item_name'] or '',
|
||||
'description' : item and item[0]['description'] or ''
|
||||
@@ -30,7 +29,7 @@ class DocType(TransactionBase):
|
||||
def generate_schedule(self):
|
||||
self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
|
||||
count = 0
|
||||
sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
||||
webnotes.conn.sql("delete from `tabMaintenance Schedule Detail` where parent='%s'" %(self.doc.name))
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
self.validate_maintenance_detail()
|
||||
s_list =[]
|
||||
@@ -67,7 +66,7 @@ class DocType(TransactionBase):
|
||||
email_map[d.incharge_name] = webnotes.bean("Sales Person",
|
||||
d.incharge_name).run_method("get_email_id")
|
||||
|
||||
scheduled_date =sql("select scheduled_date from `tabMaintenance Schedule Detail` \
|
||||
scheduled_date =webnotes.conn.sql("select scheduled_date from `tabMaintenance Schedule Detail` \
|
||||
where incharge_name='%s' and item_code='%s' and parent='%s' " %(d.incharge_name, \
|
||||
d.item_code, self.doc.name), as_dict=1)
|
||||
|
||||
@@ -172,7 +171,7 @@ class DocType(TransactionBase):
|
||||
def validate_sales_order(self):
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
if d.prevdoc_docname:
|
||||
chk = sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", d.prevdoc_docname)
|
||||
chk = webnotes.conn.sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", d.prevdoc_docname)
|
||||
if chk:
|
||||
msgprint("Maintenance Schedule against "+d.prevdoc_docname+" already exist")
|
||||
raise Exception
|
||||
@@ -186,7 +185,7 @@ class DocType(TransactionBase):
|
||||
cur_s_no = cur_serial_no.split(',')
|
||||
|
||||
for x in cur_s_no:
|
||||
chk = sql("select name, status from `tabSerial No` where docstatus!=2 and name=%s", (x))
|
||||
chk = webnotes.conn.sql("select name, status from `tabSerial No` where docstatus!=2 and name=%s", (x))
|
||||
chk1 = chk and chk[0][0] or ''
|
||||
status = chk and chk[0][1] or ''
|
||||
|
||||
@@ -209,7 +208,7 @@ class DocType(TransactionBase):
|
||||
cur_s_no = cur_serial_no.split(',')
|
||||
|
||||
for x in cur_s_no:
|
||||
dt = sql("select delivery_date from `tabSerial No` where name = %s", x)
|
||||
dt = webnotes.conn.sql("select delivery_date from `tabSerial No` where name = %s", x)
|
||||
dt = dt and dt[0][0] or ''
|
||||
|
||||
if dt:
|
||||
@@ -225,7 +224,7 @@ class DocType(TransactionBase):
|
||||
cur_s_no = cur_serial_no.split(',')
|
||||
|
||||
for x in cur_s_no:
|
||||
sql("update `tabSerial No` set amc_expiry_date = '%s', maintenance_status = 'Under AMC' where name = '%s'"% (amc_end_date,x))
|
||||
webnotes.conn.sql("update `tabSerial No` set amc_expiry_date = '%s', maintenance_status = 'Under AMC' where name = '%s'"% (amc_end_date,x))
|
||||
|
||||
def on_update(self):
|
||||
webnotes.conn.set(self.doc, 'status', 'Draft')
|
||||
@@ -233,7 +232,7 @@ class DocType(TransactionBase):
|
||||
def validate_serial_no_warranty(self):
|
||||
for d in getlist(self.doclist, 'item_maintenance_detail'):
|
||||
if cstr(d.serial_no).strip():
|
||||
dt = sql("""select warranty_expiry_date, amc_expiry_date
|
||||
dt = webnotes.conn.sql("""select warranty_expiry_date, amc_expiry_date
|
||||
from `tabSerial No` where name = %s""", d.serial_no, as_dict=1)
|
||||
if dt[0]['warranty_expiry_date'] and dt[0]['warranty_expiry_date'] >= d.start_date:
|
||||
webnotes.msgprint("""Serial No: %s is already under warranty upto %s.
|
||||
|
||||
@@ -8,7 +8,6 @@ from webnotes.utils import cstr
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
from utilities.transaction_base import TransactionBase
|
||||
@@ -19,7 +18,7 @@ class DocType(TransactionBase):
|
||||
self.doclist = doclist
|
||||
|
||||
def get_item_details(self, item_code):
|
||||
item = sql("select item_name,description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
||||
item = webnotes.conn.sql("select item_name,description from `tabItem` where name = '%s'" %(item_code), as_dict=1)
|
||||
ret = {
|
||||
'item_name' : item and item[0]['item_name'] or '',
|
||||
'description' : item and item[0]['description'] or ''
|
||||
@@ -28,7 +27,7 @@ class DocType(TransactionBase):
|
||||
|
||||
def validate_serial_no(self):
|
||||
for d in getlist(self.doclist, 'maintenance_visit_details'):
|
||||
if d.serial_no and not sql("select name from `tabSerial No` where name = '%s' and docstatus != 2" % d.serial_no):
|
||||
if d.serial_no and not webnotes.conn.sql("select name from `tabSerial No` where name = '%s' and docstatus != 2" % d.serial_no):
|
||||
msgprint("Serial No: "+ d.serial_no + " not exists in the system")
|
||||
raise Exception
|
||||
|
||||
@@ -52,7 +51,7 @@ class DocType(TransactionBase):
|
||||
elif self.doc.completion_status == 'Partially Completed':
|
||||
status = 'Work In Progress'
|
||||
else:
|
||||
nm = sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.doc.name))
|
||||
nm = webnotes.conn.sql("select t1.name, t1.mntc_date, t2.service_person, t2.work_done from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.completion_status = 'Partially Completed' and t2.prevdoc_docname = %s and t1.name!=%s and t1.docstatus = 1 order by t1.name desc limit 1", (d.prevdoc_docname, self.doc.name))
|
||||
|
||||
if nm:
|
||||
status = 'Work In Progress'
|
||||
@@ -65,7 +64,7 @@ class DocType(TransactionBase):
|
||||
service_person = ''
|
||||
work_done = ''
|
||||
|
||||
sql("update `tabCustomer Issue` set resolution_date=%s, resolved_by=%s, resolution_details=%s, status=%s where name =%s",(mntc_date,service_person,work_done,status,d.prevdoc_docname))
|
||||
webnotes.conn.sql("update `tabCustomer Issue` set resolution_date=%s, resolved_by=%s, resolution_details=%s, status=%s where name =%s",(mntc_date,service_person,work_done,status,d.prevdoc_docname))
|
||||
|
||||
|
||||
def check_if_last_visit(self):
|
||||
@@ -77,7 +76,7 @@ class DocType(TransactionBase):
|
||||
check_for_doctype = d.prevdoc_doctype
|
||||
|
||||
if check_for_docname:
|
||||
check = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.doc.name, check_for_docname, self.doc.mntc_date, self.doc.mntc_date, self.doc.mntc_time))
|
||||
check = webnotes.conn.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent = t1.name and t1.name!=%s and t2.prevdoc_docname=%s and t1.docstatus = 1 and (t1.mntc_date > %s or (t1.mntc_date = %s and t1.mntc_time > %s))", (self.doc.name, check_for_docname, self.doc.mntc_date, self.doc.mntc_date, self.doc.mntc_time))
|
||||
|
||||
if check:
|
||||
check_lst = [x[0] for x in check]
|
||||
|
||||
@@ -76,22 +76,25 @@ class DocType():
|
||||
sender = self.doc.send_from or webnotes.utils.get_formatted_email(self.doc.owner)
|
||||
|
||||
from webnotes.utils.email_lib.bulk import send
|
||||
webnotes.conn.auto_commit_on_many_writes = True
|
||||
|
||||
if not webnotes.flags.in_test:
|
||||
webnotes.conn.auto_commit_on_many_writes = True
|
||||
|
||||
send(recipients = self.recipients, sender = sender,
|
||||
subject = self.doc.subject, message = self.doc.message,
|
||||
doctype = self.send_to_doctype, email_field = "email_id",
|
||||
ref_doctype = self.doc.doctype, ref_docname = self.doc.name)
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = False
|
||||
if not webnotes.flags.in_test:
|
||||
webnotes.conn.auto_commit_on_many_writes = False
|
||||
|
||||
def validate_send(self):
|
||||
if self.doc.fields.get("__islocal"):
|
||||
webnotes.msgprint(_("""Please save the Newsletter before sending."""),
|
||||
raise_exception=1)
|
||||
|
||||
import conf
|
||||
if getattr(conf, "status", None) == "Trial":
|
||||
from webnotes import conf
|
||||
if (conf.get("status") or None) == "Trial":
|
||||
webnotes.msgprint(_("""Sending newsletters is not allowed for Trial users, \
|
||||
to prevent abuse of this feature."""), raise_exception=1)
|
||||
|
||||
@@ -105,7 +108,6 @@ def get_lead_options():
|
||||
}
|
||||
|
||||
|
||||
lead_naming_series = None
|
||||
def create_lead(email_id):
|
||||
"""create a lead if it does not exist"""
|
||||
from email.utils import parseaddr
|
||||
@@ -119,7 +121,7 @@ def create_lead(email_id):
|
||||
"email_id": email_id,
|
||||
"lead_name": real_name or email_id,
|
||||
"status": "Contacted",
|
||||
"naming_series": lead_naming_series or get_lead_naming_series(),
|
||||
"naming_series": get_lead_naming_series(),
|
||||
"company": webnotes.conn.get_default("company"),
|
||||
"source": "Email"
|
||||
})
|
||||
@@ -127,7 +129,7 @@ def create_lead(email_id):
|
||||
|
||||
def get_lead_naming_series():
|
||||
"""gets lead's default naming series"""
|
||||
global lead_naming_series
|
||||
lead_naming_series = None
|
||||
naming_series_field = webnotes.get_doctype("Lead").get_field("naming_series")
|
||||
if naming_series_field.default:
|
||||
lead_naming_series = naming_series_field.default
|
||||
|
||||
@@ -45,20 +45,23 @@ test_records =[
|
||||
"subject": "_Test Newsletter to Lead",
|
||||
"send_to_type": "Lead",
|
||||
"lead_source": "All",
|
||||
"message": "This is a test newsletter"
|
||||
"message": "This is a test newsletter",
|
||||
"send_from": "admin@example.com"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Newsletter",
|
||||
"subject": "_Test Newsletter to Contact",
|
||||
"send_to_type": "Contact",
|
||||
"contact_type": "Customer",
|
||||
"message": "This is a test newsletter"
|
||||
"message": "This is a test newsletter",
|
||||
"send_from": "admin@example.com"
|
||||
}],
|
||||
[{
|
||||
"doctype": "Newsletter",
|
||||
"subject": "_Test Newsletter to Custom",
|
||||
"send_to_type": "Custom",
|
||||
"email_list": "test_custom@example.com, test_custom1@example.com, test_custom2@example.com",
|
||||
"message": "This is a test newsletter"
|
||||
"message": "This is a test newsletter",
|
||||
"send_from": "admin@example.com"
|
||||
}],
|
||||
]
|
||||
|
||||
@@ -54,7 +54,7 @@ Original Query:
|
||||
|
||||
def auto_close_tickets(self):
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set status = 'Closed'
|
||||
where status = 'Waiting for Customer'
|
||||
where status = 'Replied'
|
||||
and date_sub(curdate(),interval 15 Day) > modified""")
|
||||
|
||||
def get_support_mails():
|
||||
@@ -81,7 +81,7 @@ def add_support_communication(subject, content, sender, docname=None, mail=None)
|
||||
|
||||
make(content=content, sender=sender, subject = subject,
|
||||
doctype="Support Ticket", name=ticket.doc.name,
|
||||
date=mail.date if mail else today())
|
||||
date=mail.date if mail else today(), sent_or_received="Received")
|
||||
|
||||
if mail:
|
||||
mail.save_attachments_in_doc(ticket.doc)
|
||||
|
||||
@@ -6,7 +6,7 @@ cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
|
||||
|
||||
wn.provide("erpnext.support");
|
||||
// TODO commonify this code
|
||||
erpnext.support.CustomerIssue = wn.ui.form.Controller.extend({
|
||||
erpnext.support.SupportTicket = wn.ui.form.Controller.extend({
|
||||
customer: function() {
|
||||
var me = this;
|
||||
if(this.frm.doc.customer) {
|
||||
@@ -18,7 +18,7 @@ erpnext.support.CustomerIssue = wn.ui.form.Controller.extend({
|
||||
}
|
||||
});
|
||||
|
||||
$.extend(cur_frm.cscript, new erpnext.support.CustomerIssue({frm: cur_frm}));
|
||||
$.extend(cur_frm.cscript, new erpnext.support.SupportTicket({frm: cur_frm}));
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
onload: function(doc, dt, dn) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class DocType(TransactionBase):
|
||||
|
||||
def get_sender(self, comm):
|
||||
return webnotes.conn.get_value('Email Settings',None,'support_email')
|
||||
|
||||
|
||||
def get_subject(self, comm):
|
||||
return '[' + self.doc.name + '] ' + (comm.subject or 'No Subject Specified')
|
||||
|
||||
@@ -35,16 +35,7 @@ class DocType(TransactionBase):
|
||||
if self.doc.status == "Closed":
|
||||
from webnotes.widgets.form.assign_to import clear
|
||||
clear(self.doc.doctype, self.doc.name)
|
||||
|
||||
def on_communication(self, comm):
|
||||
if comm.sender == self.get_sender(comm) or \
|
||||
webnotes.conn.get_value("Profile", extract_email_id(comm.sender), "user_type")=="System User":
|
||||
self.doc.status = "Waiting for Customer"
|
||||
else:
|
||||
self.doc.status = "Open"
|
||||
self.update_status()
|
||||
self.doc.save()
|
||||
|
||||
|
||||
def set_lead_contact(self, email_id):
|
||||
import email.utils
|
||||
email_id = email.utils.parseaddr(email_id)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-02-01 10:36:25",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-09-10 10:54:02",
|
||||
"modified": "2013-10-03 16:45:41",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -71,7 +71,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "status",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nOpen\nTo Reply\nWaiting for Customer\nHold\nClosed",
|
||||
"options": "Open\nReplied\nHold\nClosed",
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-05-06 14:25:21",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-05-06 14:32:47",
|
||||
"modified": "2013-10-09 12:23:27",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -10,7 +10,7 @@
|
||||
"doctype": "Report",
|
||||
"is_standard": "Yes",
|
||||
"name": "__common__",
|
||||
"query": "SELECT\n ms_item.scheduled_date as \"Schedule Date:Date:120\",\n\tms_item.item_code as \"Item Code:Link/Item:120\",\n\tms_item.item_name as \"Item Name::120\",\n\tms_item.serial_no as \"Serial No::120\",\n\tms_item.incharge_name as \"Incharge::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms.sales_order_no as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, `tabMaintenance Schedule Detail` ms_item\nWHERE\n\tms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_item.scheduled_date asc, ms_item.item_code asc",
|
||||
"query": "SELECT\n ms_sch.scheduled_date as \"Schedule Date:Date:120\",\n\tms_sch.item_code as \"Item Code:Link/Item:120\",\n\tms_sch.item_name as \"Item Name::120\",\n\tms_sch.serial_no as \"Serial No::120\",\n\tms_sch.incharge_name as \"Incharge::120\",\n\tms.customer_name as \"Customer:Link/Customer:120\",\n\tms.address_display as \"Customer Address::120\",\n\tms_item.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n\tms.company as \"Company:Link/Company:120\"\n\t\nFROM\n\t`tabMaintenance Schedule` ms, \n `tabMaintenance Schedule Detail` ms_sch, \n `tabMaintenance Schedule Item` ms_item\nWHERE\n\tms.name = ms_sch.parent and ms.name = ms_item.parent and ms.docstatus = 1\nORDER BY\n\tms_sch.scheduled_date asc, ms_sch.item_code asc",
|
||||
"ref_doctype": "Maintenance Schedule",
|
||||
"report_name": "Maintenance Schedules",
|
||||
"report_type": "Query Report"
|
||||
|
||||
Reference in New Issue
Block a user