Moved demo to separate app, moved patches folder

This commit is contained in:
Rushabh Mehta 2013-12-27 17:30:24 +05:30
parent 4ac68952e8
commit c4a0ed63ef
8 changed files with 188 additions and 53 deletions

View File

@ -1,64 +1,65 @@
app_name ERPNext
app_publisher Web Notes Technologies
app_description Open Source Enterprise Resource Planning for Small and Midsized Organizations
app_icon icon-th
app_color #e74c3c
app_version 4.0.0-wip
app_name = erpnext
app_title = ERPNext
app_publisher = Web Notes Technologies
app_description = Open Source Enterprise Resource Planning for Small and Midsized Organizations
app_icon = icon-th
app_color = #e74c3c
app_version = 4.0.0-wip
app_include_js assets/js/erpnext.min.js
app_include_css assets/css/erpnext.css
web_include_js assets/js/erpnext-web.min.js
app_include_js = assets/js/erpnext.min.js
app_include_css = assets/css/erpnext.css
web_include_js = assets/js/erpnext-web.min.js
after_install erpnext.setup.install.after_install
after_install = erpnext.setup.install.after_install
boot_session erpnext.startup.boot.boot_session
notification_config erpnext.startup.notifications.get_notification_config
boot_session = erpnext.startup.boot.boot_session
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
dump_report_map = erpnext.startup.report_data_map.data_map
update_website_context = erpnext.startup.webutils.update_website_context
mail_footer erpnext.startup.mail_footer
mail_footer = erpnext.startup.mail_footer
on_session_creation erpnext.startup.event_handlers.on_session_creation
on_logout erpnext.startup.event_handlers.on_logut
on_session_creation = erpnext.startup.event_handlers.on_session_creation
on_logout = erpnext.startup.event_handlers.on_logut
# Bean Events
# -----------
# Boot Events
# -------------------------
bean_event *:on_update:erpnext.home.update_feed
bean_event *:on_submit:erpnext.home.update_feed
bean_event Comment:on_update:erpnext.home.make_comment_feed
bean_event = *:on_update:erpnext.home.update_feed
bean_event = *:on_submit:erpnext.home.update_feed
bean_event = Comment:on_update:erpnext.home.make_comment_feed
bean_event *:on_update:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event *:on_cancel:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event *:on_trash:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = *:on_update:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = *:on_cancel:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = *:on_trash:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event Stock Entry:on_submit:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event Stock Entry:on_cancel:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event = Stock Entry:on_submit:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event = Stock Entry:on_cancel:erpnext.stock.doctype.material_request.material_request.update_completed_qty
standard_queries Warehouse:erpnext.stock.utils.get_warehouse_list
standard_queries Customer:erpnext.selling.utils.get_customer_list
standard_queries = Warehouse:erpnext.stock.utils.get_warehouse_list
standard_queries = Customer:erpnext.selling.utils.get_customer_list
# Schedulers
# ----------
# -------------------------
#### Frequently
scheduler_event all:erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
scheduler_event all:erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
scheduler_event all:erpnext.selling.doctype.lead.get_leads.get_leads
scheduler_event all:webnotes.utils.email_lib.bulk.flush
scheduler_event = all:erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
scheduler_event = all:erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
scheduler_event = all:erpnext.selling.doctype.lead.get_leads.get_leads
scheduler_event = all:webnotes.utils.email_lib.bulk.flush
#### Daily
scheduler_event daily:webnotes.core.doctype.event.event.send_event_digest
scheduler_event daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count
scheduler_event daily:webnotes.utils.email_lib.bulk.clear_outbox
scheduler_event daily:erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
scheduler_event daily:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
scheduler_event daily:erpnext.stock.utils.reorder_item
scheduler_event daily:erpnext.setup.doctype.email_digest.email_digest.send
scheduler_event = daily:webnotes.core.doctype.event.event.send_event_digest
scheduler_event = daily:webnotes.core.doctype.notification_count.notification_count.delete_event_notification_count
scheduler_event = daily:webnotes.utils.email_lib.bulk.clear_outbox
scheduler_event = daily:erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
scheduler_event = daily:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
scheduler_event = daily:erpnext.stock.utils.reorder_item
scheduler_event = daily:erpnext.setup.doctype.email_digest.email_digest.send
#### Weekly
scheduler_event weekly:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly
scheduler_event = weekly:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly

View File

@ -1,7 +1,3 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# patches after permission rewrite
erpnext.patches.1312.p02_update_user_properties
erpnext.patches.1312.p03_move_warehouse_user_to_restrictions
erpnext.patches.1312.p04_new_permissions
erpnext.patches.4_0.update_user_properties
erpnext.patches.4_0.move_warehouse_user_to_restrictions
erpnext.patches.4_0.new_permissions

View File

View File

@ -0,0 +1,12 @@
# 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 webnotes
def execute():
from webnotes.core.page.user_properties import user_properties
for warehouse, profile in webnotes.conn.sql("""select parent, user from `tabWarehouse User`"""):
user_properties.add(profile, "Warehouse", warehouse)
webnotes.delete_doc("DocType", "Warehouse User")

View File

@ -0,0 +1,24 @@
# 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 webnotes
def execute():
# reset Page perms
from webnotes.core.page.permission_manager.permission_manager import reset
reset("Page")
reset("Report")
# patch to move print, email into DocPerm
for doctype, hide_print, hide_email in webnotes.conn.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
(ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
if not hide_print:
webnotes.conn.sql("""update `tabDocPerm` set `print`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)
if not hide_email:
webnotes.conn.sql("""update `tabDocPerm` set `email`=1
where permlevel=0 and `read`=1 and parent=%s""", doctype)

View File

@ -0,0 +1,102 @@
# 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 webnotes
import webnotes.permissions
import webnotes.model.doctype
import webnotes.defaults
def execute():
webnotes.reload_doc("core", "doctype", "docperm")
update_user_properties()
update_user_match()
add_employee_restrictions_to_leave_approver()
update_permissions()
remove_duplicate_restrictions()
webnotes.defaults.clear_cache()
webnotes.clear_cache()
def update_user_properties():
webnotes.reload_doc("core", "doctype", "docfield")
for d in webnotes.conn.sql("""select parent, defkey, defvalue from tabDefaultValue
where parent not in ('__global', 'Control Panel')""", as_dict=True):
df = webnotes.conn.sql("""select options from tabDocField
where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
if df:
webnotes.conn.sql("""update tabDefaultValue
set defkey=%s, parenttype='Restriction'
where defkey=%s and
parent not in ('__global', 'Control Panel')""", (df[0].options, d.defkey))
def update_user_match():
import webnotes.defaults
doctype_matches = {}
for doctype, match in webnotes.conn.sql("""select parent, `match` from `tabDocPerm`
where `match` like %s and ifnull(`match`, '')!="leave_approver:user" """, "%:user"):
doctype_matches.setdefault(doctype, []).append(match)
for doctype, user_matches in doctype_matches.items():
meta = webnotes.get_doctype(doctype)
# for each user with roles of this doctype, check if match condition applies
for profile in webnotes.conn.sql_list("""select name from `tabProfile`
where enabled=1 and user_type='System User'"""):
perms = webnotes.permissions.get_user_perms(meta, "read", profile)
# user does not have required roles
if not perms:
continue
# assume match
user_match = True
for perm in perms:
if not perm.match:
# aha! non match found
user_match = False
break
if not user_match:
continue
# if match condition applies, restrict that user
# add that doc's restriction to that user
for match in user_matches:
for name in webnotes.conn.sql_list("""select name from `tab{doctype}`
where `{field}`=%s""".format(doctype=doctype, field=match.split(":")[0]), profile):
webnotes.defaults.add_default(doctype, name, profile, "Restriction")
def add_employee_restrictions_to_leave_approver():
from webnotes.core.page.user_properties import user_properties
# add restrict rights to HR User and HR Manager
webnotes.conn.sql("""update `tabDocPerm` set `restrict`=1 where parent in ('Employee', 'Leave Application')
and role in ('HR User', 'HR Manager') and permlevel=0 and `read`=1""")
webnotes.model.doctype.clear_cache()
# add Employee restrictions (in on_update method)
for employee in webnotes.conn.sql_list("""select name from `tabEmployee`
where exists(select leave_approver from `tabEmployee Leave Approver`
where `tabEmployee Leave Approver`.parent=`tabEmployee`.name)
or ifnull(`reports_to`, '')!=''"""):
webnotes.bean("Employee", employee).save()
def update_permissions():
# clear match conditions other than owner
webnotes.conn.sql("""update tabDocPerm set `match`=''
where ifnull(`match`,'') not in ('', 'owner')""")
def remove_duplicate_restrictions():
# remove duplicate restrictions (if they exist)
for d in webnotes.conn.sql("""select parent, defkey, defvalue,
count(*) as cnt from tabDefaultValue
where parent not in ('__global', 'Control Panel')
group by parent, defkey, defvalue""", as_dict=1):
if d.cnt > 1:
# order by parenttype so that restriction does not get removed!
webnotes.conn.sql("""delete from tabDefaultValue where parent=%s, defkey=%s,
defvalue=%s order by parenttype limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, cint, fmt_money, get_base_path
from webnotes.utils import cstr, cint, fmt_money
from webnotes.webutils import delete_page_cache
from erpnext.selling.utils.cart import _get_cart_quotation

View File

@ -19,7 +19,7 @@ import os
import mimetypes
import webnotes
import oauth2client.client
from webnotes.utils import get_base_path, cstr
from webnotes.utils import cstr
from webnotes import _, msgprint
from apiclient.discovery import build
from apiclient.http import MediaFileUpload
@ -69,7 +69,7 @@ def backup_to_gdrive():
# upload database
backup = new_backup()
path = os.path.join(get_base_path(), "public", "backups")
path = os.path.join(webnotes.local.site_path, "public", "backups")
filename = os.path.join(path, os.path.basename(backup.backup_path_db))
# upload files to database folder
@ -83,7 +83,7 @@ def backup_to_gdrive():
files_folder_id = webnotes.conn.get_value("Backup Manager", None, "files_folder_id")
webnotes.conn.close()
path = os.path.join(get_base_path(), "public", "files")
path = os.path.join(webnotes.local.site_path, "public", "files")
for filename in os.listdir(path):
filename = cstr(filename)
found = False