brotherton-erpnext/erpnext/setup/setup_wizard/domainify.py

88 lines
2.7 KiB
Python
Raw Normal View History

2016-05-11 09:43:44 +00:00
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import frappe
domains = {
'Manufacturing': {
'desktop_icons': ['Item', 'BOM', 'Customer', 'Supplier', 'Sales Order',
2016-05-13 12:36:01 +00:00
'Production Order', 'Stock Entry', 'Purchase Order', 'Task', 'Buying', 'Selling',
2016-06-13 12:16:55 +00:00
'Accounts', 'HR', 'ToDo'],
2016-05-13 12:36:01 +00:00
'properties': [
{'doctype': 'Item', 'fieldname': 'manufacturing', 'property': 'collapsible_depends_on', 'value': 'is_stock_item'},
],
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
2016-05-13 12:36:01 +00:00
]
2016-05-11 09:43:44 +00:00
},
2016-05-20 07:24:44 +00:00
'Retail': {
'desktop_icons': ['POS', 'Item', 'Customer', 'Sales Invoice', 'Purchase Order', 'Warranty Claim',
2016-06-13 12:16:55 +00:00
'Accounts', 'Buying', 'ToDo'],
2016-05-13 12:36:01 +00:00
'remove_roles': ['Manufacturing User', 'Manufacturing Manager'],
'properties': [
{'doctype': 'Item', 'fieldname': 'manufacturing', 'property': 'hidden', 'value': 1},
{'doctype': 'Customer', 'fieldname': 'credit_limit_section', 'property': 'hidden', 'value': 1},
],
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
]
2016-05-11 09:43:44 +00:00
},
2016-05-20 07:24:44 +00:00
2016-05-11 09:43:44 +00:00
'Distribution': {
2016-05-12 12:26:23 +00:00
'desktop_icons': ['Item', 'Customer', 'Supplier', 'Lead', 'Sales Order',
2016-06-13 12:16:55 +00:00
'Sales Invoice', 'CRM', 'Selling', 'Buying', 'Stock', 'Accounts', 'HR', 'ToDo'],
'remove_roles': ['Manufacturing User', 'Manufacturing Manager'],
2016-05-12 12:26:23 +00:00
'properties': [
{'doctype': 'Item', 'fieldname': 'manufacturing', 'property': 'hidden', 'value': 1},
2016-05-13 12:36:01 +00:00
],
'set_value': [
['Stock Settings', None, 'show_barcode_field', 1]
2016-05-12 12:26:23 +00:00
]
2016-05-11 09:43:44 +00:00
},
2016-05-20 07:24:44 +00:00
2016-05-11 09:43:44 +00:00
'Services': {
2016-05-20 07:24:44 +00:00
'desktop_icons': ['Project', 'Time Log', 'Customer', 'Sales Order', 'Sales Invoice', 'Lead', 'Opportunity',
2016-06-13 12:16:55 +00:00
'Expense Claim', 'Employee', 'HR', 'ToDo'],
'remove_roles': ['Manufacturing User', 'Manufacturing Manager'],
2016-05-11 09:43:44 +00:00
'properties': [
2016-05-11 11:17:14 +00:00
{'doctype': 'Item', 'fieldname': 'is_stock_item', 'property': 'default', 'value': 0},
2016-05-12 09:52:59 +00:00
],
'set_value': [
2016-05-13 12:36:01 +00:00
['Stock Settings', None, 'show_barcode_field', 0]
2016-05-11 09:43:44 +00:00
]
}
}
def setup_domain(domain):
if not domain in domains:
return
from frappe.desk.doctype.desktop_icon.desktop_icon import set_desktop_icons
data = frappe._dict(domains[domain])
if data.remove_roles:
for role in data.remove_roles:
frappe.db.sql('delete from tabUserRole where role=%s', role)
if data.desktop_icons:
set_desktop_icons(data.desktop_icons)
if data.properties:
for args in data.properties:
frappe.make_property_setter(args)
2016-05-12 10:56:01 +00:00
if data.set_value:
for args in data.set_value:
doc = frappe.get_doc(args[0], args[1] or args[0])
doc.set(args[2], args[3])
doc.save()
2016-05-11 09:43:44 +00:00
frappe.clear_cache()
def reset():
from frappe.desk.page.setup_wizard.setup_wizard import add_all_roles_to
add_all_roles_to('Administrator')
frappe.db.sql('delete from `tabProperty Setter`')