Prateeksha Singh | 95d8fd3 | 2017-09-04 11:14:04 +0530 | [diff] [blame] | 1 | # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | import frappe, erpnext |
| 5 | from frappe import _ |
| 6 | from erpnext.setup.doctype.setup_progress.setup_progress import get_action_completed_state |
| 7 | |
| 8 | def get_slide_settings(): |
| 9 | defaults = frappe.defaults.get_defaults() |
| 10 | domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') |
| 11 | company = defaults.get("company") or '' |
| 12 | # Initial state of slides |
| 13 | return [ |
| 14 | frappe._dict( |
| 15 | action_name='Add Company', |
| 16 | title=_("Setup Company") if domain != 'Education' else _("Setup Institution"), |
| 17 | help=_('Setup your ' + ('company' if domain != 'Education' else 'institution') + ' and brand.'), |
| 18 | # image_src="/assets/erpnext/images/illustrations/shop.jpg", |
| 19 | fields=[], |
| 20 | done_state_title=_("You added " + company), |
| 21 | done_state_title_route=["Form", "Company", company], |
| 22 | help_links=[ |
| 23 | { |
| 24 | "label": _("Chart of Accounts"), |
| 25 | "url": ["https://erpnext.org/docs/user/manual/en/accounts/chart-of-accounts"] |
| 26 | }, |
| 27 | { |
| 28 | "label": _("Opening Balances"), |
| 29 | "video_id": "U5wPIvEn-0c" |
| 30 | } |
| 31 | ] |
| 32 | ) |
| 33 | , |
| 34 | frappe._dict( |
| 35 | action_name='Add Customers', |
| 36 | domains=('Manufacturing', 'Services', 'Retail', 'Distribution'), |
| 37 | icon="fa fa-group", |
| 38 | title=_("Add Customers"), |
| 39 | help=_("List a few of your customers. They could be organizations or individuals."), |
| 40 | fields=[ |
| 41 | {"fieldtype":"Section Break"}, |
| 42 | {"fieldtype":"Data", "fieldname":"customer", "label":_("Customer"), |
| 43 | "placeholder":_("Customer Name")}, |
| 44 | {"fieldtype":"Column Break"}, |
| 45 | {"fieldtype":"Data", "fieldname":"customer_contact", |
| 46 | "label":_("Contact Name"), "placeholder":_("Contact Name")} |
| 47 | ], |
| 48 | add_more=1, max_count=3, mandatory_entry=1, |
| 49 | submit_method="erpnext.utilities.user_progress_utils.create_customers", |
| 50 | done_state_title=_("Go to Customers"), |
| 51 | done_state_title_route=["List", "Customer"], |
| 52 | help_links=[ |
| 53 | { |
| 54 | "label": _('Learn More'), |
| 55 | "url": ["https://erpnext.org/docs/user/manual/en/CRM/customer.html"] |
| 56 | } |
| 57 | ] |
| 58 | ), |
| 59 | frappe._dict( |
| 60 | action_name='Add Suppliers', |
| 61 | domains=('Manufacturing', 'Services', 'Retail', 'Distribution'), |
| 62 | icon="fa fa-group", |
| 63 | title=_("Your Suppliers"), |
| 64 | help=_("List a few of your suppliers. They could be organizations or individuals."), |
| 65 | fields=[ |
| 66 | {"fieldtype":"Section Break"}, |
| 67 | {"fieldtype":"Data", "fieldname":"supplier", "label":_("Supplier"), |
| 68 | "placeholder":_("Supplier Name")}, |
| 69 | {"fieldtype":"Column Break"}, |
| 70 | {"fieldtype":"Data", "fieldname":"supplier_contact", |
| 71 | "label":_("Contact Name"), "placeholder":_("Contact Name")}, |
| 72 | ], |
| 73 | add_more=1, max_count=3, mandatory_entry=1, |
| 74 | submit_method="erpnext.utilities.user_progress_utils.create_suppliers", |
| 75 | done_state_title=_("Go to Suppliers"), |
| 76 | done_state_title_route=["List", "Supplier"], |
| 77 | help_links=[ |
| 78 | { |
| 79 | "label": _('Learn More'), |
| 80 | "url": ["https://erpnext.org/docs/user/manual/en/buying/supplier"] |
| 81 | }, |
| 82 | { |
| 83 | "label": _('Customers and Suppliers'), |
| 84 | "video_id": "zsrrVDk6VBs" |
| 85 | }, |
| 86 | ] |
| 87 | ), |
| 88 | frappe._dict( |
| 89 | action_name='Add Products', |
| 90 | domains=['Manufacturing', 'Services', 'Retail', 'Distribution'], |
| 91 | icon="fa fa-barcode", |
| 92 | title=_("Your Products or Services"), |
| 93 | help=_("List your products or services that you buy or sell."), |
| 94 | fields=[ |
| 95 | {"fieldtype":"Section Break", "show_section_border": 1}, |
| 96 | {"fieldtype":"Data", "fieldname":"item", "label":_("Item"), |
| 97 | "placeholder":_("A Product")}, |
| 98 | {"fieldtype":"Column Break"}, |
| 99 | {"fieldtype":"Select", "fieldname":"item_uom", "label":_("UOM"), |
| 100 | "options":[_("Unit"), _("Nos"), _("Box"), _("Pair"), _("Kg"), _("Set"), |
| 101 | _("Hour"), _("Minute"), _("Litre"), _("Meter"), _("Gram")], |
| 102 | "default": _("Unit"), "static": 1}, |
| 103 | {"fieldtype":"Column Break"}, |
| 104 | {"fieldtype":"Currency", "fieldname":"item_price", "label":_("Rate"), "static": 1} |
| 105 | ], |
| 106 | add_more=1, max_count=3, mandatory_entry=1, |
| 107 | submit_method="erpnext.utilities.user_progress_utils.create_items", |
| 108 | done_state_title=_("Go to Items"), |
| 109 | done_state_title_route=["List", "Item"], |
| 110 | help_links=[ |
| 111 | { |
| 112 | "label": _("Explore Sales Cycle"), |
| 113 | "video_id": "1eP90MWoDQM" |
| 114 | }, |
| 115 | ] |
| 116 | ), |
| 117 | |
| 118 | # School slides begin |
| 119 | frappe._dict( |
| 120 | action_name='Add Programs', |
| 121 | domains=("Education"), |
| 122 | title=_("Program"), |
| 123 | help=_("Example: Masters in Computer Science"), |
| 124 | fields=[ |
| 125 | {"fieldtype":"Section Break", "show_section_border": 1}, |
| 126 | {"fieldtype":"Data", "fieldname":"program", "label":_("Program"), "placeholder": _("Program Name")}, |
| 127 | ], |
| 128 | add_more=1, max_count=3, mandatory_entry=1, |
| 129 | submit_method="erpnext.utilities.user_progress_utils.create_program", |
| 130 | done_state_title=_("Go to Programs"), |
| 131 | done_state_title_route=["List", "Program"], |
| 132 | help_links=[ |
| 133 | { |
| 134 | "label": _("Student Application"), |
| 135 | "video_id": "l8PUACusN3E" |
| 136 | }, |
| 137 | ] |
| 138 | |
| 139 | ), |
| 140 | frappe._dict( |
| 141 | action_name='Add Courses', |
| 142 | domains=["Education"], |
| 143 | title=_("Course"), |
| 144 | help=_("Example: Basic Mathematics"), |
| 145 | fields=[ |
| 146 | {"fieldtype":"Section Break", "show_section_border": 1}, |
| 147 | {"fieldtype":"Data", "fieldname":"course", "label":_("Course"), "placeholder": _("Course Name")}, |
| 148 | ], |
| 149 | add_more=1, max_count=3, mandatory_entry=1, |
| 150 | submit_method="erpnext.utilities.user_progress_utils.create_course", |
| 151 | done_state_title=_("Go to Courses"), |
| 152 | done_state_title_route=["List", "Course"], |
| 153 | help_links=[ |
| 154 | { |
| 155 | "label": _('Add Students'), |
| 156 | "route": ["List", "Student"] |
| 157 | } |
| 158 | ] |
| 159 | ), |
| 160 | frappe._dict( |
| 161 | action_name='Add Instructors', |
| 162 | domains=["Education"], |
| 163 | title=_("Instructor"), |
| 164 | help=_("People who teach at your organisation"), |
| 165 | fields=[ |
| 166 | {"fieldtype":"Section Break", "show_section_border": 1}, |
| 167 | {"fieldtype":"Data", "fieldname":"instructor", "label":_("Instructor"), "placeholder": _("Instructor Name")}, |
| 168 | ], |
| 169 | add_more=1, max_count=3, mandatory_entry=1, |
| 170 | submit_method="erpnext.utilities.user_progress_utils.create_instructor", |
| 171 | done_state_title=_("Go to Instructors"), |
| 172 | done_state_title_route=["List", "Instructor"], |
| 173 | help_links=[ |
| 174 | { |
| 175 | "label": _('Student Batches'), |
| 176 | "route": ["List", "Student Batch"] |
| 177 | } |
| 178 | ] |
| 179 | ), |
| 180 | frappe._dict( |
| 181 | action_name='Add Rooms', |
| 182 | domains=["Education"], |
| 183 | title=_("Room"), |
| 184 | help=_("Classrooms/ Laboratories etc where lectures can be scheduled."), |
| 185 | fields=[ |
| 186 | {"fieldtype":"Section Break", "show_section_border": 1}, |
| 187 | {"fieldtype":"Data", "fieldname":"room", "label":_("Room")}, |
| 188 | {"fieldtype":"Column Break"}, |
| 189 | {"fieldtype":"Int", "fieldname":"room_capacity", "label":_("Room Capacity"), "static": 1}, |
| 190 | ], |
| 191 | add_more=1, max_count=3, mandatory_entry=1, |
| 192 | submit_method="erpnext.utilities.user_progress_utils.create_room", |
| 193 | done_state_title=_("Go to Rooms"), |
| 194 | done_state_title_route=["List", "Room"], |
| 195 | help_links=[] |
| 196 | ), |
| 197 | # School slides end |
| 198 | |
| 199 | frappe._dict( |
| 200 | action_name='Add Users', |
| 201 | title=_("Add Users"), |
| 202 | help=_("Add users to your organization, other than yourself."), |
| 203 | fields=[ |
| 204 | {"fieldtype":"Section Break"}, |
| 205 | {"fieldtype":"Data", "fieldname":"user_email", "label":_("Email ID"), |
| 206 | "placeholder":_("user@example.com"), "options": "Email", "static": 1}, |
| 207 | {"fieldtype":"Column Break"}, |
| 208 | {"fieldtype":"Data", "fieldname":"user_fullname", |
| 209 | "label":_("Full Name"), "static": 1}, |
| 210 | ], |
| 211 | add_more=1, max_count=3, mandatory_entry=1, |
| 212 | submit_method="erpnext.utilities.user_progress_utils.create_users", |
| 213 | done_state_title=_("Go to Users"), |
| 214 | done_state_title_route=["List", "User"], |
| 215 | help_links=[ |
| 216 | { |
| 217 | "label": _('Learn More'), |
| 218 | "url": ["https://erpnext.org/docs/user/manual/en/setting-up/users-and-permissions"] |
| 219 | }, |
| 220 | { |
| 221 | "label": _('Users and Permissions'), |
| 222 | "video_id": "8Slw1hsTmUI" |
| 223 | }, |
| 224 | ] |
| 225 | ) |
| 226 | ] |
| 227 | |
| 228 | def get_user_progress_slides(): |
| 229 | slides = [] |
| 230 | slide_settings = get_slide_settings() |
| 231 | |
| 232 | domain = frappe.db.get_value('Company', erpnext.get_default_company(), 'domain') |
| 233 | |
| 234 | for s in slide_settings: |
| 235 | if not s.domains or (domain and domain in s.domains): |
| 236 | s.mark_as_done_method = "erpnext.setup.doctype.setup_progress.setup_progress.set_action_completed_state" |
| 237 | s.done = get_action_completed_state(s.action_name) or 0 |
| 238 | slides.append(s) |
| 239 | |
| 240 | return slides |
| 241 | |