[minor] plugin architecture, first cut

This commit is contained in:
Anand Doshi
2013-10-14 18:59:16 +05:30
parent 6bc48070a1
commit 3510764e7c
5 changed files with 30 additions and 27 deletions

View File

@@ -15,13 +15,14 @@ def execute():
- Write to file
- Delete custom script record
"""
import os
from webnotes.utils import get_site_base_path
from core.doctype.custom_script.custom_script import make_custom_server_script_file
for name, dt, script in webnotes.conn.sql("""select name, dt, script from `tabCustom Script`
where script_type='Server'"""):
if script.strip():
script = indent_using_tabs(script)
make_custom_server_script_file(dt, script)
webnotes.delete_doc("Custom Script", name)
def indent_using_tabs(script):
for line in script.split("\n"):

View File

@@ -1,13 +1,16 @@
from __future__ import unicode_literals
import webnotes
def on_login(self):
from webnotes.utils import validate_email_add
from webnotes import conf
if "demo_notify_url" in conf:
if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email):
import requests
response = requests.post(conf.demo_notify_url, data={
"cmd":"portal.utils.send_message",
"subject":"Logged into Demo",
"sender": webnotes.form_dict.lead_email,
"message": "via demo.erpnext.com"
})
class CustomDocType(DocType):
def on_login(self):
from webnotes.utils import validate_email_add
from webnotes import conf
if "demo_notify_url" in conf:
if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email):
import requests
response = requests.post(conf.demo_notify_url, data={
"cmd":"portal.utils.send_message",
"subject":"Logged into Demo",
"sender": webnotes.form_dict.lead_email,
"message": "via demo.erpnext.com"
})

View File

@@ -1,5 +1,5 @@
Data Import Template,,,,,,,,,,,,,,,,,,,,,,,,,,
Table:,Lead,,,,,,,,,,,,,,,,,,,,,,,,,,
Table:,Lead,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,
Notes:,,,,,,,,,,,,,,,,,,,,,,,,,,
@@ -11,11 +11,11 @@ Only mandatory fields are necessary for new records. You can delete non-mandator
"If you are uploading new records, ""Naming Series"" becomes mandatory, if present.",,,,,,,,,,,,,,,,,,,,,,,,,,
You can only upload upto 5000 records in one go. (may be less in some cases),,,,,,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,,,
Column Labels,ID,Contact Name,Status,Naming Series,Company Name,Email Id,Source,From Customer,Campaign Name,Remark,Phone,Mobile No.,Fax,Website,Territory,Lead Type,Lead Owner,Market Segment,Industry,Request Type,Next Contact By,Next Contact Date,Last Contact Date,Company,Unsubscribed,Blog Subscriber
Column Name:,name,lead_name,status,naming_series,company_name,email_id,source,customer,campaign_name,remark,phone,mobile_no,fax,website,territory,type,lead_owner,market_segment,industry,request_type,contact_by,contact_date,last_contact_date,company,unsubscribed,blog_subscriber
Mandatory:,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No
Type:,Data (text),Data,Select,Select,Data,Data,Select,Link,Link,Small Text,Data,Data,Data,Data,Link,Select,Link,Select,Link,Select,Link,Date,Date,Link,Check,Check
Info:,,,"Lead, Open, Replied, Opportunity, Interested, Converted, Do Not Contact","One of: LEAD, LEAD/10-11/, LEAD/MUMBAI/",,,"One of: Advertisement, Blog Post, Campaign, Call, Customer, Exhibition, Supplier, Website, Email",Valid Customer,Valid Campaign,,,,,,Valid Territory,"One of: Client, Channel Partner, Consultant",Valid Profile,"One of: Lower Income, Middle Income, Upper Income",Valid Industry Type,"One of: Product Enquiry, Request for Information, Suggestions, Other",Valid Profile,,,Valid Company,0 or 1,0 or 1
Column Labels,ID,Contact Name,Status,Naming Series,Company Name,Email Id,Source,From Customer,Campaign Name,Remark,Phone,Mobile No.,Fax,Website,Territory,Lead Type,Lead Owner,Market Segment,Industry,Request Type,Next Contact By,Next Contact Date,Company,Unsubscribed,Blog Subscriber,
Column Name:,name,lead_name,status,naming_series,company_name,email_id,source,customer,campaign_name,remark,phone,mobile_no,fax,website,territory,type,lead_owner,market_segment,industry,request_type,contact_by,contact_date,company,unsubscribed,blog_subscriber,
Mandatory:,Yes,Yes,Yes,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,No,
Type:,Data (text),Data,Select,Select,Data,Data,Select,Link,Link,Small Text,Data,Data,Data,Data,Link,Select,Link,Select,Link,Select,Link,Date,Link,Check,Check,
Info:,,,"Lead, Open, Replied, Opportunity, Interested, Converted, Do Not Contact","One of: LEAD, LEAD/10-11/, LEAD/MUMBAI/",,,"One of: Advertisement, Blog Post, Campaign, Call, Customer, Exhibition, Supplier, Website, Email",Valid Customer,Valid Campaign,,,,,,Valid Territory,"One of: Client, Channel Partner, Consultant",Valid Profile,"One of: Lower Income, Middle Income, Upper Income",Valid Industry Type,"One of: Product Enquiry, Request for Information, Suggestions, Other",Valid Profile,,Valid Company,0 or 1,0 or 1,
Start entering data below this line,,,,,,,,,,,,,,,,,,,,,,,,,,
,,Mart Lakeman,Lead,,Zany Brainy,MartLakeman@einrot.com,,,,,,,,,,,,,,,,,,,,
,,Saga Lundqvist,Lead,,Patterson-Fletcher,SagaLundqvist@dayrep.com,,,,,,,,,,,,,,,,,,,,
1 Data Import Template
2 Table: Lead
3
4
5 Notes:
11 If you are uploading new records, "Naming Series" becomes mandatory, if present.
12 You can only upload upto 5000 records in one go. (may be less in some cases)
13
14 Column Labels ID Contact Name Status Naming Series Company Name Email Id Source From Customer Campaign Name Remark Phone Mobile No. Fax Website Territory Lead Type Lead Owner Market Segment Industry Request Type Next Contact By Next Contact Date Last Contact Date Company Company Unsubscribed Unsubscribed Blog Subscriber Blog Subscriber
15 Column Name: name lead_name status naming_series company_name email_id source customer campaign_name remark phone mobile_no fax website territory type lead_owner market_segment industry request_type contact_by contact_date last_contact_date company company unsubscribed unsubscribed blog_subscriber blog_subscriber
16 Mandatory: Yes Yes Yes No No No No No No No No No No No No No No No No No No No No No No No
17 Type: Data (text) Data Select Select Data Data Select Link Link Small Text Data Data Data Data Link Select Link Select Link Select Link Date Date Link Link Check Check Check
18 Info: Lead, Open, Replied, Opportunity, Interested, Converted, Do Not Contact One of: LEAD, LEAD/10-11/, LEAD/MUMBAI/ One of: Advertisement, Blog Post, Campaign, Call, Customer, Exhibition, Supplier, Website, Email Valid Customer Valid Campaign Valid Territory One of: Client, Channel Partner, Consultant Valid Profile One of: Lower Income, Middle Income, Upper Income Valid Industry Type One of: Product Enquiry, Request for Information, Suggestions, Other Valid Profile Valid Company Valid Company 0 or 1 0 or 1 0 or 1
19 Start entering data below this line
20 Mart Lakeman Lead Zany Brainy MartLakeman@einrot.com
21 Saga Lundqvist Lead Patterson-Fletcher SagaLundqvist@dayrep.com

View File

@@ -164,7 +164,7 @@ def run_stock(current_date):
if can_make("Delivery Note"):
from selling.doctype.sales_order.sales_order import make_delivery_note
from stock.stock_ledger import NegativeStockError
from stock.doctype.stock_ledger_entry.stock_ledger_entry import SerialNoRequiredError, SerialNoQtyError
from stock.doctype.serial_no.serial_no import SerialNoRequiredError, SerialNoQtyError
report = "Ordered Items To Be Delivered"
for so in list(set([r[0] for r in query_report.run(report)["result"] if r[0]!="Total"]))[:how_many("Delivery Note")]:
dn = webnotes.bean(make_delivery_note(so))

View File

@@ -105,13 +105,12 @@ def make_demo_login_page():
webnotes.conn.commit()
def make_demo_on_login_script():
webnotes.conn.sql("""delete from `tabCustom Script` where dt='Control Panel'""")
s = webnotes.new_bean("Custom Script")
s.doc.dt = "Control Panel"
s.doc.script_type = "Server"
with open(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), "r") as dfile:
s.doc.script = dfile.read()
s.insert()
import shutil
from core.doctype.custom_script.custom_script import get_custom_server_script_path
custom_script_path = get_custom_server_script_path("Control Panel")
webnotes.create_folder(os.path.dirname(custom_script_path))
shutil.copyfile(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), custom_script_path)
cp = webnotes.bean("Control Panel")
cp.doc.custom_startup_code = """wn.ui.toolbar.show_banner('You are using ERPNext Demo. To start your own ERPNext Trial, <a href="https://erpnext.com/pricing-and-signup" target="_blank">click here</a>')"""