From 74506e96d35eeae05dd23d9593cb0d055fc6ade9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 17:52:14 +0530 Subject: [PATCH] [profile/email] [feature] added option not to send print as email body. fix in profile delete --- accounts/page/accounts_home/accounts_home.js | 10 ++++ buying/doctype/supplier/supplier.py | 14 ++++- patches/patch_list.py | 1 + .../doctype/email_settings/email_settings.txt | 27 +++++---- startup/boot.py | 50 +++++++++++++++++ startup/event_handlers.py | 56 +++---------------- 6 files changed, 94 insertions(+), 64 deletions(-) create mode 100644 startup/boot.py diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 403d7bdb3f..9981ee9a97 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -39,6 +39,16 @@ wn.module_page["Accounts"] = [ description: wn._("Structure cost centers for budgeting."), doctype:"Cost Center" }, + { + label: wn._("Customer"), + description: wn._("Customer database."), + doctype:"Customer" + }, + { + label: wn._("Supplier"), + description: wn._("Supplier database."), + doctype:"Supplier" + }, ] }, { diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 3af63b022a..6658db3135 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -106,9 +106,9 @@ class DocType(TransactionBase): def create_account_head(self): if self.doc.company : abbr = self.get_company_abbr() + parent_account = self.get_parent_account(abbr) if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)): - parent_account = self.get_parent_account(abbr) ac = add_ac({ 'account_name': self.doc.name, @@ -121,10 +121,18 @@ class DocType(TransactionBase): 'master_name': self.doc.name, }) msgprint(_("Created Account Head: ") + ac) - + else: + self.check_parent_account(parent_account, abbr) else : msgprint("Please select Company under which you want to create account head") - + + def check_parent_account(self, parent_account, abbr): + if webnotes.conn.get_value("Account", self.doc.name + " - " + abbr, + "parent_account") != parent_account: + ac = webnotes.bean("Account", self.doc.name + " - " + abbr) + ac.doc.parent_account = parent_account + ac.save() + def get_contacts(self,nm): if nm: contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm)) diff --git a/patches/patch_list.py b/patches/patch_list.py index fc9855d096..00dd5da200 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -217,4 +217,5 @@ patch_list = [ "execute:webnotes.bean('Global Defaults').save()", "patches.march_2013.p07_update_project_in_stock_ledger", "execute:webnotes.bean('Style Settings').save() #2013-03-25", + "execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)" ] \ No newline at end of file diff --git a/setup/doctype/email_settings/email_settings.txt b/setup/doctype/email_settings/email_settings.txt index 994d4c9100..1de2c93045 100644 --- a/setup/doctype/email_settings/email_settings.txt +++ b/setup/doctype/email_settings/email_settings.txt @@ -1,13 +1,12 @@ [ { - "creation": "2012-07-03 13:30:55", + "creation": "2012-07-12 23:29:44", "docstatus": 0, - "modified": "2012-07-12 16:16:27", + "modified": "2013-03-25 17:32:05", "modified_by": "Administrator", "owner": "harshada@webnotestech.com" }, { - "_last_update": "1325570647", "allow_copy": 1, "allow_email": 1, "allow_print": 1, @@ -16,9 +15,7 @@ "in_create": 1, "issingle": 1, "module": "Setup", - "name": "__common__", - "section_style": "Simple", - "version": 1 + "name": "__common__" }, { "doctype": "DocField", @@ -37,19 +34,15 @@ "parenttype": "DocType", "permlevel": 0, "read": 1, + "report": 0, "role": "System Manager", + "submit": 0, "write": 1 }, { "doctype": "DocType", "name": "Email Settings" }, - { - "doctype": "DocPerm" - }, - { - "doctype": "DocPerm" - }, { "description": "Set your outgoing mail SMTP settings here. All system generated notifications, emails will go from this mail server. If you are not sure, leave this blank to use ERPNext servers (emails will still be sent from your email id) or contact your email provider.", "doctype": "DocField", @@ -102,6 +95,13 @@ "fieldtype": "Data", "label": "Auto Email Id" }, + { + "description": "If checked, an email with an attached HTML format will be added to part of the EMail body as well as attachment. To only send as attachment, uncheck this.", + "doctype": "DocField", + "fieldname": "send_print_in_body_and_attachment", + "fieldtype": "Check", + "label": "Send Print in Body and Attachment" + }, { "description": "Set the POP3 email settings to pull emails directly from a mailbox and create Support Tickets", "doctype": "DocField", @@ -180,5 +180,8 @@ "fieldname": "support_autoreply", "fieldtype": "Text", "label": "Custom Autoreply Message" + }, + { + "doctype": "DocPerm" } ] \ No newline at end of file diff --git a/startup/boot.py b/startup/boot.py new file mode 100644 index 0000000000..574646f959 --- /dev/null +++ b/startup/boot.py @@ -0,0 +1,50 @@ +# ERPNext: Copyright 2013 Web Notes Technologies Pvt Ltd +# GNU General Public License. See "license.txt" + + +from __future__ import unicode_literals +import webnotes +import home + +def boot_session(bootinfo): + """boot session - send website info if guest""" + import webnotes + import webnotes.model.doc + + bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' + bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings') + + if webnotes.session['user']=='Guest': + bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, + parent_label, parentfield + from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1) + bootinfo['startup_code'] = \ + webnotes.conn.get_value('Website Settings', None, 'startup_code') + else: + bootinfo['letter_heads'] = get_letter_heads() + + import webnotes.model.doctype + bootinfo['notification_settings'] = webnotes.doc("Notification Control", + "Notification Control").get_values() + + bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') + + # if no company, show a dialog box to create a new company + bootinfo['setup_complete'] = webnotes.conn.sql("""select name from + tabCompany limit 1""") and 'Yes' or 'No' + + # load subscription info + import conf + for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']: + if hasattr(conf, key): bootinfo[key] = getattr(conf, key) + + bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", + as_dict=1, update={"doctype":":Company"}) + +def get_letter_heads(): + """load letter heads with startup""" + import webnotes + ret = webnotes.conn.sql("""select name, content from `tabLetter Head` + where ifnull(disabled,0)=0""") + return dict(ret) + \ No newline at end of file diff --git a/startup/event_handlers.py b/startup/event_handlers.py index 0b64ddf03d..f0c73a542b 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -31,55 +31,6 @@ def on_login_post_session(login_manager): login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D') webnotes.conn.commit() - -def comment_added(doc): - """add comment to feed""" - home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by, - '"' + doc.comment + '"', '#6B24B3') - -def boot_session(bootinfo): - """boot session - send website info if guest""" - import webnotes - import webnotes.model.doc - - bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' - bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings') - - if webnotes.session['user']=='Guest': - bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, - parent_label, parentfield - from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1) - bootinfo['startup_code'] = \ - webnotes.conn.get_value('Website Settings', None, 'startup_code') - else: - bootinfo['letter_heads'] = get_letter_heads() - - import webnotes.model.doctype - bootinfo['notification_settings'] = webnotes.doc("Notification Control", - "Notification Control").get_values() - - bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') - - # if no company, show a dialog box to create a new company - bootinfo['setup_complete'] = webnotes.conn.sql("""select name from - tabCompany limit 1""") and 'Yes' or 'No' - - # load subscription info - import conf - for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']: - if hasattr(conf, key): bootinfo[key] = getattr(conf, key) - - bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", - as_dict=1, update={"doctype":":Company"}) - -def get_letter_heads(): - """load letter heads with startup""" - import webnotes - ret = webnotes.conn.sql("""select name, content from `tabLetter Head` - where ifnull(disabled,0)=0""") - return dict(ret) - - def check_if_expired(): """check if account is expired. If expired, do not allow login""" import conf @@ -106,3 +57,10 @@ def check_if_expired(): webnotes.response['message'] = 'Account Expired' raise webnotes.AuthenticationError + + +def comment_added(doc): + """add comment to feed""" + home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by, + '"' + doc.comment + '"', '#6B24B3') + \ No newline at end of file