This commit is contained in:
Anand Doshi 2014-04-01 12:21:06 +05:30
parent f2227d033c
commit dd32d6eb1f
4 changed files with 33 additions and 34 deletions

View File

@ -20,36 +20,36 @@ from frappe import msgprint
feed_dict = {
# Project
'Project': ['[%(status)s]', '#000080'],
'Task': ['[%(status)s] %(subject)s', '#000080'],
'Project': ['[%(status)s]', '#000080'],
'Task': ['[%(status)s] %(subject)s', '#000080'],
# Sales
'Lead': ['%(lead_name)s', '#000080'],
'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
'Lead': ['%(lead_name)s', '#000080'],
'Quotation': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
'Sales Order': ['[%(status)s] To %(customer_name)s worth %(currency)s %(grand_total_export)s', '#4169E1'],
# Purchase
'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
'Supplier': ['%(supplier_name)s, %(supplier_type)s', '#6495ED'],
'Purchase Order': ['[%(status)s] %(name)s To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
# Stock
'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'],
'Delivery Note': ['[%(status)s] To %(customer_name)s', '#4169E1'],
'Purchase Receipt': ['[%(status)s] From %(supplier)s', '#4169E1'],
# Accounts
'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'],
'Purchase Invoice': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
'Sales Invoice':['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'],
'Journal Voucher': ['[%(voucher_type)s] %(name)s', '#4169E1'],
'Purchase Invoice': ['To %(supplier_name)s for %(currency)s %(grand_total_import)s', '#4169E1'],
'Sales Invoice': ['To %(customer_name)s for %(currency)s %(grand_total_export)s', '#4169E1'],
# HR
'Expense Claim': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'],
'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'],
'Leave Transaction':['%(leave_type)s for %(employee)s', '#4169E1'],
'Expense Claim': ['[%(approval_status)s] %(name)s by %(employee_name)s', '#4169E1'],
'Salary Slip': ['%(employee_name)s for %(month)s %(fiscal_year)s', '#4169E1'],
'Leave Transaction': ['%(leave_type)s for %(employee)s', '#4169E1'],
# Support
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
'Maintenance Visit':['To %(customer_name)s', '#4169E1'],
'Support Ticket': ["[%(status)s] %(subject)s", '#000080'],
'Customer Issue': ['[%(status)s] %(description)s by %(customer_name)s', '#000080'],
'Maintenance Visit': ['To %(customer_name)s', '#4169E1'],
'Support Ticket': ["[%(status)s] %(subject)s", '#000080'],
# Website
'Web Page': ['%(title)s', '#000080'],
@ -59,7 +59,7 @@ feed_dict = {
def make_feed(feedtype, doctype, name, owner, subject, color):
"makes a new Feed record"
#msgprint(subject)
from frappe.utils import get_fullname
from frappe.utils import get_fullname
if feedtype in ('Login', 'Comment', 'Assignment'):
# delete old login, comment feed
@ -71,7 +71,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
where doc_type=%s and doc_name=%s
and ifnull(feed_type,'') != 'Comment'""", (doctype, name))
f = frappe.get_doc('Feed')
f = frappe.new_doc('Feed')
f.owner = owner
f.feed_type = feedtype
f.doc_type = doctype
@ -81,16 +81,15 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
f.full_name = get_fullname(owner)
f.save()
def update_feed(bean, method=None):
def update_feed(doc, method=None):
"adds a new feed"
doc = bean.doc
if method in ['on_update', 'on_submit']:
subject, color = feed_dict.get(doc.doctype, [None, None])
if subject:
make_feed('', doc.doctype, doc.name, doc.owner, subject % doc.fields, color)
def make_comment_feed(bean, method):
def make_comment_feed(doc, method):
"""add comment to feed"""
doc = bean.doc
make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
'<i>"' + doc.comment + '"</i>', '#6B24B3')
'<i>"' + doc.comment + '"</i>', '#6B24B3')

View File

@ -18,7 +18,7 @@ def boot_session(bootinfo):
load_country_and_currency(bootinfo)
bootinfo['notification_settings'] = frappe.get_doc("Notification Control",
"Notification Control").get_values()
"Notification Control")
# if no company, show a dialog box to create a new company
bootinfo["customer_count"] = frappe.db.sql("""select count(*) from tabCustomer""")[0][0]

View File

@ -4,14 +4,14 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import nowtime
from frappe.utils.user import get_user_fullname
from erpnext.home import make_feed
def on_session_creation(login_manager):
"""make feed"""
if frappe.session['user'] not in ('Guest'):
# create feed
from frappe.utils import nowtime
from frappe.utils.user import get_user_fullname
make_feed('Login', 'User', login_manager.user, login_manager.user,
'%s logged in at %s' % (get_user_fullname(login_manager.user), nowtime()),
login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D')

View File

@ -257,7 +257,7 @@ def make_purchase_order_based_on_supplier(source_name, target_doc=None):
if target_doc:
if isinstance(target_doc, basestring):
import json
target_doc = frappe.doclist(json.loads(target_doc))
target_doc = frappe.get_doc(json.loads(target_doc))
target_doc = target_doc.get({"parentfield": ["!=", "po_details"]})
material_requests, supplier_items = get_material_requests_based_on_supplier(source_name)