[refactor modules]

This commit is contained in:
Rushabh Mehta 2014-09-09 12:38:21 +05:30
parent 1aea75261d
commit ed37cef32a
31 changed files with 18 additions and 339 deletions

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint
from frappe.utils.email_lib.receive import POP3Mailbox
from frappe.email.receive import POP3Mailbox
from frappe.core.doctype.communication.communication import _make
class JobsMailbox(POP3Mailbox):

View File

@ -185,7 +185,7 @@ class SalarySlip(TransactionBase):
def send_mail_funct(self):
from frappe.utils.email_lib import sendmail
from frappe.email import sendmail
receiver = frappe.db.get_value("Employee", self.employee, "company_email")
if receiver:

View File

@ -7,7 +7,7 @@ import json
import re
from frappe.model.naming import make_autoname
from frappe.utils import cint
from frappe.utils.email_lib import sendmail_to_system_managers
from frappe.email import sendmail_to_system_managers
doctype_series_map = {
'Attendance': 'ATT-',

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.core.doctype.custom_field.custom_field import create_custom_field_if_values_exist
from frappe.custom.doctype.custom_field.custom_field import create_custom_field_if_values_exist
def execute():
frappe.reload_doc("stock", "doctype", "purchase_receipt")

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.country_info import get_all
from frappe.geo.country_info import get_all
from erpnext.setup.install import import_country_and_currency
def execute():

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.core.doctype.property_setter.property_setter import make_property_setter
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
doctype_series_map = {
'Attendance': 'ATT-',

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import frappe
from frappe.country_info import get_country_info
from frappe.geo.country_info import get_country_info
from erpnext.setup.install import add_country_and_currency
def execute():

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint
from frappe.utils.email_lib.receive import POP3Mailbox
from frappe.email.receive import POP3Mailbox
from frappe.core.doctype.communication.communication import _make
def add_sales_communication(subject, content, sender, real_name, mail=None,

View File

@ -57,7 +57,7 @@ def take_backups_gdrive():
send_email(False, "Google Drive", error_message)
def send_email(success, service_name, error_status=None):
from frappe.utils.email_lib import sendmail
from frappe.email import sendmail
if success:
subject = "Backup Upload Successful"
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you

View File

@ -1 +0,0 @@
Country Master.

View File

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

View File

@ -1,107 +0,0 @@
{
"allow_import": 1,
"autoname": "field:country_name",
"creation": "2013-01-19 10:23:30",
"docstatus": 0,
"doctype": "DocType",
"document_type": "Master",
"fields": [
{
"fieldname": "country_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Country Name",
"oldfieldname": "country_name",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 1
},
{
"fieldname": "date_format",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Date Format",
"permlevel": 0
},
{
"fieldname": "time_zones",
"fieldtype": "Text",
"in_list_view": 1,
"label": "Time Zones",
"permlevel": 0
},
{
"fieldname": "code",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Code",
"permlevel": 0
}
],
"icon": "icon-globe",
"idx": 1,
"in_create": 0,
"modified": "2014-05-27 03:49:08.984710",
"modified_by": "Administrator",
"module": "Setup",
"name": "Country",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Master Manager",
"submit": 0,
"write": 1
},
{
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Master Manager",
"submit": 0,
"write": 1
},
{
"apply_user_permissions": 1,
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "HR User",
"submit": 0,
"write": 1
},
{
"create": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "HR Manager",
"submit": 0,
"write": 1
},
{
"apply_user_permissions": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "All"
}
],
"read_only": 0
}

View File

@ -1,10 +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.model.document import Document
class Country(Document):
pass

View File

@ -1,6 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
test_records = frappe.get_test_records('Country')

View File

@ -1,6 +0,0 @@
[
{
"country_name": "_Test Country",
"doctype": "Country"
}
]

View File

@ -1 +0,0 @@
Currency Master with details about abbreviation, symbol etc.

View File

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

View File

@ -1,9 +0,0 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.refresh = function(doc) {
cur_frm.set_intro("");
if(!cur_frm.doc.enabled) {
cur_frm.set_intro(__("This Currency is disabled. Enable to use in transactions"))
}
}

View File

@ -1,117 +0,0 @@
{
"autoname": "field:currency_name",
"creation": "2013-01-28 10:06:02",
"description": "**Currency** Master",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "currency_name",
"fieldtype": "Data",
"label": "Currency Name",
"oldfieldname": "currency_name",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 1
},
{
"fieldname": "enabled",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Enabled",
"permlevel": 0
},
{
"description": "Sub-currency. For e.g. \"Cent\"",
"fieldname": "fraction",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Fraction",
"permlevel": 0
},
{
"description": "1 Currency = [?] Fraction\nFor e.g. 1 USD = 100 Cent",
"fieldname": "fraction_units",
"fieldtype": "Int",
"in_list_view": 1,
"label": "Fraction Units",
"permlevel": 0
},
{
"description": "A symbol for this currency. For e.g. $",
"fieldname": "symbol",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Symbol",
"permlevel": 0
},
{
"description": "How should this currency be formatted? If not set, will use system defaults",
"fieldname": "number_format",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Number Format",
"options": "\n#,###.##\n#.###,##\n# ###.##\n# ###,##\n#'###.##\n#, ###.##\n#,##,###.##\n#,###.###\n#.###\n#,###",
"permlevel": 0
}
],
"icon": "icon-bitcoin",
"idx": 1,
"in_create": 0,
"modified": "2014-06-18 03:49:09.038451",
"modified_by": "Administrator",
"module": "Setup",
"name": "Currency",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Accounts Manager",
"submit": 0,
"write": 1
},
{
"amend": 0,
"create": 1,
"delete": 1,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Sales Master Manager",
"submit": 0,
"write": 1
},
{
"amend": 0,
"create": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "Purchase Master Manager",
"submit": 0,
"write": 1
},
{
"apply_user_permissions": 1,
"delete": 0,
"email": 1,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "All"
}
],
"read_only": 0
}

View File

@ -1,21 +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 import throw, _
from frappe.model.document import Document
class Currency(Document):
def validate(self):
frappe.clear_cache()
def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
"""common validation for currency and price list currency"""
company_currency = frappe.db.get_value("Company", company, "default_currency")
if not conversion_rate:
throw(_("{0} is mandatory. Maybe Currency Exchange record is not created for {1} to {2}.").format(
conversion_rate_label, currency, company_currency))

View File

@ -1,7 +0,0 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
# pre loaded
import frappe
test_records = frappe.get_test_records('Currency')

View File

@ -9,7 +9,7 @@ from frappe.utils import fmt_money, formatdate, now_datetime, cstr, esc, \
from frappe.utils.dateutils import datetime_in_user_format
from datetime import timedelta
from dateutil.relativedelta import relativedelta
from frappe.utils.email_lib import sendmail
from frappe.email import sendmail
from frappe.core.doctype.user.user import STANDARD_USERS
content_sequence = [

View File

@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe
import frappe.defaults
from frappe.utils import cint
from frappe.core.doctype.property_setter.property_setter import make_property_setter
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
keydict = {
# "key in defaults": "key in Global Defaults"

View File

@ -135,7 +135,7 @@ class NamingSeries(Document):
msgprint(_("Please select prefix first"))
def set_by_naming_series(doctype, fieldname, naming_series, hide_name_field=True):
from frappe.core.doctype.property_setter.property_setter import make_property_setter
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
if naming_series:
make_property_setter(doctype, "naming_series", "hidden", 0, "Check")
make_property_setter(doctype, "naming_series", "reqd", 1, "Check")

View File

@ -13,7 +13,6 @@ default_mail_footer = """<div style="padding: 7px; text-align: right; color: #88
def after_install():
frappe.get_doc({'doctype': "Role", "role_name": "Analytics"}).insert()
set_single_defaults()
import_country_and_currency()
from erpnext.accounts.doctype.chart_of_accounts.import_charts import import_charts
import_charts()
frappe.db.set_default('desktop:home_page', 'setup-wizard')
@ -22,38 +21,6 @@ def after_install():
add_all_roles_to("Administrator")
frappe.db.commit()
def import_country_and_currency():
from frappe.country_info import get_all
data = get_all()
for name in data:
country = frappe._dict(data[name])
add_country_and_currency(name, country)
# enable frequently used currencies
for currency in ("INR", "USD", "GBP", "EUR", "AED", "AUD", "JPY", "CNY", "CHF"):
frappe.db.set_value("Currency", currency, "enabled", 1)
def add_country_and_currency(name, country):
if not frappe.db.exists("Country", name):
frappe.get_doc({
"doctype": "Country",
"country_name": name,
"code": country.code,
"date_format": country.date_format or "dd-mm-yyyy",
"time_zones": "\n".join(country.timezones or [])
}).insert()
if country.currency and not frappe.db.exists("Currency", country.currency):
frappe.get_doc({
"doctype": "Currency",
"currency_name": country.currency,
"fraction": country.currency_fraction,
"symbol": country.currency_symbol,
"fraction_units": country.currency_fraction_units,
"number_format": country.number_format
}).insert()
def feature_setup():
"""save global defaults and features setup"""
doc = frappe.get_doc("Features Setup", "Features Setup")

View File

@ -8,7 +8,7 @@ from frappe.utils import cstr, flt, getdate
from frappe import _
from frappe.utils.file_manager import save_file
from frappe.translate import set_default_language, get_dict, get_lang_dict, send_translations
from frappe.country_info import get_country_info
from frappe.geo.country_info import get_country_info
from frappe.utils.nestedset import get_root_of
from default_website import website_maker
import install_fixtures

View File

@ -6,7 +6,7 @@ from frappe import _
import json
from frappe.utils import flt, cstr, nowdate, add_days, cint
from frappe.defaults import get_global_default
from frappe.utils.email_lib import sendmail
from frappe.email import sendmail
from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
class InvalidWarehouseCompany(frappe.ValidationError): pass

View File

@ -94,7 +94,7 @@ class Newsletter(Document):
sender = self.send_from or frappe.utils.get_formatted_email(self.owner)
from frappe.utils.email_lib.bulk import send
from frappe.email.bulk import send
if not frappe.flags.in_test:
frappe.db.auto_commit_on_many_writes = True

View File

@ -8,7 +8,7 @@ import frappe
from frappe import _
from frappe.utils import cint
from frappe.model.document import Document
from frappe.utils.email_lib.receive import POP3Mailbox
from frappe.email.receive import POP3Mailbox
import _socket, poplib
class SupportEmailSettings(Document):

View File

@ -4,8 +4,8 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, cint, decode_dict, today
from frappe.utils.email_lib import sendmail
from frappe.utils.email_lib.receive import POP3Mailbox
from frappe.email import sendmail
from frappe.email.receive import POP3Mailbox
from frappe.core.doctype.communication.communication import _make
class SupportMailbox(POP3Mailbox):