mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 19:49:18 +00:00
Merge branch 'master' of https://github.com/webnotes/erpnext
This commit is contained in:
@@ -115,18 +115,20 @@ class DocType(TransactionBase):
|
||||
if not webnotes.conn.exists("Account", (self.doc.name + " - " + abbr)):
|
||||
parent_account = self.get_receivables_group()
|
||||
# create
|
||||
from accounts.utils import add_ac
|
||||
ac = add_ac({
|
||||
'account_name':self.doc.name,
|
||||
ac_bean = webnotes.bean({
|
||||
"doctype": "Account",
|
||||
'account_name': self.doc.name,
|
||||
'parent_account': parent_account,
|
||||
'group_or_ledger':'Ledger',
|
||||
'company':self.doc.company,
|
||||
'account_type':'',
|
||||
'tax_rate':'0',
|
||||
'master_type':'Customer',
|
||||
'master_name':self.doc.name
|
||||
'master_name':self.doc.name,
|
||||
"freeze_account": "No"
|
||||
})
|
||||
msgprint("Account Head: %s created" % ac)
|
||||
ac_bean.ignore_permissions = True
|
||||
ac_bean.insert()
|
||||
|
||||
msgprint("Account Head: %s created" % ac_bean.doc.name)
|
||||
else :
|
||||
msgprint("Please Select Company under which you want to create account head")
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-23 19:57:18",
|
||||
"creation": "2013-06-11 14:26:44",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-29 16:28:03",
|
||||
"modified": "2013-06-11 14:27:57",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -270,7 +270,7 @@
|
||||
"label": "Credit Days",
|
||||
"oldfieldname": "credit_days",
|
||||
"oldfieldtype": "Int",
|
||||
"permlevel": 2
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -280,7 +280,7 @@
|
||||
"oldfieldname": "credit_limit",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"permlevel": 2
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -339,7 +339,7 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 2,
|
||||
"permlevel": 1,
|
||||
"role": "Sales User"
|
||||
},
|
||||
{
|
||||
@@ -355,7 +355,7 @@
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 2,
|
||||
"permlevel": 1,
|
||||
"role": "Sales Master Manager",
|
||||
"write": 1
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _
|
||||
from webnotes.utils import cstr, validate_email_add
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.utils import cstr, validate_email_add, cint
|
||||
from webnotes import session, msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
@@ -30,6 +29,13 @@ class DocType(SellingController):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
self._prev = webnotes._dict({
|
||||
"contact_date": webnotes.conn.get_value("Lead", self.doc.name, "contact_date") if \
|
||||
(not cint(self.doc.fields.get("__islocal"))) else None,
|
||||
"contact_by": webnotes.conn.get_value("Lead", self.doc.name, "contact_by") if \
|
||||
(not cint(self.doc.fields.get("__islocal"))) else None,
|
||||
})
|
||||
|
||||
def onload(self):
|
||||
self.add_communication_list()
|
||||
|
||||
@@ -55,12 +61,18 @@ class DocType(SellingController):
|
||||
msgprint('Please enter valid email id.')
|
||||
raise Exception
|
||||
|
||||
|
||||
def on_update(self):
|
||||
if self.doc.contact_date:
|
||||
self.add_calendar_event()
|
||||
|
||||
self.check_email_id_is_unique()
|
||||
self.add_calendar_event()
|
||||
|
||||
def add_calendar_event(self, opts=None, force=False):
|
||||
super(DocType, self).add_calendar_event({
|
||||
"owner": self.doc.lead_owner,
|
||||
"subject": ('Contact ' + cstr(self.doc.lead_name)),
|
||||
"description": ('Contact ' + cstr(self.doc.lead_name)) + \
|
||||
(self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \
|
||||
(self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '')
|
||||
}, force)
|
||||
|
||||
def check_email_id_is_unique(self):
|
||||
if self.doc.email_id:
|
||||
@@ -71,27 +83,6 @@ class DocType(SellingController):
|
||||
items = [e[0] for e in email_list if e[0]!=self.doc.name]
|
||||
webnotes.msgprint(_("""Email Id must be unique, already exists for: """) + \
|
||||
", ".join(items), raise_exception=True)
|
||||
|
||||
def add_calendar_event(self):
|
||||
# delete any earlier event by this lead
|
||||
sql("delete from tabEvent where ref_type='Lead' and ref_name=%s", self.doc.name)
|
||||
|
||||
# create new event
|
||||
ev = Document('Event')
|
||||
ev.owner = self.doc.lead_owner
|
||||
ev.description = ('Contact ' + cstr(self.doc.lead_name)) + \
|
||||
(self.doc.contact_by and ('. By : ' + cstr(self.doc.contact_by)) or '') + \
|
||||
(self.doc.remark and ('.To Discuss : ' + cstr(self.doc.remark)) or '')
|
||||
ev.event_date = self.doc.contact_date
|
||||
ev.event_hour = '10:00'
|
||||
ev.event_type = 'Private'
|
||||
ev.ref_type = 'Lead'
|
||||
ev.ref_name = self.doc.name
|
||||
ev.save(1)
|
||||
|
||||
event_user = addchild(ev, 'event_individuals', 'Event User')
|
||||
event_user.person = self.doc.contact_by
|
||||
event_user.save()
|
||||
|
||||
def get_sender(self, comm):
|
||||
return webnotes.conn.get_value('Sales Email Settings',None,'email_id')
|
||||
@@ -100,3 +91,5 @@ class DocType(SellingController):
|
||||
webnotes.conn.sql("""update tabCommunication set lead=null where lead=%s""", self.doc.name)
|
||||
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
||||
self.doc.name)
|
||||
|
||||
self.delete_events()
|
||||
@@ -17,9 +17,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, cstr, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild
|
||||
from webnotes.utils import add_days, cstr, getdate, cint
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes import msgprint
|
||||
|
||||
@@ -34,6 +32,13 @@ class DocType(TransactionBase):
|
||||
self.fname = 'enq_details'
|
||||
self.tname = 'Opportunity Item'
|
||||
|
||||
self._prev = webnotes._dict({
|
||||
"contact_date": webnotes.conn.get_value("Opportunity", self.doc.name, "contact_date") if \
|
||||
(not cint(self.doc.fields.get("__islocal"))) else None,
|
||||
"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()
|
||||
|
||||
@@ -84,48 +89,34 @@ class DocType(TransactionBase):
|
||||
def on_update(self):
|
||||
# Add to calendar
|
||||
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
|
||||
if self.doc.contact_by:
|
||||
self.add_calendar_event()
|
||||
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=''
|
||||
user_lst =[]
|
||||
self.add_calendar_event()
|
||||
|
||||
def add_calendar_event(self, opts=None, force=False):
|
||||
if not opts:
|
||||
opts = webnotes._dict()
|
||||
|
||||
opts.description = ""
|
||||
|
||||
if self.doc.customer:
|
||||
if self.doc.contact_person:
|
||||
desc = 'Contact '+cstr(self.doc.contact_person)
|
||||
opts.description = 'Contact '+cstr(self.doc.contact_person)
|
||||
else:
|
||||
desc = 'Contact customer '+cstr(self.doc.customer)
|
||||
opts.description = 'Contact customer '+cstr(self.doc.customer)
|
||||
elif self.doc.lead:
|
||||
if self.doc.contact_display:
|
||||
desc = 'Contact '+cstr(self.doc.contact_display)
|
||||
opts.description = 'Contact '+cstr(self.doc.contact_display)
|
||||
else:
|
||||
desc = 'Contact lead '+cstr(self.doc.lead)
|
||||
desc = desc+ '. By : ' + cstr(self.doc.contact_by)
|
||||
opts.description = 'Contact lead '+cstr(self.doc.lead)
|
||||
|
||||
opts.subject = opts.description
|
||||
opts.description += '. By : ' + cstr(self.doc.contact_by)
|
||||
|
||||
if self.doc.to_discuss:
|
||||
desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
|
||||
opts.description += ' To Discuss : ' + cstr(self.doc.to_discuss)
|
||||
|
||||
ev = Document('Event')
|
||||
ev.description = desc
|
||||
ev.event_date = self.doc.contact_date
|
||||
ev.event_hour = '10:00'
|
||||
ev.event_type = 'Private'
|
||||
ev.ref_type = 'Opportunity'
|
||||
ev.ref_name = self.doc.name
|
||||
ev.save(1)
|
||||
|
||||
user_lst.append(self.doc.owner)
|
||||
|
||||
chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
|
||||
if chk:
|
||||
user_lst.append(chk[0][0])
|
||||
|
||||
for d in user_lst:
|
||||
ch = addchild(ev, 'event_individuals', 'Event User')
|
||||
ch.person = d
|
||||
ch.save(1)
|
||||
super(DocType, self).add_calendar_event(opts, force)
|
||||
|
||||
def set_last_contact_date(self):
|
||||
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
|
||||
@@ -159,6 +150,9 @@ class DocType(TransactionBase):
|
||||
self.set_last_contact_date()
|
||||
self.validate_item_details()
|
||||
self.validate_lead_cust()
|
||||
|
||||
if not self.doc.status:
|
||||
self.doc.status = "Draft"
|
||||
|
||||
def on_submit(self):
|
||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||
@@ -180,3 +174,6 @@ class DocType(TransactionBase):
|
||||
webnotes.conn.set(self.doc, 'status', 'Opportunity Lost')
|
||||
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
|
||||
return 'true'
|
||||
|
||||
def on_trash(self):
|
||||
self.delete_events()
|
||||
Reference in New Issue
Block a user