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

422 lines
13 KiB
Python
Raw Normal View History

# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2013-10-08 12:29:11 +00:00
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
2015-11-09 11:23:11 +00:00
import frappe, copy
2013-10-08 12:29:11 +00:00
import os
import json
2015-11-09 11:23:11 +00:00
from frappe.utils import cstr, flt, getdate
from frappe import _
2014-02-14 10:17:51 +00:00
from frappe.utils.file_manager import save_file
2015-04-01 16:31:54 +00:00
from .default_website import website_maker
[domain] Healthcare (#10664) * Medical module for erpnext * Changes in core for Medical module * patient registration updated * fix - appointment invioce - fields missing * pages- indicator instead of bg-color * Lab Test field renamed service type * Department added Lab Test * procedure name in prescription * fixes sample collection * filter disabled patient * fix patient admission * updated patient age * availability check msg updated * fixes, removed procedure from invoice * sample print renamed * fixes, validation * service desk physician in filter * refactor scheduler * Appointment -field property - set only once = 1 * Appointment - Mark closed and pending buttons removed * Appointment - readonly = 1 if value set * Appointment - availabilty * Appointment - Cancel - info - cancel invoice * Appointment - set pending appointments * Dosage form - new DT * Drug Prescription - Dosage form added * Facility - Floor - removed from Fecility * Floor - removed * Lab Test Template - item creation validation * Procedure - Create Procedure * Procedure Appointment - new DT * Service Unit - Floor reference removed * Zone Fcilities - Unused DT removed * Appointment Desk - fixed * Service Desk - method pointing from procedure changed to procedure_appointment * Consultation print - got featured * Consultation - removed patient refernce to procedure prescription * Procedure Prescription - removed patient refernce * Lab Test - Changed field properties and value * Lab Test - field property changed * Lab Test - methods rewrite - lab test doc creation * Lab Test - create lab test from invoice and consultaion - got changed * Button History changed to Medical Record * Service Desk - Updated * Notification - Procedure Appointment * fix-get procedure prescription * fix field added to test prescription * msgprint on invoice creation * fix data on install * Merge branch erpnext/develop * fixes- minor * Setup wizard - Create Sensitivity * Appointment - Validate and Save if there is no schedule for Physician * Consultation - Button create vital signs and medical record * Review Type - New DocType * Review Detail and Treatment Plan - Childs - Consultation * Patient Medical Record - field Attach doc * Consultation - New Fields * Consultation - Manage new Fields - Medical record add action * Patient Relation - Child DocType - Patient * Patient - Patient Relation added * Patient - collapsible = 1 * Laboratory Settings - fields - message for lab test * Laboratory Settings - get message for lab test * SMS text for lab test and invoice test report * Procedure Stock Detail - Stock detail for Procedure and Template * Template Stage Detail - Stage detail for Procedure Template * Procedure Stage Detail - Stage detail for Procedure * Service Unit - field - warehouse * Scheduler - msg - content changed * Laboratory Settings - defualt - msg content * Invoice Test Report - msg print * Print Format-Changed-Consultation-Invoice Test Report-Lab Test * OP Settings - Expnse Account for Stock Entry in Procedure * Procedure and Procedure Template - Manage Stock Stage and Sample Collection * Procedure Appointment - Manage Stock and Stage * Lab Test - fixed - resource not find * Invoice Test Report - fixed - resource not find * Procedure - doc reload after insert * Patient Medical Record - fixed - refernce missed * Create Vital Signs -on client side * Rename module Medical to Healthcare * Remove In Patient (IP) Feature. * Rename - Procedure to Clinical Procedure * Remove spaces in Naming Series * Rename Duration to Drug Prescription Duration * Duration to Drug Prescription Duration * Merge All Settings to Healthcare Settings * Healthcare settings - import fixed * Procedure related documents are removed * Appointment Desk and Sevrvice Desk are removed * Consultation - minimal * Consultation - minimal * Consultation - minimal - patient detials in collapsible section * Message Print to Alerts * Patient - some fields removed * Patient - create consultation - message print to alerts * Consultation - show patient details updated * Setup wizard - Duration to Drug Prescritpion Duration * Healthcare Settings - patient registration - fee collection * Lab Test - Create Sales Invoice bug fixed * Healthcare menu rearranged * Healthcare Settings - Optimised and Rearragnged * Healthcare Settings - Expense account removed * Receivable account removed from patient * Patient - Optimised and Rearragnged * Removed Referring Physician * Healthcare Settings - bold headings removed * Physician - Patient - Fields are Segregated * Remove Service Unit * Remove - Service Type * Consultation invoice * Lab Test - invoice * Patient - Invoice * Rename Appointment to Patient Appointment * wip * Patient Dashboard, Physician Form cleanup * Dosage renamed to Prescription Dosage * Renamed Drug Prescription Duration to Prescription Duration * Patient Appointment booking modal * Patient Age - calculate by dob * Remove - scheduler * Consultation - Appointment to Patient Appointment * Patient Dashboard - rearranged * Patient Appointment * Removed rer_physician from lab test and consultation * Patient Appontment Changes * Appointment and Consultation - optimized * Patient Appointment - fee validity code optimized * Consultation and Patient Appointment - Invoice validate two side * fix: #13 remove relation to admission * Healthcare - Patient Portal * fix import error * domain Healthcare added on install * Removed - Invoice Test Report * Physician Schedule - menu * Consultation - patient details - re write * New Doctype-Medical Code * Consultation - Daignosis codification * Medical Code - Codification - Settings * Medical Code Standard - Medical Code - Codification - Settings * fix appointment calendar * fix appointment analytics * Menu Medical Code Standard * New Doctype - Medical Code Standard * Set Physician Role insted of IP Physician and OP Physician Role * fixed some json files * Medical code - permission to physician * Unused Childs - Work Schedule and User List - Removed * Label Procedure to Lab Test * Lab Test and Patient - code optimised * Add Item Groups - setup wizard * Healthcare Settings - add Role - Medical Administrator * Healthcare - Demo setup - Make Demo * Fee Validity - Logic Test * Test Fee Validity - Optimised * Healthcare Doctypes - Restricted to Domain Healthcare * Domainify - remove Healthcare Roles - Other Domains * Healthcare doctypes - beta checked * Codacy fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Lab Test - print hide =1 for some fields * Consultation - Codification field label to Medical Coding * Codacy fixes - import frappe and etc. * Codacy fixes - import frappe in test_vital_signs * Codacy fixes * Codacy fixes * Codacy fixes and remove delete perm for patient * send_sms - import form frappe * Healthcare Settings * Lab Prescription - Consultation - Test Code - read_only = 0 * Portal fixes * Patient Appointment - filter physician - if has schedule * Physician - IP Charge - Removed * test - files * Web Form - Patient Profile - removed * Role Medical Administrator to Healthcare Administrator * WIP healthcare documentation * Coday - fixes * Travis - fixes * Lab Test Report - menu * Reorder Healthcare settings - group lab config to bottom * Sample Collection - New - allow Sample and patient Selection * Rate - similar behaviour and Label as in Item Standard Selling Rate * Healthcare documentation * Lab Test Samples to Lab Test sample * Commplaints to Complaint * Commplaints to Complaint * Antibiotics to Antibiotic * Appointment Token Number - remove * View - Medical record * Codacy fixes * update healthcare docs * Cleanup Docs - Search, quick entry, trsck change, etc. * [minor] ux changes
2017-09-13 07:22:30 +00:00
from .healthcare import setup_healthcare
import install_fixtures
from .sample_data import make_sample_data
from erpnext.accounts.doctype.account.account import RootNotEditable
from frappe.core.doctype.communication.comment import add_info_comment
2016-05-11 09:43:44 +00:00
from erpnext.setup.setup_wizard.domainify import setup_domain
from erpnext.setup.doctype.company.company import install_country_fixtures
2013-10-08 12:29:11 +00:00
2015-11-09 11:23:11 +00:00
def setup_complete(args=None):
if frappe.db.sql("select name from tabCompany"):
frappe.throw(_("Setup Already Complete!!"))
install_fixtures.install(args.get("country"))
create_price_lists(args)
create_fiscal_year_and_company(args)
create_sales_tax(args)
create_employee_for_self(args)
set_defaults(args)
create_territories()
create_feed_and_todo()
create_email_digest()
create_letter_head(args)
if args.get('domain').lower() == 'education':
create_academic_year()
create_academic_term()
[domain] Healthcare (#10664) * Medical module for erpnext * Changes in core for Medical module * patient registration updated * fix - appointment invioce - fields missing * pages- indicator instead of bg-color * Lab Test field renamed service type * Department added Lab Test * procedure name in prescription * fixes sample collection * filter disabled patient * fix patient admission * updated patient age * availability check msg updated * fixes, removed procedure from invoice * sample print renamed * fixes, validation * service desk physician in filter * refactor scheduler * Appointment -field property - set only once = 1 * Appointment - Mark closed and pending buttons removed * Appointment - readonly = 1 if value set * Appointment - availabilty * Appointment - Cancel - info - cancel invoice * Appointment - set pending appointments * Dosage form - new DT * Drug Prescription - Dosage form added * Facility - Floor - removed from Fecility * Floor - removed * Lab Test Template - item creation validation * Procedure - Create Procedure * Procedure Appointment - new DT * Service Unit - Floor reference removed * Zone Fcilities - Unused DT removed * Appointment Desk - fixed * Service Desk - method pointing from procedure changed to procedure_appointment * Consultation print - got featured * Consultation - removed patient refernce to procedure prescription * Procedure Prescription - removed patient refernce * Lab Test - Changed field properties and value * Lab Test - field property changed * Lab Test - methods rewrite - lab test doc creation * Lab Test - create lab test from invoice and consultaion - got changed * Button History changed to Medical Record * Service Desk - Updated * Notification - Procedure Appointment * fix-get procedure prescription * fix field added to test prescription * msgprint on invoice creation * fix data on install * Merge branch erpnext/develop * fixes- minor * Setup wizard - Create Sensitivity * Appointment - Validate and Save if there is no schedule for Physician * Consultation - Button create vital signs and medical record * Review Type - New DocType * Review Detail and Treatment Plan - Childs - Consultation * Patient Medical Record - field Attach doc * Consultation - New Fields * Consultation - Manage new Fields - Medical record add action * Patient Relation - Child DocType - Patient * Patient - Patient Relation added * Patient - collapsible = 1 * Laboratory Settings - fields - message for lab test * Laboratory Settings - get message for lab test * SMS text for lab test and invoice test report * Procedure Stock Detail - Stock detail for Procedure and Template * Template Stage Detail - Stage detail for Procedure Template * Procedure Stage Detail - Stage detail for Procedure * Service Unit - field - warehouse * Scheduler - msg - content changed * Laboratory Settings - defualt - msg content * Invoice Test Report - msg print * Print Format-Changed-Consultation-Invoice Test Report-Lab Test * OP Settings - Expnse Account for Stock Entry in Procedure * Procedure and Procedure Template - Manage Stock Stage and Sample Collection * Procedure Appointment - Manage Stock and Stage * Lab Test - fixed - resource not find * Invoice Test Report - fixed - resource not find * Procedure - doc reload after insert * Patient Medical Record - fixed - refernce missed * Create Vital Signs -on client side * Rename module Medical to Healthcare * Remove In Patient (IP) Feature. * Rename - Procedure to Clinical Procedure * Remove spaces in Naming Series * Rename Duration to Drug Prescription Duration * Duration to Drug Prescription Duration * Merge All Settings to Healthcare Settings * Healthcare settings - import fixed * Procedure related documents are removed * Appointment Desk and Sevrvice Desk are removed * Consultation - minimal * Consultation - minimal * Consultation - minimal - patient detials in collapsible section * Message Print to Alerts * Patient - some fields removed * Patient - create consultation - message print to alerts * Consultation - show patient details updated * Setup wizard - Duration to Drug Prescritpion Duration * Healthcare Settings - patient registration - fee collection * Lab Test - Create Sales Invoice bug fixed * Healthcare menu rearranged * Healthcare Settings - Optimised and Rearragnged * Healthcare Settings - Expense account removed * Receivable account removed from patient * Patient - Optimised and Rearragnged * Removed Referring Physician * Healthcare Settings - bold headings removed * Physician - Patient - Fields are Segregated * Remove Service Unit * Remove - Service Type * Consultation invoice * Lab Test - invoice * Patient - Invoice * Rename Appointment to Patient Appointment * wip * Patient Dashboard, Physician Form cleanup * Dosage renamed to Prescription Dosage * Renamed Drug Prescription Duration to Prescription Duration * Patient Appointment booking modal * Patient Age - calculate by dob * Remove - scheduler * Consultation - Appointment to Patient Appointment * Patient Dashboard - rearranged * Patient Appointment * Removed rer_physician from lab test and consultation * Patient Appontment Changes * Appointment and Consultation - optimized * Patient Appointment - fee validity code optimized * Consultation and Patient Appointment - Invoice validate two side * fix: #13 remove relation to admission * Healthcare - Patient Portal * fix import error * domain Healthcare added on install * Removed - Invoice Test Report * Physician Schedule - menu * Consultation - patient details - re write * New Doctype-Medical Code * Consultation - Daignosis codification * Medical Code - Codification - Settings * Medical Code Standard - Medical Code - Codification - Settings * fix appointment calendar * fix appointment analytics * Menu Medical Code Standard * New Doctype - Medical Code Standard * Set Physician Role insted of IP Physician and OP Physician Role * fixed some json files * Medical code - permission to physician * Unused Childs - Work Schedule and User List - Removed * Label Procedure to Lab Test * Lab Test and Patient - code optimised * Add Item Groups - setup wizard * Healthcare Settings - add Role - Medical Administrator * Healthcare - Demo setup - Make Demo * Fee Validity - Logic Test * Test Fee Validity - Optimised * Healthcare Doctypes - Restricted to Domain Healthcare * Domainify - remove Healthcare Roles - Other Domains * Healthcare doctypes - beta checked * Codacy fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Lab Test - print hide =1 for some fields * Consultation - Codification field label to Medical Coding * Codacy fixes - import frappe and etc. * Codacy fixes - import frappe in test_vital_signs * Codacy fixes * Codacy fixes * Codacy fixes and remove delete perm for patient * send_sms - import form frappe * Healthcare Settings * Lab Prescription - Consultation - Test Code - read_only = 0 * Portal fixes * Patient Appointment - filter physician - if has schedule * Physician - IP Charge - Removed * test - files * Web Form - Patient Profile - removed * Role Medical Administrator to Healthcare Administrator * WIP healthcare documentation * Coday - fixes * Travis - fixes * Lab Test Report - menu * Reorder Healthcare settings - group lab config to bottom * Sample Collection - New - allow Sample and patient Selection * Rate - similar behaviour and Label as in Item Standard Selling Rate * Healthcare documentation * Lab Test Samples to Lab Test sample * Commplaints to Complaint * Commplaints to Complaint * Antibiotics to Antibiotic * Appointment Token Number - remove * View - Medical record * Codacy fixes * update healthcare docs * Cleanup Docs - Search, quick entry, trsck change, etc. * [minor] ux changes
2017-09-13 07:22:30 +00:00
if args.domain.lower() == 'healthcare':
setup_healthcare()
if args.get('setup_website'):
website_maker(args)
create_logo(args)
frappe.local.message_log = []
setup_domain(args.get('domain'))
frappe.db.commit()
login_as_first_user(args)
frappe.db.commit()
frappe.clear_cache()
try:
make_sample_data(args.get('domain'))
frappe.clear_cache()
except:
# clear message
if frappe.message_log:
frappe.message_log.pop()
pass
def setup_success(args=None):
company = frappe.db.sql("select name from tabCompany", as_dict=True)[0]["name"]
install_country_fixtures(company)
2013-10-08 12:29:11 +00:00
def create_fiscal_year_and_company(args):
2016-10-20 10:19:39 +00:00
if (args.get('fy_start_date')):
curr_fiscal_year = get_fy_details(args.get('fy_start_date'), args.get('fy_end_date'))
frappe.get_doc({
"doctype":"Fiscal Year",
'year': curr_fiscal_year,
'year_start_date': args.get('fy_start_date'),
'year_end_date': args.get('fy_end_date'),
2016-10-20 10:19:39 +00:00
}).insert()
args["curr_fiscal_year"] = curr_fiscal_year
# Company
if (args.get('company_name')):
frappe.get_doc({
"doctype":"Company",
2017-06-22 11:07:04 +00:00
'company_name':args.get('company_name'),
'enable_perpetual_inventory': 1,
2016-10-20 10:19:39 +00:00
'abbr':args.get('company_abbr'),
'default_currency':args.get('currency'),
'country': args.get('country'),
'create_chart_of_accounts_based_on': 'Standard Template',
'chart_of_accounts': args.get('chart_of_accounts'),
'domain': args.get('domain')
2016-10-20 10:19:39 +00:00
}).insert()
#Enable shopping cart
enable_shopping_cart(args)
# Bank Account
create_bank_account(args)
def enable_shopping_cart(args):
2016-10-20 10:19:39 +00:00
frappe.get_doc({
"doctype": "Shopping Cart Settings",
"enabled": 1,
2017-06-22 11:07:04 +00:00
'company': args.get('company_name') ,
2016-10-20 10:19:39 +00:00
'price_list': frappe.db.get_value("Price List", {"selling": 1}),
'default_customer_group': _("Individual"),
'quotation_series': "QTN-",
}).insert()
def create_bank_account(args):
2016-10-20 10:19:39 +00:00
if args.get("bank_account"):
2017-06-22 11:07:04 +00:00
company_name = args.get('company_name')
2016-10-20 10:19:39 +00:00
bank_account_group = frappe.db.get_value("Account",
{"account_type": "Bank", "is_group": 1, "root_type": "Asset",
"company": company_name})
if bank_account_group:
bank_account = frappe.get_doc({
"doctype": "Account",
'account_name': args.get("bank_account"),
'parent_account': bank_account_group,
'is_group':0,
'company': company_name,
"account_type": "Bank",
})
try:
return bank_account.insert()
except RootNotEditable:
frappe.throw(_("Bank account cannot be named as {0}").format(args.get("bank_account")))
except frappe.DuplicateEntryError:
# bank account same as a CoA entry
pass
2014-04-07 09:39:09 +00:00
2013-10-08 12:29:11 +00:00
def create_price_lists(args):
2016-10-20 10:19:39 +00:00
for pl_type, pl_name in (("Selling", _("Standard Selling")), ("Buying", _("Standard Buying"))):
frappe.get_doc({
"doctype": "Price List",
"price_list_name": pl_name,
"enabled": 1,
"buying": 1 if pl_type == "Buying" else 0,
"selling": 1 if pl_type == "Selling" else 0,
"currency": args["currency"]
}).insert()
2014-04-07 09:39:09 +00:00
2013-10-08 12:29:11 +00:00
def set_defaults(args):
2016-10-20 10:19:39 +00:00
# enable default currency
frappe.db.set_value("Currency", args.get("currency"), "enabled", 1)
global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
global_defaults.update({
'current_fiscal_year': args.get('curr_fiscal_year'),
2016-10-20 10:19:39 +00:00
'default_currency': args.get('currency'),
2017-06-22 11:07:04 +00:00
'default_company':args.get('company_name') ,
2016-10-20 10:19:39 +00:00
"country": args.get("country"),
})
global_defaults.save()
frappe.db.set_value("System Settings", None, "email_footer_address", args.get("company"))
stock_settings = frappe.get_doc("Stock Settings")
stock_settings.item_naming_by = "Item Code"
stock_settings.valuation_method = "FIFO"
stock_settings.default_warehouse = frappe.db.get_value('Warehouse', {'warehouse_name': _('Stores')})
stock_settings.stock_uom = _("Nos")
stock_settings.auto_indent = 1
stock_settings.auto_insert_price_list_rate_if_missing = 1
stock_settings.automatically_set_serial_nos_based_on_fifo = 1
stock_settings.save()
selling_settings = frappe.get_doc("Selling Settings")
selling_settings.cust_master_name = "Customer Name"
selling_settings.so_required = "No"
selling_settings.dn_required = "No"
selling_settings.allow_multiple_items = 1
2016-10-20 10:19:39 +00:00
selling_settings.save()
buying_settings = frappe.get_doc("Buying Settings")
buying_settings.supp_master_name = "Supplier Name"
buying_settings.po_required = "No"
buying_settings.pr_required = "No"
buying_settings.maintain_same_rate = 1
buying_settings.allow_multiple_items = 1
2016-10-20 10:19:39 +00:00
buying_settings.save()
notification_control = frappe.get_doc("Notification Control")
notification_control.quotation = 1
notification_control.sales_invoice = 1
notification_control.purchase_order = 1
notification_control.save()
hr_settings = frappe.get_doc("HR Settings")
hr_settings.emp_created_by = "Naming Series"
hr_settings.save()
2013-10-08 12:29:11 +00:00
domain_settings = frappe.get_doc("Domain Settings")
domain_settings.append('active_domains', dict(domain=_(args.get('domain'))))
domain_settings.save()
2013-10-08 12:29:11 +00:00
def create_feed_and_todo():
2016-10-20 10:19:39 +00:00
"""update Activity feed and create todo for creation of item, customer, vendor"""
add_info_comment(**{
"subject": _("ERPNext Setup Complete!")
})
2013-10-08 12:29:11 +00:00
def create_email_digest():
2016-10-20 10:19:39 +00:00
from frappe.utils.user import get_system_managers
system_managers = get_system_managers(only_name=True)
if not system_managers:
return
companies = frappe.db.sql_list("select name FROM `tabCompany`")
for company in companies:
if not frappe.db.exists("Email Digest", "Default Weekly Digest - " + company):
edigest = frappe.get_doc({
"doctype": "Email Digest",
"name": "Default Weekly Digest - " + company,
"company": company,
"frequency": "Weekly",
"recipient_list": "\n".join(system_managers)
})
for df in edigest.meta.get("fields", {"fieldtype": "Check"}):
if df.fieldname != "scheduler_errors":
edigest.set(df.fieldname, 1)
edigest.insert()
# scheduler errors digest
if companies:
edigest = frappe.new_doc("Email Digest")
edigest.update({
"name": "Scheduler Errors",
"company": companies[0],
"frequency": "Daily",
"recipient_list": "\n".join(system_managers),
"scheduler_errors": 1,
"enabled": 1
})
edigest.insert()
2014-04-07 09:39:09 +00:00
def get_fy_details(fy_start_date, fy_end_date):
2016-10-20 10:19:39 +00:00
start_year = getdate(fy_start_date).year
if start_year == getdate(fy_end_date).year:
fy = cstr(start_year)
else:
fy = cstr(start_year) + '-' + cstr(start_year + 1)
return fy
2016-10-20 10:19:39 +00:00
def create_sales_tax(args):
country_wise_tax = get_country_wise_tax(args.get("country"))
if country_wise_tax and len(country_wise_tax) > 0:
2016-10-20 10:19:39 +00:00
for sales_tax, tax_data in country_wise_tax.items():
2017-06-22 11:07:04 +00:00
make_tax_account_and_template(
args.get("company_name"),
tax_data.get('account_name'),
tax_data.get('tax_rate'), sales_tax)
2016-10-20 10:19:39 +00:00
# Tax utils start
2016-10-20 10:19:39 +00:00
def make_tax_account_and_template(company, account_name, tax_rate, template_name=None):
try:
2017-06-22 11:07:04 +00:00
if not isinstance(account_name, (list, tuple)):
account_name = [account_name]
tax_rate = [tax_rate]
accounts = []
for i, name in enumerate(account_name):
accounts.append(make_tax_account(company, account_name[i], tax_rate[i]))
if accounts:
make_sales_and_purchase_tax_templates(accounts, template_name)
2017-07-20 10:25:54 +00:00
except frappe.NameError:
pass
except RootNotEditable:
2016-10-20 10:19:39 +00:00
pass
2016-10-20 10:19:39 +00:00
def make_tax_account(company, account_name, tax_rate):
tax_group = get_tax_account_group(company)
if tax_group:
return frappe.get_doc({
"doctype":"Account",
"company": company,
"parent_account": tax_group,
"account_name": account_name,
"is_group": 0,
"report_type": "Balance Sheet",
"root_type": "Liability",
"account_type": "Tax",
"tax_rate": flt(tax_rate) if tax_rate else None
}).insert(ignore_permissions=True)
2017-06-22 11:07:04 +00:00
def make_sales_and_purchase_tax_templates(accounts, template_name=None):
2016-10-20 10:19:39 +00:00
if not template_name:
2017-06-22 11:07:04 +00:00
template_name = accounts[0].name
2016-10-20 10:19:39 +00:00
sales_tax_template = {
"doctype": "Sales Taxes and Charges Template",
"title": template_name,
2017-06-22 11:07:04 +00:00
"company": accounts[0].company,
'taxes': []
}
for account in accounts:
sales_tax_template['taxes'].append({
2016-10-20 10:19:39 +00:00
"category": "Valuation and Total",
"charge_type": "On Net Total",
"account_head": account.name,
"description": "{0} @ {1}".format(account.account_name, account.tax_rate),
"rate": account.tax_rate
2017-06-22 11:07:04 +00:00
})
2016-10-20 10:19:39 +00:00
# Sales
frappe.get_doc(copy.deepcopy(sales_tax_template)).insert(ignore_permissions=True)
2016-10-20 10:19:39 +00:00
# Purchase
purchase_tax_template = copy.deepcopy(sales_tax_template)
purchase_tax_template["doctype"] = "Purchase Taxes and Charges Template"
2017-06-22 11:07:04 +00:00
doc = frappe.get_doc(purchase_tax_template)
doc.insert(ignore_permissions=True)
2013-10-08 12:29:11 +00:00
def get_tax_account_group(company):
tax_group = frappe.db.get_value("Account",
{"account_name": "Duties and Taxes", "is_group": 1, "company": company})
if not tax_group:
tax_group = frappe.db.get_value("Account", {"is_group": 1, "root_type": "Liability",
"account_type": "Tax", "company": company})
return tax_group
2015-04-23 07:44:17 +00:00
# Tax utils end
2015-04-23 07:44:17 +00:00
def get_country_wise_tax(country):
data = {}
with open (os.path.join(os.path.dirname(__file__), "data", "country_wise_tax.json")) as countrywise_tax:
data = json.load(countrywise_tax).get(country)
2015-07-23 07:09:44 +00:00
return data
def create_letter_head(args):
2016-10-20 10:19:39 +00:00
if args.get("attach_letterhead"):
frappe.get_doc({
"doctype":"Letter Head",
"letter_head_name": _("Standard"),
"is_default": 1
}).insert()
attach_letterhead = args.get("attach_letterhead").split(",")
if len(attach_letterhead)==3:
filename, filetype, content = attach_letterhead
fileurl = save_file(filename, content, "Letter Head", _("Standard"), decode=True).file_url
frappe.db.set_value("Letter Head", _("Standard"), "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
2014-04-07 09:39:09 +00:00
def create_logo(args):
2016-10-20 10:19:39 +00:00
if args.get("attach_logo"):
attach_logo = args.get("attach_logo").split(",")
if len(attach_logo)==3:
filename, filetype, content = attach_logo
fileurl = save_file(filename, content, "Website Settings", "Website Settings",
decode=True).file_url
frappe.db.set_value("Website Settings", "Website Settings", "brand_html",
2017-06-22 11:07:04 +00:00
"<img src='{0}' style='max-width: 40px; max-height: 25px;'> {1}".format(fileurl, args.get("company_name") ))
2013-10-08 12:29:11 +00:00
def create_territories():
2016-10-20 10:19:39 +00:00
"""create two default territories, one for home country and one named Rest of the World"""
from frappe.utils.nestedset import get_root_of
country = frappe.db.get_default("country")
root_territory = get_root_of("Territory")
for name in (country, _("Rest Of The World")):
if name and not frappe.db.exists("Territory", name):
frappe.get_doc({
"doctype": "Territory",
"territory_name": name.replace("'", ""),
"parent_territory": root_territory,
"is_group": "No"
}).insert()
def login_as_first_user(args):
2016-10-20 10:19:39 +00:00
if args.get("email") and hasattr(frappe.local, "login_manager"):
frappe.local.login_manager.login_as(args.get("email"))
def create_employee_for_self(args):
2016-10-20 10:19:39 +00:00
if frappe.session.user == 'Administrator':
return
# create employee for self
emp = frappe.get_doc({
"doctype": "Employee",
"employee_name": " ".join(filter(None, [args.get("first_name"), args.get("last_name")])),
"user_id": frappe.session.user,
"status": "Active",
"company": args.get("company_name")
})
emp.flags.ignore_mandatory = True
emp.insert(ignore_permissions = True)
# Schools
def create_academic_term():
2016-10-20 10:19:39 +00:00
at = ["Semester 1", "Semester 2", "Semester 3"]
ay = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
for y in ay:
for t in at:
academic_term = frappe.new_doc("Academic Term")
academic_term.academic_year = y
academic_term.term_name = t
try:
academic_term.save()
except frappe.DuplicateEntryError:
pass
def create_academic_year():
2016-10-20 10:19:39 +00:00
ac = ["2013-14", "2014-15", "2015-16", "2016-17", "2017-18"]
for d in ac:
academic_year = frappe.new_doc("Academic Year")
academic_year.academic_year_name = d
try:
academic_year.save()
except frappe.DuplicateEntryError:
pass
[domain] Healthcare (#10664) * Medical module for erpnext * Changes in core for Medical module * patient registration updated * fix - appointment invioce - fields missing * pages- indicator instead of bg-color * Lab Test field renamed service type * Department added Lab Test * procedure name in prescription * fixes sample collection * filter disabled patient * fix patient admission * updated patient age * availability check msg updated * fixes, removed procedure from invoice * sample print renamed * fixes, validation * service desk physician in filter * refactor scheduler * Appointment -field property - set only once = 1 * Appointment - Mark closed and pending buttons removed * Appointment - readonly = 1 if value set * Appointment - availabilty * Appointment - Cancel - info - cancel invoice * Appointment - set pending appointments * Dosage form - new DT * Drug Prescription - Dosage form added * Facility - Floor - removed from Fecility * Floor - removed * Lab Test Template - item creation validation * Procedure - Create Procedure * Procedure Appointment - new DT * Service Unit - Floor reference removed * Zone Fcilities - Unused DT removed * Appointment Desk - fixed * Service Desk - method pointing from procedure changed to procedure_appointment * Consultation print - got featured * Consultation - removed patient refernce to procedure prescription * Procedure Prescription - removed patient refernce * Lab Test - Changed field properties and value * Lab Test - field property changed * Lab Test - methods rewrite - lab test doc creation * Lab Test - create lab test from invoice and consultaion - got changed * Button History changed to Medical Record * Service Desk - Updated * Notification - Procedure Appointment * fix-get procedure prescription * fix field added to test prescription * msgprint on invoice creation * fix data on install * Merge branch erpnext/develop * fixes- minor * Setup wizard - Create Sensitivity * Appointment - Validate and Save if there is no schedule for Physician * Consultation - Button create vital signs and medical record * Review Type - New DocType * Review Detail and Treatment Plan - Childs - Consultation * Patient Medical Record - field Attach doc * Consultation - New Fields * Consultation - Manage new Fields - Medical record add action * Patient Relation - Child DocType - Patient * Patient - Patient Relation added * Patient - collapsible = 1 * Laboratory Settings - fields - message for lab test * Laboratory Settings - get message for lab test * SMS text for lab test and invoice test report * Procedure Stock Detail - Stock detail for Procedure and Template * Template Stage Detail - Stage detail for Procedure Template * Procedure Stage Detail - Stage detail for Procedure * Service Unit - field - warehouse * Scheduler - msg - content changed * Laboratory Settings - defualt - msg content * Invoice Test Report - msg print * Print Format-Changed-Consultation-Invoice Test Report-Lab Test * OP Settings - Expnse Account for Stock Entry in Procedure * Procedure and Procedure Template - Manage Stock Stage and Sample Collection * Procedure Appointment - Manage Stock and Stage * Lab Test - fixed - resource not find * Invoice Test Report - fixed - resource not find * Procedure - doc reload after insert * Patient Medical Record - fixed - refernce missed * Create Vital Signs -on client side * Rename module Medical to Healthcare * Remove In Patient (IP) Feature. * Rename - Procedure to Clinical Procedure * Remove spaces in Naming Series * Rename Duration to Drug Prescription Duration * Duration to Drug Prescription Duration * Merge All Settings to Healthcare Settings * Healthcare settings - import fixed * Procedure related documents are removed * Appointment Desk and Sevrvice Desk are removed * Consultation - minimal * Consultation - minimal * Consultation - minimal - patient detials in collapsible section * Message Print to Alerts * Patient - some fields removed * Patient - create consultation - message print to alerts * Consultation - show patient details updated * Setup wizard - Duration to Drug Prescritpion Duration * Healthcare Settings - patient registration - fee collection * Lab Test - Create Sales Invoice bug fixed * Healthcare menu rearranged * Healthcare Settings - Optimised and Rearragnged * Healthcare Settings - Expense account removed * Receivable account removed from patient * Patient - Optimised and Rearragnged * Removed Referring Physician * Healthcare Settings - bold headings removed * Physician - Patient - Fields are Segregated * Remove Service Unit * Remove - Service Type * Consultation invoice * Lab Test - invoice * Patient - Invoice * Rename Appointment to Patient Appointment * wip * Patient Dashboard, Physician Form cleanup * Dosage renamed to Prescription Dosage * Renamed Drug Prescription Duration to Prescription Duration * Patient Appointment booking modal * Patient Age - calculate by dob * Remove - scheduler * Consultation - Appointment to Patient Appointment * Patient Dashboard - rearranged * Patient Appointment * Removed rer_physician from lab test and consultation * Patient Appontment Changes * Appointment and Consultation - optimized * Patient Appointment - fee validity code optimized * Consultation and Patient Appointment - Invoice validate two side * fix: #13 remove relation to admission * Healthcare - Patient Portal * fix import error * domain Healthcare added on install * Removed - Invoice Test Report * Physician Schedule - menu * Consultation - patient details - re write * New Doctype-Medical Code * Consultation - Daignosis codification * Medical Code - Codification - Settings * Medical Code Standard - Medical Code - Codification - Settings * fix appointment calendar * fix appointment analytics * Menu Medical Code Standard * New Doctype - Medical Code Standard * Set Physician Role insted of IP Physician and OP Physician Role * fixed some json files * Medical code - permission to physician * Unused Childs - Work Schedule and User List - Removed * Label Procedure to Lab Test * Lab Test and Patient - code optimised * Add Item Groups - setup wizard * Healthcare Settings - add Role - Medical Administrator * Healthcare - Demo setup - Make Demo * Fee Validity - Logic Test * Test Fee Validity - Optimised * Healthcare Doctypes - Restricted to Domain Healthcare * Domainify - remove Healthcare Roles - Other Domains * Healthcare doctypes - beta checked * Codacy fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Codacy - fixes * Lab Test - print hide =1 for some fields * Consultation - Codification field label to Medical Coding * Codacy fixes - import frappe and etc. * Codacy fixes - import frappe in test_vital_signs * Codacy fixes * Codacy fixes * Codacy fixes and remove delete perm for patient * send_sms - import form frappe * Healthcare Settings * Lab Prescription - Consultation - Test Code - read_only = 0 * Portal fixes * Patient Appointment - filter physician - if has schedule * Physician - IP Charge - Removed * test - files * Web Form - Patient Profile - removed * Role Medical Administrator to Healthcare Administrator * WIP healthcare documentation * Coday - fixes * Travis - fixes * Lab Test Report - menu * Reorder Healthcare settings - group lab config to bottom * Sample Collection - New - allow Sample and patient Selection * Rate - similar behaviour and Label as in Item Standard Selling Rate * Healthcare documentation * Lab Test Samples to Lab Test sample * Commplaints to Complaint * Commplaints to Complaint * Antibiotics to Antibiotic * Appointment Token Number - remove * View - Medical record * Codacy fixes * update healthcare docs * Cleanup Docs - Search, quick entry, trsck change, etc. * [minor] ux changes
2017-09-13 07:22:30 +00:00