[refactor] [frappe 5.0]

This commit is contained in:
Rushabh Mehta 2014-09-09 16:15:35 +05:30
parent ed37cef32a
commit c0bb453b88
55 changed files with 80 additions and 655 deletions

View File

@ -18,6 +18,9 @@ class JournalVoucher(AccountsController):
self.credit_days_global = -1
self.is_approving_authority = -1
def get_feed(self):
return self.voucher_type
def validate(self):
if not self.is_opening:
self.is_opening='No'

View File

@ -78,7 +78,7 @@ def get_conditions(filters):
conditions.append("voucher_no=%(voucher_no)s")
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
match_conditions = build_match_conditions("GL Entry")
if match_conditions: conditions.append(match_conditions)

View File

@ -7,7 +7,7 @@ import frappe
from frappe.utils import nowdate, cstr, flt, now, getdate, add_months
from frappe import throw, _
from frappe.utils import formatdate
import frappe.widgets.reportview
import frappe.desk.reportview
class FiscalYearError(frappe.ValidationError): pass
class BudgetError(frappe.ValidationError): pass

View File

@ -38,7 +38,7 @@ class QualityInspection(Document):
def item_query(doctype, txt, searchfield, start, page_len, filters):
if filters.get("from"):
from frappe.widgets.reportview import get_match_cond
from frappe.desk.reportview import get_match_cond
filters.update({
"txt": txt,
"mcond": get_match_cond(filters["from"]),

View File

@ -13,6 +13,8 @@ from erpnext.accounts.party import create_party_account
from erpnext.utilities.transaction_base import TransactionBase
class Supplier(TransactionBase):
def get_feed(self):
return self.supplier_name
def autoname(self):
supp_master_name = frappe.defaults.get_global_default('supp_master_name')

View File

@ -7,13 +7,6 @@ def get_data():
"icon": "icon-money",
"type": "module"
},
"Activity": {
"color": "#e67e22",
"icon": "icon-play",
"label": _("Activity"),
"link": "activity",
"type": "page"
},
"Buying": {
"color": "#c0392b",
"icon": "icon-shopping-cart",
@ -30,14 +23,6 @@ def get_data():
"icon": "icon-cogs",
"type": "module"
},
"Notes": {
"color": "#95a5a6",
"doctype": "Note",
"icon": "icon-file-alt",
"label": _("Notes"),
"link": "List/Note",
"type": "list"
},
"POS": {
"color": "#589494",
"icon": "icon-th",

View File

@ -1,5 +1,5 @@
from frappe import _
from frappe.widgets.moduleview import add_setup_section
from frappe.desk.moduleview import add_setup_section
def get_data():
data = [

View File

@ -18,6 +18,10 @@ class BuyingController(StockController):
"other_charges": "templates/print_formats/includes/taxes.html",
}
def get_feed(self):
return _("From {0} | {1} {2}").format(self.supplier_name, self.currency,
self.grand_total_import)
def validate(self):
super(BuyingController, self).validate()
if getattr(self, "supplier", None) and not self.supplier_name:

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.widgets.reportview import get_match_cond
from frappe.desk.reportview import get_match_cond
from frappe.model.db_query import DatabaseQuery
def get_filters_cond(doctype, filters, conditions):
@ -276,7 +276,7 @@ def get_account_list(doctype, txt, searchfield, start, page_len, filters):
if searchfield and txt:
filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt])
return frappe.widgets.reportview.execute("Account", filters = filter_list,
return frappe.desk.reportview.execute("Account", filters = filter_list,
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)

View File

@ -134,7 +134,7 @@ def notify_errors(doc, doctype, customer, owner):
def assign_task_to_owner(doc, doctype, msg, users):
for d in users:
from frappe.widgets.form import assign_to
from frappe.desk.form import assign_to
args = {
'assign_to' : d,
'doctype' : doctype,

View File

@ -18,6 +18,10 @@ class SellingController(StockController):
"other_charges": "templates/print_formats/includes/taxes.html",
}
def get_feed(self):
return _("To {0} | {1} {2}").format(self.customer_name, self.currency,
self.grand_total_export)
def onload(self):
if self.doctype in ("Sales Order", "Delivery Note", "Sales Invoice"):
for item in self.get(self.fname):

View File

@ -1,102 +0,0 @@
# ERPNext - web based ERP (http://erpnext.com)
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
import frappe
from frappe import msgprint
feed_dict = {
# Project
'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'],
# 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'],
# Stock
'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'],
# 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'],
# 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'],
# Website
'Web Page': ['%(title)s', '#000080'],
'Blog': ['%(title)s', '#000080']
}
def make_feed(feedtype, doctype, name, owner, subject, color):
"makes a new Feed record"
#msgprint(subject)
from frappe.utils import get_fullname
if feedtype in ('Login', 'Comment', 'Assignment'):
# delete old login, comment feed
frappe.db.sql("""delete from tabFeed where
datediff(curdate(), creation) > 7 and doc_type in ('Comment', 'Login', 'Assignment')""")
else:
# one feed per item
frappe.db.sql("""delete from tabFeed
where doc_type=%s and doc_name=%s
and ifnull(feed_type,'') != 'Comment'""", (doctype, name))
f = frappe.new_doc('Feed')
f.owner = owner
f.feed_type = feedtype
f.doc_type = doctype
f.doc_name = name
f.subject = subject
f.color = color
f.full_name = get_fullname(owner)
f.save(ignore_permissions=True)
def update_feed(doc, method=None):
"adds a new feed"
if frappe.flags.in_patch:
return
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.as_dict(), color)
def make_comment_feed(doc, method):
"""add comment to feed"""
comment = doc.comment
if len(comment) > 240:
comment = comment[:240] + "..."
make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by,
'<i>"' + comment + '"</i>', '#6B24B3')

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1 +0,0 @@
Activity Feed.

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,73 +0,0 @@
{
"autoname": "hash",
"creation": "2012-07-03 13:29:42",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "feed_type",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Feed Type",
"options": "\nComment\nLogin",
"permlevel": 0
},
{
"fieldname": "doc_type",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Doc Type",
"permlevel": 0
},
{
"fieldname": "doc_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Doc Name",
"permlevel": 0
},
{
"fieldname": "subject",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Subject",
"permlevel": 0
},
{
"fieldname": "color",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Color",
"permlevel": 0
},
{
"fieldname": "full_name",
"fieldtype": "Data",
"label": "Full Name",
"permlevel": 0
}
],
"icon": "icon-rss",
"idx": 1,
"modified": "2014-06-18 03:49:10.882587",
"modified_by": "Administrator",
"module": "Home",
"name": "Feed",
"owner": "Administrator",
"permissions": [
{
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager"
},
{
"apply_user_permissions": 1,
"permlevel": 0,
"read": 1,
"role": "All"
}
]
}

View File

@ -1,50 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import frappe.defaults
import frappe.permissions
from frappe.model.document import Document
class Feed(Document):
pass
def on_doctype_update():
if not frappe.db.sql("""show index from `tabFeed`
where Key_name="feed_doctype_docname_index" """):
frappe.db.commit()
frappe.db.sql("""alter table `tabFeed`
add index feed_doctype_docname_index(doc_type, doc_name)""")
def get_permission_query_conditions(user):
if not user: user = frappe.session.user
if not frappe.permissions.apply_user_permissions("Feed", "read", user):
return ""
user_permissions = frappe.defaults.get_user_permissions(user)
can_read = frappe.get_user(user).get_can_read()
can_read_doctypes = ['"{}"'.format(doctype) for doctype in
list(set(can_read) - set(user_permissions.keys()))]
if not can_read_doctypes:
return ""
conditions = ["tabFeed.doc_type in ({})".format(", ".join(can_read_doctypes))]
if user_permissions:
can_read_docs = []
for doctype, names in user_permissions.items():
for n in names:
can_read_docs.append('"{}|{}"'.format(doctype, n))
if can_read_docs:
conditions.append("concat_ws('|', tabFeed.doc_type, tabFeed.doc_name) in ({})".format(
", ".join(can_read_docs)))
return "(" + " or ".join(conditions) + ")"
def has_permission(doc, user):
return frappe.has_permission(doc.doc_type, "read", doc.doc_name, user=user)

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1 +0,0 @@
List of latest activities based on Feed.

View File

@ -1 +0,0 @@
from __future__ import unicode_literals

View File

@ -1,23 +0,0 @@
#page-activity .label {
display: inline-block;
width: 100px;
margin-right: 7px;
}
#page-activity .label-info {
cursor: pointer;
}
#page-activity .user-info {
float: right;
color: #777;
font-size: 10px;
}
#page-activity .date-sep {
margin: 0px -15px 11px -15px;
padding: 5px 0px;
border-bottom: 2px solid #aaa;
color: #555;
font-size: 10px;
}

View File

@ -1,88 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
frappe.pages['activity'].onload = function(wrapper) {
frappe.ui.make_app_page({
parent: wrapper,
title: __("Activity"),
single_column: true
})
wrapper.appframe.add_module_icon("Activity");
var list = new frappe.ui.Listing({
hide_refresh: true,
appframe: wrapper.appframe,
method: 'erpnext.home.page.activity.activity.get_feed',
parent: $(wrapper).find(".layout-main"),
render_row: function(row, data) {
new erpnext.ActivityFeed(row, data);
}
});
list.run();
wrapper.appframe.set_title_right(__("Refresh"), function() { list.run(); });
// Build Report Button
if(frappe.boot.user.can_get_report.indexOf("Feed")!=-1) {
wrapper.appframe.add_button(__('Build Report'), function() {
frappe.set_route('Report', "Feed");
}, 'icon-th');
}
}
erpnext.last_feed_date = false;
erpnext.ActivityFeed = Class.extend({
init: function(row, data) {
this.scrub_data(data);
this.add_date_separator(row, data);
if(!data.add_class) data.add_class = "label-default";
$(row).append(repl('<div style="margin: 0px">\
<span class="avatar avatar-small"><img src="%(imgsrc)s" /></span> \
<span %(onclick)s class="label %(add_class)s">%(feed_type)s</span>\
%(link)s %(subject)s <span class="user-info">%(by)s</span></div>', data));
},
scrub_data: function(data) {
data.by = frappe.user_info(data.owner).fullname;
data.imgsrc = frappe.utils.get_file_link(frappe.user_info(data.owner).image);
// feedtype
if(!data.feed_type) {
data.feed_type = __(data.doc_type);
data.add_class = "label-info";
data.onclick = repl('onclick="window.location.href=\'#!List/%(feed_type)s\';"', data)
}
// color for comment
if(data.feed_type=='Comment') {
data.add_class = "label-danger";
}
if(data.feed_type=='Assignment') {
data.add_class = "label-warning";
}
// link
if(data.doc_name && data.feed_type!='Login') {
data.link = frappe.format(data.doc_name, {"fieldtype":"Link", "options":data.doc_type})
} else {
data.link = "";
}
},
add_date_separator: function(row, data) {
var date = dateutil.str_to_obj(data.modified);
var last = erpnext.last_feed_date;
if((last && dateutil.obj_to_str(last) != dateutil.obj_to_str(date)) || (!last)) {
var diff = dateutil.get_day_diff(dateutil.get_today(), dateutil.obj_to_str(date));
if(diff < 1) {
pdate = 'Today';
} else if(diff < 2) {
pdate = 'Yesterday';
} else {
pdate = dateutil.global_date_format(date);
}
$(row).html(repl('<div class="date-sep" style="padding-left: 15px;">%(date)s</div>', {date: pdate}));
}
erpnext.last_feed_date = date;
}
})

View File

@ -1,20 +0,0 @@
{
"creation": "2013-04-09 11:45:31.000000",
"docstatus": 0,
"doctype": "Page",
"icon": "icon-play",
"idx": 1,
"modified": "2013-07-11 14:40:20.000000",
"modified_by": "Administrator",
"module": "Home",
"name": "activity",
"owner": "Administrator",
"page_name": "activity",
"roles": [
{
"role": "All"
}
],
"standard": "Yes",
"title": "Activity"
}

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.utils import cint
@frappe.whitelist()
def get_feed(limit_start, limit_page_length):
"""get feed"""
return frappe.get_list("Feed", fields=["name", "feed_type", "doc_type", "subject", "owner", "modified"],
limit_start = limit_start, limit_page_length = limit_page_length)

View File

@ -20,7 +20,6 @@ notification_config = "erpnext.startup.notifications.get_notification_config"
dump_report_map = "erpnext.startup.report_data_map.data_map"
update_website_context = "erpnext.startup.webutils.update_website_context"
on_session_creation = "erpnext.startup.event_handlers.on_session_creation"
before_tests = "erpnext.setup.utils.before_tests"
website_generators = ["Item Group", "Item", "Sales Partner"]
@ -28,24 +27,15 @@ website_generators = ["Item Group", "Item", "Sales Partner"]
standard_queries = "Customer:erpnext.selling.doctype.customer.customer.get_customer_list"
permission_query_conditions = {
"Feed": "erpnext.home.doctype.feed.feed.get_permission_query_conditions",
"Note": "erpnext.utilities.doctype.note.note.get_permission_query_conditions"
}
has_permission = {
"Feed": "erpnext.home.doctype.feed.feed.has_permission",
"Note": "erpnext.utilities.doctype.note.note.has_permission"
}
doc_events = {
"*": {
"on_update": "erpnext.home.update_feed",
"on_submit": "erpnext.home.update_feed"
},
"Comment": {
"on_update": "erpnext.home.make_comment_feed"
},
"Stock Entry": {
"on_submit": "erpnext.stock.doctype.material_request.material_request.update_completed_qty",
"on_cancel": "erpnext.stock.doctype.material_request.material_request.update_completed_qty"

View File

@ -11,6 +11,10 @@ from erpnext.hr.utils import set_employee_name
class InvalidExpenseApproverError(frappe.ValidationError): pass
class ExpenseClaim(Document):
def get_feed(self):
return _("{0}: From {0} for {1}").format(self.approval_status,
self.employee_name, self.total_claimed_amount)
def validate(self):
self.validate_fiscal_year()
self.validate_exp_details()

View File

@ -17,6 +17,10 @@ class LeaveApproverIdentityError(frappe.ValidationError): pass
from frappe.model.document import Document
class LeaveApplication(Document):
def get_feed(self):
return _("{0}: From {0} of type {1}").format(self.status,
self.employee_name, self.leave_type)
def validate(self):
if not getattr(self, "__islocal", None) and frappe.db.exists(self.doctype, self.name):
self.previous_doc = frappe.db.get_value(self.doctype, self.name, "*", as_dict=True)
@ -212,7 +216,7 @@ class LeaveApplication(Document):
def notify(self, args):
args = frappe._dict(args)
from frappe.core.page.messages.messages import post
from frappe.desk.page.messages.messages import post
post(**{"txt": args.message, "contact": args.message_to, "subject": args.subject,
"notify": cint(self.follow_via_email)})
@ -249,7 +253,7 @@ def get_events(start, end):
employee, company = employee.name, employee.company
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
match_conditions = build_match_conditions("Leave Application")
# show department leaves for employee

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.widgets.reportview import execute as runreport
from frappe.desk.reportview import execute as runreport
def execute(filters=None):
if not filters: filters = {}

View File

@ -11,6 +11,8 @@ from erpnext.utilities.transaction_base import delete_events
from frappe.model.document import Document
class Project(Document):
def get_feed(self):
return self.status
def get_gross_profit(self):
pft, per_pft =0, 0
@ -70,4 +72,4 @@ class Project(Document):
@frappe.whitelist()
def get_cost_center_name(project_name):
return frappe.db.get_value("Project", project_name, "cost_center")
return frappe.db.get_value("Project", project_name, "cost_center")

View File

@ -11,6 +11,9 @@ from frappe import _
from frappe.model.document import Document
class Task(Document):
def get_feed(self):
return '{0}: {1}'.format(_(self.status), self.subject)
def get_project_details(self):
return {
"project": self.project
@ -47,7 +50,7 @@ class Task(Document):
@frappe.whitelist()
def get_events(start, end, filters=None):
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
if not frappe.has_permission("Task"):
frappe.msgprint(_("No Permission"), raise_exception=1)

View File

@ -61,7 +61,7 @@ class TimeLog(Document):
@frappe.whitelist()
def get_events(start, end):
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
if not frappe.has_permission("Time Log"):
frappe.msgprint(_("No Permission"), raise_exception=1)

View File

@ -75,7 +75,7 @@ def build_conditions(filters):
if filters.get("to_date"):
conditions += " and to_time <= timestamp(%(to_date)s, %(to_time)s)"
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
match_conditions = build_match_conditions("Time Log")
if match_conditions:
conditions += " and %s" % match_conditions

View File

@ -12,7 +12,7 @@ def get_time_log_list(doctype, txt, searchfield, start, page_len, filters):
@frappe.whitelist()
def query_task(doctype, txt, searchfield, start, page_len, filters):
from frappe.widgets.reportview import build_match_conditions
from frappe.desk.reportview import build_match_conditions
search_string = "%%%s%%" % txt
order_by_string = "%s%%" % txt

View File

@ -12,6 +12,8 @@ from erpnext.utilities.transaction_base import TransactionBase
from erpnext.accounts.party import create_party_account
class Customer(TransactionBase):
def get_feed(self):
return self.customer_name
def autoname(self):
cust_master_name = frappe.defaults.get_global_default('cust_master_name')

View File

@ -11,6 +11,9 @@ from frappe.model.mapper import get_mapped_doc
from erpnext.controllers.selling_controller import SellingController
class Lead(SellingController):
def get_feed(self):
return '{0}: {1}'.format(_(self.status), self.lead_name)
def onload(self):
customer = frappe.db.get_value("Customer", {"lead_name": self.name})
self.get("__onload").is_customer = customer

View File

@ -4,17 +4,17 @@
$.extend(cur_frm.cscript, {
refresh: function() {
cur_frm.disable_save();
if(!(cint(cur_frm.doc.dropbox_access_allowed) ||
if(!(cint(cur_frm.doc.dropbox_access_allowed) ||
cint(cur_frm.doc.gdrive_access_allowed))) {
cur_frm.set_intro(__("You can start by selecting backup frequency and granting access for sync"));
} else {
var services = {
"dropbox": __("Dropbox"),
"gdrive": __("Google Drive")
"dropbox": __("Dropbox")
// "gdrive": __("Google Drive")
}
var active_services = [];
$.each(services, function(service, label) {
var access_allowed = cint(cur_frm.doc[service + "_access_allowed"]);
var frequency = cur_frm.doc["upload_backups_to_" + service];
@ -22,27 +22,27 @@ $.extend(cur_frm.cscript, {
active_services.push(label + " [" + frequency + "]");
}
});
if(active_services.length > 0) {
cur_frm.set_intro(__("Backups will be uploaded to") + ": " +
cur_frm.set_intro(__("Backups will be uploaded to") + ": " +
frappe.utils.comma_and(active_services));
} else {
cur_frm.set_intro("");
}
}
},
validate_send_notifications_to: function() {
if(!cur_frm.doc.send_notifications_to) {
msgprint(__("Please specify") + ": " +
msgprint(__("Please specify") + ": " +
__(frappe.meta.get_label(cur_frm.doctype, "send_notifications_to")));
return false;
}
return true;
},
allow_dropbox_access: function() {
if(cur_frm.cscript.validate_send_notifications_to()) {
return frappe.call({
@ -59,7 +59,7 @@ $.extend(cur_frm.cscript, {
});
}
},
allow_gdrive_access: function() {
if(cur_frm.cscript.validate_send_notifications_to()) {
return frappe.call({
@ -72,7 +72,7 @@ $.extend(cur_frm.cscript, {
});
}
},
validate_gdrive: function() {
return frappe.call({
method: "erpnext.setup.doctype.backup_manager.backup_googledrive.gdrive_callback",
@ -81,11 +81,11 @@ $.extend(cur_frm.cscript, {
},
});
},
upload_backups_to_dropbox: function() {
cur_frm.save();
},
// upload_backups_to_gdrive: function() {
// cur_frm.save();
// },

View File

@ -295,7 +295,7 @@ class EmailDigest(Document):
filter_by_company=False)
def get_calendar_events(self, user_id):
from frappe.core.doctype.event.event import get_events
from frappe.desk.doctype.event.event import get_events
events = get_events(self.future_from_date.strftime("%Y-%m-%d"), self.future_to_date.strftime("%Y-%m-%d"))
html = ""

View File

@ -227,9 +227,11 @@ def set_defaults(args):
def create_feed_and_todo():
"""update activty feed and create todo for creation of item, customer, vendor"""
from erpnext.home import make_feed
make_feed('Comment', 'ToDo', '', frappe.session['user'],
'ERNext Setup Complete!', '#6B24B3')
frappe.get_doc({
"doctype": "Feed",
"feedtype": "Comment",
"subject": "ERPNext Setup Complete!"
}).insert(ignore_permissions=True)
def create_email_digest():
from frappe.utils.user import get_system_managers

View File

@ -1,17 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt"
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'] != 'Guest':
# create feed
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

@ -26,6 +26,10 @@ form_grid_templates = {
class StockEntry(StockController):
fname = 'mtn_details'
def get_feed(self):
return _("From {0} to {1}").format(self.from_warehouse, self.to_warehouse)
def onload(self):
if self.docstatus==1:
for item in self.get(self.fname):

View File

@ -12,6 +12,8 @@ from frappe.utils import today
from erpnext.utilities.transaction_base import TransactionBase
class CustomerIssue(TransactionBase):
def get_feed(self):
return _("{0}: From {1}").format(self.status, self.customer_name)
def validate(self):
if session['user'] != 'Guest' and not self.customer:

View File

@ -8,6 +8,8 @@ from frappe import _
from erpnext.utilities.transaction_base import TransactionBase
class MaintenanceVisit(TransactionBase):
def get_feed(self):
return _("To {0}").format(self.customer_name)
def get_item_details(self, item_code):
return frappe.db.get_value("Item", item_code, ["item_name", "description"], as_dict=1)

View File

@ -3,11 +3,14 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from erpnext.utilities.transaction_base import TransactionBase
from frappe.utils import now, extract_email_id
class SupportTicket(TransactionBase):
def get_feed(self):
return "{0}: {1}".format(_(self.status, self.subject))
def get_sender(self, comm):
return frappe.db.get_value('Support Email Settings',None,'support_email')
@ -30,7 +33,7 @@ class SupportTicket(TransactionBase):
self.set_lead_contact(self.raised_by)
if self.status == "Closed":
from frappe.widgets.form.assign_to import clear
from frappe.desk.form.assign_to import clear
clear(self.doctype, self.name)
def set_lead_contact(self, email_id):

View File

@ -1 +0,0 @@
Shared Note. (Page with standard information, links, attachments).

View File

@ -1,71 +0,0 @@
{
"allow_rename": 1,
"creation": "2013-05-24 13:41:00",
"description": "Note is a free page where users can share documents / notes",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Transaction",
"fields": [
{
"fieldname": "title",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Title",
"permlevel": 0,
"print_hide": 1,
"reqd": 1
},
{
"description": "Help: To link to another record in the system, use \"#Form/Note/[Note Name]\" as the Link URL. (don't use \"http://\")",
"fieldname": "content",
"fieldtype": "Text Editor",
"in_list_view": 0,
"label": "Content",
"permlevel": 0
},
{
"fieldname": "share",
"fieldtype": "Section Break",
"label": "Share",
"permlevel": 0
},
{
"description": "Everyone can read",
"fieldname": "public",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Public",
"permlevel": 0,
"print_hide": 1
},
{
"fieldname": "share_with",
"fieldtype": "Table",
"label": "Share With",
"options": "Note User",
"permlevel": 0,
"print_hide": 1
}
],
"icon": "icon-file-text",
"idx": 1,
"modified": "2014-07-30 03:24:38.302928",
"modified_by": "Administrator",
"module": "Utilities",
"name": "Note",
"owner": "Administrator",
"permissions": [
{
"apply_user_permissions": 1,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"role": "All",
"write": 1
}
],
"read_only_onload": 1
}

View File

@ -1,46 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
class Note(Document):
def autoname(self):
# replace forbidden characters
import re
self.name = re.sub("[%'\"#*?`]", "", self.title.strip())
def before_print(self):
self.print_heading = self.name
self.sub_heading = ""
def get_permission_query_conditions(user):
if not user: user = frappe.session.user
if user == "Administrator":
return ""
return """(`tabNote`.public=1 or `tabNote`.owner="{user}" or exists (
select name from `tabNote User`
where `tabNote User`.parent=`tabNote`.name
and `tabNote User`.user="{user}"))""".format(user=user)
def has_permission(doc, ptype, user):
if doc.public == 1 or user == "Administrator":
return True
if user == doc.owner:
return True
note_user_map = dict((d.user, d) for d in doc.get("share_with"))
if user in note_user_map:
if ptype == "read":
return True
elif note_user_map.get(user).permission == "Edit":
return True
return False

View File

@ -1,16 +0,0 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
{% if(!doc.public) { %}
<span style="margin-right: 8px;"
title="{%= __("Private") %}" class="filterable"
data-filter="public,=,Yes">
<i class="icon-lock text-muted"></i>
</span>
{% } %}
</div>
</div>
</div>

View File

@ -1,3 +0,0 @@
frappe.listview_settings['Note'] = {
add_fields: ["title", "public"],
}

View File

@ -1,10 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors and Contributors
# See license.txt
import frappe
import unittest
test_records = frappe.get_test_records('Note')
class TestNote(unittest.TestCase):
pass

View File

@ -1,7 +0,0 @@
[
{
"doctype": "Note",
"name": "_Test Note 1",
"title": "Test Note Title"
}
]

View File

@ -1 +0,0 @@
User who can access / edit the parent Note.

View File

@ -1,36 +0,0 @@
{
"creation": "2013-05-24 14:24:48",
"description": "List of users who can edit a particular Note",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Other",
"fields": [
{
"fieldname": "user",
"fieldtype": "Link",
"ignore_user_permissions": 1,
"in_list_view": 1,
"label": "User",
"options": "User",
"permlevel": 0,
"reqd": 1
},
{
"default": "Edit",
"fieldname": "permission",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Permission",
"options": "Edit\nRead",
"permlevel": 0
}
],
"idx": 1,
"istable": 1,
"modified": "2014-06-04 02:33:27.466061",
"modified_by": "Administrator",
"module": "Utilities",
"name": "Note User",
"owner": "Administrator",
"permissions": []
}

View File

@ -1,12 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class NoteUser(Document):
pass