mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-20 21:49:18 +00:00
Merge branch 'master' of https://github.com/webnotes/erpnext
This commit is contained in:
@@ -160,13 +160,13 @@ class DocType:
|
|||||||
def update_outstanding_amt(self):
|
def update_outstanding_amt(self):
|
||||||
# get final outstanding amt
|
# get final outstanding amt
|
||||||
bal = flt(sql("""select sum(debit) - sum(credit) from `tabGL Entry`
|
bal = flt(sql("""select sum(debit) - sum(credit) from `tabGL Entry`
|
||||||
where against_voucher=%s and against_voucher_type=%s
|
where against_voucher=%s and against_voucher_type=%s and account = %s
|
||||||
and ifnull(is_cancelled,'No') = 'No'""",
|
and ifnull(is_cancelled,'No') = 'No'""", (self.doc.against_voucher,
|
||||||
(self.doc.against_voucher, self.doc.against_voucher_type))[0][0] or 0.0)
|
self.doc.against_voucher_type, self.doc.account))[0][0] or 0.0)
|
||||||
|
|
||||||
if self.doc.against_voucher_type == 'Purchase Invoice':
|
if self.doc.against_voucher_type == 'Purchase Invoice':
|
||||||
bal = -bal
|
bal = -bal
|
||||||
|
|
||||||
elif self.doc.against_voucher_type == "Journal Voucher":
|
elif self.doc.against_voucher_type == "Journal Voucher":
|
||||||
against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
|
against_voucher_amount = flt(webnotes.conn.sql("""select sum(debit) - sum(credit)
|
||||||
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
|
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
|
||||||
|
|||||||
@@ -466,9 +466,8 @@ class DocType(BuyingController):
|
|||||||
# expense will be booked in sales invoice
|
# expense will be booked in sales invoice
|
||||||
stock_item_and_auto_inventory_accounting = True
|
stock_item_and_auto_inventory_accounting = True
|
||||||
|
|
||||||
valuation_amt = (flt(item.amount, self.precision.item.amount) +
|
valuation_amt = (flt(item.amount) + flt(item.item_tax_amount) +
|
||||||
flt(item.item_tax_amount, self.precision.item.item_tax_amount) +
|
flt(item.rm_supp_cost))
|
||||||
flt(item.rm_supp_cost, self.precision.item.rm_supp_cost))
|
|
||||||
|
|
||||||
gl_entries.append(
|
gl_entries.append(
|
||||||
self.get_gl_dict({
|
self.get_gl_dict({
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
if (wn.model.can_read(this.ctype) !== -1) {
|
if (wn.model.can_read(this.ctype) !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.open();">Edit</a>');
|
node_links.push('<a onclick="erpnext.account_chart.open();">Edit</a>');
|
||||||
}
|
}
|
||||||
if (data.expandable) {
|
if (data.expandable && wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
||||||
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
||||||
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
|
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
|
||||||
|
|||||||
@@ -127,16 +127,6 @@ wn.module_page["Accounts"] = [
|
|||||||
right: true,
|
right: true,
|
||||||
icon: "icon-table",
|
icon: "icon-table",
|
||||||
items: [
|
items: [
|
||||||
{
|
|
||||||
"label":wn._("Customer Account Head"),
|
|
||||||
route: "query-report/Customer Account Head",
|
|
||||||
doctype: "Account"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label":wn._("Supplier Account Head"),
|
|
||||||
route: "query-report/Supplier Account Head",
|
|
||||||
doctype: "Account"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"label":wn._("General Ledger"),
|
"label":wn._("General Ledger"),
|
||||||
page: "general-ledger"
|
page: "general-ledger"
|
||||||
@@ -247,6 +237,11 @@ wn.module_page["Accounts"] = [
|
|||||||
route: "query-report/Customer Account Head",
|
route: "query-report/Customer Account Head",
|
||||||
doctype: "Account"
|
doctype: "Account"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"label":wn._("Supplier Account Head"),
|
||||||
|
route: "query-report/Supplier Account Head",
|
||||||
|
doctype: "Account"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label":wn._("Item-wise Sales Register"),
|
"label":wn._("Item-wise Sales Register"),
|
||||||
route: "query-report/Item-wise Sales Register",
|
route: "query-report/Item-wise Sales Register",
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ def upload():
|
|||||||
if not company_abbr:
|
if not company_abbr:
|
||||||
webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1)
|
webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1)
|
||||||
|
|
||||||
data, start_idx = get_data(rows, company_abbr)
|
data, start_idx = get_data(rows, company_abbr, rows[0][0])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
|
err_msg = webnotes.message_log and "<br>".join(webnotes.message_log) or cstr(e)
|
||||||
messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
|
messages.append("""<p style='color: red'>%s</p>""" % (err_msg or "No message"))
|
||||||
@@ -213,10 +213,11 @@ def get_common_values(rows):
|
|||||||
|
|
||||||
return common_values
|
return common_values
|
||||||
|
|
||||||
def get_data(rows, company_abbr):
|
def get_data(rows, company_abbr, import_type):
|
||||||
start_row = 0
|
start_row = 0
|
||||||
data = []
|
data = []
|
||||||
start_row_idx = 0
|
start_row_idx = 0
|
||||||
|
accounts = None
|
||||||
for i in xrange(len(rows)):
|
for i in xrange(len(rows)):
|
||||||
r = rows[i]
|
r = rows[i]
|
||||||
if r[0]:
|
if r[0]:
|
||||||
@@ -257,17 +258,19 @@ def get_data(rows, company_abbr):
|
|||||||
|
|
||||||
columns = [c.replace(" ", "_").lower() for c in rows[i+1]
|
columns = [c.replace(" ", "_").lower() for c in rows[i+1]
|
||||||
if not c.endswith(" - " + company_abbr)]
|
if not c.endswith(" - " + company_abbr)]
|
||||||
accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]
|
|
||||||
|
if import_type == "Voucher Import: Multiple Accounts":
|
||||||
|
accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]
|
||||||
|
|
||||||
if not accounts:
|
if not accounts:
|
||||||
webnotes.msgprint(_("""No Account found in csv file,
|
webnotes.msgprint(_("""No Account found in csv file,
|
||||||
May be company abbreviation is not correct"""), raise_exception=1)
|
May be company abbreviation is not correct"""), raise_exception=1)
|
||||||
|
|
||||||
if accounts and (len(columns) != rows[i+1].index(accounts[0])):
|
if accounts and (len(columns) != rows[i+1].index(accounts[0])):
|
||||||
webnotes.msgprint(_("""All account columns should be after \
|
webnotes.msgprint(_("""All account columns should be after \
|
||||||
standard columns and on the right.
|
standard columns and on the right.
|
||||||
If you entered it properly, next probable reason \
|
If you entered it properly, next probable reason \
|
||||||
could be wrong account name.
|
could be wrong account name.
|
||||||
Please rectify it in the file and try again."""), raise_exception=1)
|
Please rectify it in the file and try again."""), raise_exception=1)
|
||||||
|
|
||||||
return data, start_row_idx
|
return data, start_row_idx
|
||||||
@@ -59,7 +59,7 @@ def get_conditions(filters):
|
|||||||
def get_items(filters):
|
def get_items(filters):
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
return webnotes.conn.sql("""select si.name, si.posting_date, si.debit_to, si.project_name,
|
return webnotes.conn.sql("""select si.name, si.posting_date, si.debit_to, si.project_name,
|
||||||
si.customer, si.remarks, si.territory, si_item.item_code, si_item.item_name,
|
si.customer, si.remarks, si.territory, si.company, si_item.item_code, si_item.item_name,
|
||||||
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
|
si_item.item_group, si_item.sales_order, si_item.delivery_note, si_item.income_account,
|
||||||
si_item.qty, si_item.basic_rate, si_item.amount
|
si_item.qty, si_item.basic_rate, si_item.amount
|
||||||
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
from `tabSales Invoice` si, `tabSales Invoice Item` si_item
|
||||||
|
|||||||
@@ -125,7 +125,6 @@ def add_ac(args=None):
|
|||||||
ac.doc.doctype = "Account"
|
ac.doc.doctype = "Account"
|
||||||
ac.doc.old_parent = ""
|
ac.doc.old_parent = ""
|
||||||
ac.doc.freeze_account = "No"
|
ac.doc.freeze_account = "No"
|
||||||
ac.ignore_permissions = 1
|
|
||||||
ac.insert()
|
ac.insert()
|
||||||
return ac.doc.name
|
return ac.doc.name
|
||||||
|
|
||||||
@@ -138,7 +137,6 @@ def add_cc(args=None):
|
|||||||
cc = webnotes.bean(args)
|
cc = webnotes.bean(args)
|
||||||
cc.doc.doctype = "Cost Center"
|
cc.doc.doctype = "Cost Center"
|
||||||
cc.doc.old_parent = ""
|
cc.doc.old_parent = ""
|
||||||
cc.ignore_permissions = 1
|
|
||||||
cc.insert()
|
cc.insert()
|
||||||
return cc.doc.name
|
return cc.doc.name
|
||||||
|
|
||||||
|
|||||||
@@ -432,6 +432,7 @@ class DocType(BuyingController):
|
|||||||
d.account_head = other['account_head']
|
d.account_head = other['account_head']
|
||||||
d.rate = flt(other['rate'])
|
d.rate = flt(other['rate'])
|
||||||
d.tax_amount = flt(other['tax_amount'])
|
d.tax_amount = flt(other['tax_amount'])
|
||||||
|
d.cost_center = other["cost_center"]
|
||||||
d.idx = idx
|
d.idx = idx
|
||||||
idx += 1
|
idx += 1
|
||||||
return obj.doclist
|
return obj.doclist
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ from webnotes.model.doc import make_autoname
|
|||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
|
|
||||||
from accounts.utils import add_ac
|
|
||||||
from utilities.transaction_base import TransactionBase
|
from utilities.transaction_base import TransactionBase
|
||||||
|
|
||||||
class DocType(TransactionBase):
|
class DocType(TransactionBase):
|
||||||
@@ -71,14 +70,16 @@ class DocType(TransactionBase):
|
|||||||
return g
|
return g
|
||||||
|
|
||||||
def add_account(self, ac, par, abbr):
|
def add_account(self, ac, par, abbr):
|
||||||
ac = add_ac({
|
ac_bean = webnotes.bean({
|
||||||
|
"doctype": "Account",
|
||||||
'account_name':ac,
|
'account_name':ac,
|
||||||
'parent_account':par,
|
'parent_account':par,
|
||||||
'group_or_ledger':'Group',
|
'group_or_ledger':'Group',
|
||||||
'company':self.doc.company,
|
'company':self.doc.company,
|
||||||
'account_type':'',
|
"freeze_account": "No",
|
||||||
'tax_rate':'0'
|
|
||||||
})
|
})
|
||||||
|
ac_bean.ignore_permissions = True
|
||||||
|
ac_bean.insert()
|
||||||
|
|
||||||
msgprint(_("Created Group ") + ac)
|
msgprint(_("Created Group ") + ac)
|
||||||
|
|
||||||
@@ -109,8 +110,8 @@ class DocType(TransactionBase):
|
|||||||
parent_account = self.get_parent_account(abbr)
|
parent_account = self.get_parent_account(abbr)
|
||||||
|
|
||||||
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
|
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
|
||||||
|
ac_bean = webnotes.bean({
|
||||||
ac = add_ac({
|
"doctype": "Account",
|
||||||
'account_name': self.doc.name,
|
'account_name': self.doc.name,
|
||||||
'parent_account': parent_account,
|
'parent_account': parent_account,
|
||||||
'group_or_ledger':'Ledger',
|
'group_or_ledger':'Ledger',
|
||||||
@@ -119,8 +120,12 @@ class DocType(TransactionBase):
|
|||||||
'tax_rate': '0',
|
'tax_rate': '0',
|
||||||
'master_type': 'Supplier',
|
'master_type': 'Supplier',
|
||||||
'master_name': self.doc.name,
|
'master_name': self.doc.name,
|
||||||
|
"freeze_account": "No"
|
||||||
})
|
})
|
||||||
msgprint(_("Created Account Head: ") + ac)
|
ac_bean.ignore_permissions = True
|
||||||
|
ac_bean.insert()
|
||||||
|
|
||||||
|
msgprint(_("Created Account Head: ") + ac_bean.doc.name)
|
||||||
else:
|
else:
|
||||||
self.check_parent_account(parent_account, abbr)
|
self.check_parent_account(parent_account, abbr)
|
||||||
else :
|
else :
|
||||||
|
|||||||
19
patches/june_2013/p04_fix_event_for_lead_oppty_project.py
Normal file
19
patches/june_2013/p04_fix_event_for_lead_oppty_project.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import webnotes
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
# delete orphaned Event User
|
||||||
|
webnotes.conn.sql("""delete from `tabEvent User`
|
||||||
|
where not exists(select name from `tabEvent` where `tabEvent`.name = `tabEvent User`.parent)""")
|
||||||
|
|
||||||
|
for dt in ["Lead", "Opportunity", "Project"]:
|
||||||
|
for ref_name in webnotes.conn.sql_list("""select ref_name
|
||||||
|
from `tabEvent` where ref_type=%s and ifnull(starts_on, '')='' """, dt):
|
||||||
|
if webnotes.conn.exists(dt, ref_name):
|
||||||
|
if dt in ["Lead", "Opportunity"]:
|
||||||
|
webnotes.get_obj(dt, ref_name).add_calendar_event(force=True)
|
||||||
|
else:
|
||||||
|
webnotes.get_obj(dt, ref_name).add_calendar_event()
|
||||||
|
else:
|
||||||
|
# remove events where ref doc doesn't exist
|
||||||
|
webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
|
||||||
|
where ref_type=%s and ref_name=%s""", (dt, ref_name)))
|
||||||
@@ -254,4 +254,5 @@ patch_list = [
|
|||||||
"patches.may_2013.p05_update_cancelled_gl_entries",
|
"patches.may_2013.p05_update_cancelled_gl_entries",
|
||||||
"patches.june_2013.p01_update_bom_exploded_items",
|
"patches.june_2013.p01_update_bom_exploded_items",
|
||||||
"execute:webnotes.delete_doc('DocType', 'System Console')",
|
"execute:webnotes.delete_doc('DocType', 'System Console')",
|
||||||
|
"patches.june_2013.p04_fix_event_for_lead_oppty_project",
|
||||||
]
|
]
|
||||||
@@ -18,24 +18,17 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import flt, getdate
|
from webnotes.utils import flt, getdate
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
from webnotes.model.bean import copy_doclist
|
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self, doc, doclist=[]):
|
def __init__(self, doc, doclist=None):
|
||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
self.doclist = doclist
|
||||||
|
|
||||||
# Get Customer Details along with its primary contact details
|
# Get Customer Details along with its primary contact details
|
||||||
# ==============================================================
|
# ==============================================================
|
||||||
def get_customer_details(self):
|
def get_customer_details(self):
|
||||||
details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
|
details =webnotes.conn.sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
|
||||||
if details:
|
if details:
|
||||||
ret = {
|
ret = {
|
||||||
'customer_address' : details and details[0]['address'] or '',
|
'customer_address' : details and details[0]['address'] or '',
|
||||||
@@ -44,7 +37,7 @@ class DocType:
|
|||||||
'customer_name' : details and details[0]['customer_name'] or ''
|
'customer_name' : details and details[0]['customer_name'] or ''
|
||||||
}
|
}
|
||||||
#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
|
#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
|
||||||
contact_det = sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
|
contact_det = webnotes.conn.sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
|
||||||
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
|
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
|
||||||
ret['contact_no'] = contact_det and contact_det[0]['phone'] or ''
|
ret['contact_no'] = contact_det and contact_det[0]['phone'] or ''
|
||||||
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
|
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
|
||||||
@@ -52,21 +45,7 @@ class DocType:
|
|||||||
else:
|
else:
|
||||||
msgprint("Customer : %s does not exist in system." % (self.doc.customer))
|
msgprint("Customer : %s does not exist in system." % (self.doc.customer))
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
# Get customer's contact person details
|
|
||||||
# ==============================================================
|
|
||||||
def get_contact_details(self):
|
|
||||||
contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1)
|
|
||||||
if contact:
|
|
||||||
ret = {
|
|
||||||
'contact_no' : contact and contact[0]['contact_no'] or '',
|
|
||||||
'email_id' : contact and contact[0]['email_id'] or ''
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
else:
|
|
||||||
msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person))
|
|
||||||
raise Exception
|
|
||||||
|
|
||||||
#calculate gross profit
|
#calculate gross profit
|
||||||
#=============================================
|
#=============================================
|
||||||
def get_gross_profit(self):
|
def get_gross_profit(self):
|
||||||
@@ -86,20 +65,30 @@ class DocType:
|
|||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
# update milestones
|
self.add_calendar_event()
|
||||||
webnotes.conn.sql("""delete from tabEvent where ref_type='Project' and ref_name=%s""",
|
|
||||||
self.doc.name)
|
|
||||||
for d in self.doclist:
|
|
||||||
if d.doctype=='Project Milestone' and d.docstatus!=2:
|
|
||||||
self.add_calendar_event(d.milestone, d.milestone_date)
|
|
||||||
|
|
||||||
def add_calendar_event(self, milestone, date):
|
def add_calendar_event(self):
|
||||||
""" Add calendar event for task in calendar of Allocated person"""
|
# delete any earlier event for this project
|
||||||
event = Document('Event')
|
self.delete_events()
|
||||||
event.description = milestone + ' for ' + self.doc.name
|
|
||||||
event.event_date = date
|
# add events
|
||||||
event.event_hour = '10:00'
|
for milestone in self.doclist.get({"parentfield": "project_milestones"}):
|
||||||
event.event_type = 'Public'
|
if milestone.milestone_date:
|
||||||
event.ref_type = 'Project'
|
description = (milestone.milestone or "Milestone") + " for " + self.doc.name
|
||||||
event.ref_name = self.doc.name
|
webnotes.bean({
|
||||||
event.save(1)
|
"doctype": "Event",
|
||||||
|
"owner": self.doc.owner,
|
||||||
|
"subject": description,
|
||||||
|
"description": description,
|
||||||
|
"starts_on": milestone.milestone_date + " 10:00:00",
|
||||||
|
"event_type": "Private",
|
||||||
|
"ref_type": self.doc.doctype,
|
||||||
|
"ref_name": self.doc.name
|
||||||
|
}).insert()
|
||||||
|
|
||||||
|
def on_trash(self):
|
||||||
|
self.delete_events()
|
||||||
|
|
||||||
|
def delete_events(self):
|
||||||
|
webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
|
||||||
|
where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
|
||||||
@@ -115,18 +115,20 @@ class DocType(TransactionBase):
|
|||||||
if not webnotes.conn.exists("Account", (self.doc.name + " - " + abbr)):
|
if not webnotes.conn.exists("Account", (self.doc.name + " - " + abbr)):
|
||||||
parent_account = self.get_receivables_group()
|
parent_account = self.get_receivables_group()
|
||||||
# create
|
# create
|
||||||
from accounts.utils import add_ac
|
ac_bean = webnotes.bean({
|
||||||
ac = add_ac({
|
"doctype": "Account",
|
||||||
'account_name':self.doc.name,
|
'account_name': self.doc.name,
|
||||||
'parent_account': parent_account,
|
'parent_account': parent_account,
|
||||||
'group_or_ledger':'Ledger',
|
'group_or_ledger':'Ledger',
|
||||||
'company':self.doc.company,
|
'company':self.doc.company,
|
||||||
'account_type':'',
|
|
||||||
'tax_rate':'0',
|
|
||||||
'master_type':'Customer',
|
'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 :
|
else :
|
||||||
msgprint("Please Select Company under which you want to create account head")
|
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,
|
"docstatus": 0,
|
||||||
"modified": "2013-01-29 16:28:03",
|
"modified": "2013-06-11 14:27:57",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -270,7 +270,7 @@
|
|||||||
"label": "Credit Days",
|
"label": "Credit Days",
|
||||||
"oldfieldname": "credit_days",
|
"oldfieldname": "credit_days",
|
||||||
"oldfieldtype": "Int",
|
"oldfieldtype": "Int",
|
||||||
"permlevel": 2
|
"permlevel": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@@ -280,7 +280,7 @@
|
|||||||
"oldfieldname": "credit_limit",
|
"oldfieldname": "credit_limit",
|
||||||
"oldfieldtype": "Currency",
|
"oldfieldtype": "Currency",
|
||||||
"options": "Company:company:default_currency",
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 2
|
"permlevel": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
"permlevel": 2,
|
"permlevel": 1,
|
||||||
"role": "Sales User"
|
"role": "Sales User"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -355,7 +355,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
"permlevel": 2,
|
"permlevel": 1,
|
||||||
"role": "Sales Master Manager",
|
"role": "Sales Master Manager",
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes import _
|
from webnotes import _
|
||||||
from webnotes.utils import cstr, validate_email_add
|
from webnotes.utils import cstr, validate_email_add, cint
|
||||||
from webnotes.model.doc import Document, addchild
|
|
||||||
from webnotes import session, msgprint
|
from webnotes import session, msgprint
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
sql = webnotes.conn.sql
|
||||||
@@ -30,6 +29,13 @@ class DocType(SellingController):
|
|||||||
self.doc = doc
|
self.doc = doc
|
||||||
self.doclist = doclist
|
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):
|
def onload(self):
|
||||||
self.add_communication_list()
|
self.add_communication_list()
|
||||||
|
|
||||||
@@ -55,12 +61,18 @@ class DocType(SellingController):
|
|||||||
msgprint('Please enter valid email id.')
|
msgprint('Please enter valid email id.')
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
if self.doc.contact_date:
|
|
||||||
self.add_calendar_event()
|
|
||||||
|
|
||||||
self.check_email_id_is_unique()
|
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):
|
def check_email_id_is_unique(self):
|
||||||
if self.doc.email_id:
|
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]
|
items = [e[0] for e in email_list if e[0]!=self.doc.name]
|
||||||
webnotes.msgprint(_("""Email Id must be unique, already exists for: """) + \
|
webnotes.msgprint(_("""Email Id must be unique, already exists for: """) + \
|
||||||
", ".join(items), raise_exception=True)
|
", ".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):
|
def get_sender(self, comm):
|
||||||
return webnotes.conn.get_value('Sales Email Settings',None,'email_id')
|
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 tabCommunication set lead=null where lead=%s""", self.doc.name)
|
||||||
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
webnotes.conn.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
||||||
self.doc.name)
|
self.doc.name)
|
||||||
|
|
||||||
|
self.delete_events()
|
||||||
@@ -17,9 +17,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, cstr, getdate
|
from webnotes.utils import add_days, cstr, getdate, cint
|
||||||
from webnotes.model import db_exists
|
|
||||||
from webnotes.model.doc import Document, addchild
|
|
||||||
from webnotes.model.bean import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
|
|
||||||
@@ -34,6 +32,13 @@ class DocType(TransactionBase):
|
|||||||
self.fname = 'enq_details'
|
self.fname = 'enq_details'
|
||||||
self.tname = 'Opportunity Item'
|
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):
|
def onload(self):
|
||||||
self.add_communication_list()
|
self.add_communication_list()
|
||||||
|
|
||||||
@@ -84,48 +89,34 @@ class DocType(TransactionBase):
|
|||||||
def on_update(self):
|
def on_update(self):
|
||||||
# Add to calendar
|
# Add to calendar
|
||||||
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
|
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, 'contact_date_ref',self.doc.contact_date)
|
||||||
webnotes.conn.set(self.doc, 'status', 'Draft')
|
|
||||||
|
|
||||||
def add_calendar_event(self):
|
self.add_calendar_event()
|
||||||
desc=''
|
|
||||||
user_lst =[]
|
def add_calendar_event(self, opts=None, force=False):
|
||||||
|
if not opts:
|
||||||
|
opts = webnotes._dict()
|
||||||
|
|
||||||
|
opts.description = ""
|
||||||
|
|
||||||
if self.doc.customer:
|
if self.doc.customer:
|
||||||
if self.doc.contact_person:
|
if self.doc.contact_person:
|
||||||
desc = 'Contact '+cstr(self.doc.contact_person)
|
opts.description = 'Contact '+cstr(self.doc.contact_person)
|
||||||
else:
|
else:
|
||||||
desc = 'Contact customer '+cstr(self.doc.customer)
|
opts.description = 'Contact customer '+cstr(self.doc.customer)
|
||||||
elif self.doc.lead:
|
elif self.doc.lead:
|
||||||
if self.doc.contact_display:
|
if self.doc.contact_display:
|
||||||
desc = 'Contact '+cstr(self.doc.contact_display)
|
opts.description = 'Contact '+cstr(self.doc.contact_display)
|
||||||
else:
|
else:
|
||||||
desc = 'Contact lead '+cstr(self.doc.lead)
|
opts.description = 'Contact lead '+cstr(self.doc.lead)
|
||||||
desc = desc+ '. By : ' + cstr(self.doc.contact_by)
|
|
||||||
|
opts.subject = opts.description
|
||||||
|
opts.description += '. By : ' + cstr(self.doc.contact_by)
|
||||||
|
|
||||||
if self.doc.to_discuss:
|
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')
|
super(DocType, self).add_calendar_event(opts, force)
|
||||||
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)
|
|
||||||
|
|
||||||
def set_last_contact_date(self):
|
def set_last_contact_date(self):
|
||||||
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
|
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.set_last_contact_date()
|
||||||
self.validate_item_details()
|
self.validate_item_details()
|
||||||
self.validate_lead_cust()
|
self.validate_lead_cust()
|
||||||
|
|
||||||
|
if not self.doc.status:
|
||||||
|
self.doc.status = "Draft"
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
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, 'status', 'Opportunity Lost')
|
||||||
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
|
webnotes.conn.set(self.doc, 'order_lost_reason', arg)
|
||||||
return 'true'
|
return 'true'
|
||||||
|
|
||||||
|
def on_trash(self):
|
||||||
|
self.delete_events()
|
||||||
@@ -222,7 +222,6 @@ class DocType:
|
|||||||
# Create default cost center
|
# Create default cost center
|
||||||
# ---------------------------------------------------
|
# ---------------------------------------------------
|
||||||
def create_default_cost_center(self):
|
def create_default_cost_center(self):
|
||||||
from accounts.utils import add_cc
|
|
||||||
cc_list = [
|
cc_list = [
|
||||||
{
|
{
|
||||||
'cost_center_name':'Root',
|
'cost_center_name':'Root',
|
||||||
@@ -244,7 +243,10 @@ class DocType:
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
for cc in cc_list:
|
for cc in cc_list:
|
||||||
add_cc(cc)
|
cc.update({"doctype": "Cost Center"})
|
||||||
|
cc_bean = webnotes.bean(cc)
|
||||||
|
cc_bean.ignore_permissions = True
|
||||||
|
cc_bean.insert()
|
||||||
|
|
||||||
webnotes.conn.set_value("Company", self.doc.name, "cost_center",
|
webnotes.conn.set_value("Company", self.doc.name, "cost_center",
|
||||||
"Default CC Ledger - " + self.doc.abbr)
|
"Default CC Ledger - " + self.doc.abbr)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from __future__ import unicode_literals
|
|||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
from webnotes.utils import add_days, cstr, getdate
|
from webnotes.utils import add_days, cstr, getdate
|
||||||
from webnotes.model.doc import Document, addchild
|
from webnotes.model.doc import addchild
|
||||||
from webnotes.model.bean import getlist
|
from webnotes.model.bean import getlist
|
||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
from webnotes import msgprint
|
from webnotes import msgprint
|
||||||
@@ -100,23 +100,21 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
for key in scheduled_date:
|
for key in scheduled_date:
|
||||||
if email_map[d.incharge_name]:
|
if email_map[d.incharge_name]:
|
||||||
self.add_calender_event(key["scheduled_date"],email_map[d.incharge_name],d.item_code)
|
description = "Reference: %s, Item Code: %s and Customer: %s" % \
|
||||||
|
(self.doc.name, d.item_code, self.doc.customer)
|
||||||
|
webnotes.bean({
|
||||||
|
"doctype": "Event",
|
||||||
|
"owner": email_map[d.incharge_name] or self.doc.owner,
|
||||||
|
"subject": description,
|
||||||
|
"description": description,
|
||||||
|
"starts_on": key["scheduled_date"] + " 10:00:00",
|
||||||
|
"event_type": "Private",
|
||||||
|
"ref_type": self.doc.doctype,
|
||||||
|
"ref_name": self.doc.name
|
||||||
|
}).insert()
|
||||||
|
|
||||||
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
webnotes.conn.set(self.doc, 'status', 'Submitted')
|
||||||
|
|
||||||
|
|
||||||
def add_calender_event(self,scheduled_date,incharge_email,item_code):
|
|
||||||
""" Add calendar event for Maintenece Schedule in calendar of Allocated person"""
|
|
||||||
event = Document('Event')
|
|
||||||
event.owner = incharge_email
|
|
||||||
event.description = "Reference:%s, Item Code:%s and Customer: %s" %(self.doc.name, item_code, self.doc.customer)
|
|
||||||
event.event_date = scheduled_date
|
|
||||||
event.event_hour = '10:00'
|
|
||||||
event.event_type = 'Private'
|
|
||||||
event.ref_type = 'Maintenance Schedule'
|
|
||||||
event.ref_name = self.doc.name
|
|
||||||
event.save(1)
|
|
||||||
|
|
||||||
|
|
||||||
#get schedule dates
|
#get schedule dates
|
||||||
#----------------------
|
#----------------------
|
||||||
def create_schedule_list(self, start_date, end_date, no_of_visit):
|
def create_schedule_list(self, start_date, end_date, no_of_visit):
|
||||||
@@ -329,8 +327,13 @@ class DocType(TransactionBase):
|
|||||||
if d.serial_no:
|
if d.serial_no:
|
||||||
self.update_amc_date(d.serial_no, '')
|
self.update_amc_date(d.serial_no, '')
|
||||||
webnotes.conn.set(self.doc, 'status', 'Cancelled')
|
webnotes.conn.set(self.doc, 'status', 'Cancelled')
|
||||||
sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
|
self.delete_events()
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
sql("delete from `tabEvent` where ref_type='Maintenance Schedule' and ref_name='%s' " %(self.doc.name))
|
self.delete_events()
|
||||||
|
|
||||||
|
def delete_events(self):
|
||||||
|
webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
|
||||||
|
where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -268,4 +268,38 @@ class TransactionBase(DocListController):
|
|||||||
def validate_posting_time(self):
|
def validate_posting_time(self):
|
||||||
if not self.doc.posting_time:
|
if not self.doc.posting_time:
|
||||||
self.doc.posting_time = now_datetime().strftime('%H:%M:%S')
|
self.doc.posting_time = now_datetime().strftime('%H:%M:%S')
|
||||||
|
|
||||||
|
def add_calendar_event(self, opts, force=False):
|
||||||
|
if self.doc.contact_by != cstr(self._prev.contact_by) or \
|
||||||
|
self.doc.contact_date != cstr(self._prev.contact_date) or force:
|
||||||
|
|
||||||
|
self.delete_events()
|
||||||
|
self._add_calendar_event(opts)
|
||||||
|
|
||||||
|
def delete_events(self):
|
||||||
|
webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent`
|
||||||
|
where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)))
|
||||||
|
|
||||||
|
def _add_calendar_event(self, opts):
|
||||||
|
opts = webnotes._dict(opts)
|
||||||
|
|
||||||
|
if self.doc.contact_date:
|
||||||
|
event_doclist = [{
|
||||||
|
"doctype": "Event",
|
||||||
|
"owner": opts.owner or self.doc.owner,
|
||||||
|
"subject": opts.subject,
|
||||||
|
"description": opts.description,
|
||||||
|
"starts_on": self.doc.contact_date + " 10:00:00",
|
||||||
|
"event_type": "Private",
|
||||||
|
"ref_type": self.doc.doctype,
|
||||||
|
"ref_name": self.doc.name
|
||||||
|
}]
|
||||||
|
|
||||||
|
if webnotes.conn.exists("Profile", self.doc.contact_by):
|
||||||
|
event_doclist.append({
|
||||||
|
"doctype": "Event User",
|
||||||
|
"parentfield": "event_individuals",
|
||||||
|
"person": self.doc.contact_by
|
||||||
|
})
|
||||||
|
|
||||||
|
webnotes.bean(event_doclist).insert()
|
||||||
|
|||||||
Reference in New Issue
Block a user