commonified naming_series

This commit is contained in:
Rushabh Mehta 2012-11-26 11:58:22 +05:30
parent 78ba38106b
commit de91a21946
18 changed files with 5054 additions and 6038 deletions

View File

@ -39,11 +39,6 @@ class DocType:
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
#check status of lead #check status of lead
#------------------------ #------------------------
def check_status(self): def check_status(self):

View File

@ -4,9 +4,10 @@
"docstatus": 0, "docstatus": 0,
"creation": "2012-11-02 17:16:46", "creation": "2012-11-02 17:16:46",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-11-24 15:09:56" "modified": "2012-11-26 11:12:27"
}, },
{ {
"autoname": "naming_series:",
"name": "__common__", "name": "__common__",
"default_print_format": "Standard", "default_print_format": "Standard",
"search_fields": "lead_name,lead_owner,status", "search_fields": "lead_name,lead_owner,status",
@ -121,7 +122,7 @@
"search_index": 0, "search_index": 0,
"reqd": 0, "reqd": 0,
"in_filter": 1, "in_filter": 1,
"options": "\nAdvertisement\nBlog\nCampaign\nCall\nCustomer\nExhibition\nSupplier\nWebsite" "options": "\nAdvertisement\nBlog\nCampaign\nCall\nCustomer\nExhibition\nSupplier\nWebsite\nEmail"
}, },
{ {
"description": "Source of th", "description": "Source of th",

View File

@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, load_json from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, load_json
from webnotes.model import db_exists from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doc import Document, addchild, getchildren
from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint from webnotes import session, form, msgprint, errprint
@ -42,15 +42,6 @@ class DocType(TransactionBase):
self.tname = 'Quotation Item' self.tname = 'Quotation Item'
self.fname = 'quotation_details' self.fname = 'quotation_details'
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# DOCTYPE TRIGGER FUNCTIONS
# ==============================================================================
# Pull Opportunity Details # Pull Opportunity Details
# -------------------- # --------------------
def pull_enq_details(self): def pull_enq_details(self):

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doc import Document, addchild, getchildren
from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint from webnotes import session, form, msgprint, errprint
@ -46,12 +46,6 @@ class DocType(TransactionBase):
self.partner_tname = 'Partner Target Detail' self.partner_tname = 'Partner Target Detail'
self.territory_tname = 'Territory Target Detail' self.territory_tname = 'Territory Target Detail'
# Autoname
# ===============
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# DOCTYPE TRIGGER FUNCTIONS # DOCTYPE TRIGGER FUNCTIONS
# ============================= # =============================
# Pull Quotation Items # Pull Quotation Items

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doc import Document, addchild, getchildren
from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint from webnotes import session, form, msgprint, errprint
@ -42,11 +42,6 @@ class DocType(TransactionBase):
self.tname = 'Delivery Note Item' self.tname = 'Delivery Note Item'
self.fname = 'delivery_note_details' self.fname = 'delivery_note_details'
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def validate_fiscal_year(self): def validate_fiscal_year(self):
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date') get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists, delete_doc from webnotes.model import db_exists, delete_doc
from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doc import Document, addchild, getchildren
from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint from webnotes import session, form, msgprint, errprint
@ -41,12 +41,6 @@ class DocType(TransactionBase):
self.item_dict = {} self.item_dict = {}
self.fname = 'mtn_details' self.fname = 'mtn_details'
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# get item details # get item details
# ---------------- # ----------------
def get_item_details(self, arg): def get_item_details(self, arg):

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,3 @@ class DocType():
def __init__(self, doc, doclist=[]): def __init__(self, doc, doclist=[]):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')

View File

@ -4,13 +4,14 @@
"docstatus": 0, "docstatus": 0,
"creation": "2012-11-14 12:25:16", "creation": "2012-11-14 12:25:16",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-11-24 15:22:32" "modified": "2012-11-26 11:17:28"
}, },
{ {
"autoname": "naming_series:",
"allow_attach": 1, "allow_attach": 1,
"name": "__common__",
"doctype": "DocType", "doctype": "DocType",
"module": "Support", "module": "Support",
"name": "__common__",
"in_dialog": 1, "in_dialog": 1,
"document_type": "Master", "document_type": "Master",
"description": "Keep a track of all communications" "description": "Keep a track of all communications"

View File

@ -21,7 +21,7 @@ import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, getchildren, make_autoname from webnotes.model.doc import Document, addchild, getchildren
from webnotes.model.wrapper import getlist, copy_doclist from webnotes.model.wrapper import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, msgprint, errprint from webnotes import session, form, msgprint, errprint
@ -41,9 +41,6 @@ class DocType(TransactionBase):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series + '.######')
def check_maintenance_visit(self): def check_maintenance_visit(self):
nm = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'", self.doc.name) nm = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'", self.doc.name)
nm = nm and nm[0][0] or '' nm = nm and nm[0][0] or ''

File diff suppressed because it is too large Load Diff

View File

@ -45,10 +45,6 @@ class DocType():
where ifnull(blog_subscriber,0) = 1 and ifnull(email_id, '') != '' """ where ifnull(blog_subscriber,0) = 1 and ifnull(email_id, '') != '' """
} }
def autoname(self):
from webnotes.model.doc import make_autoname
self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
def send_emails(self): def send_emails(self):
"""send emails to leads and customers""" """send emails to leads and customers"""
# TODO: create unsubscribed check in customer # TODO: create unsubscribed check in customer

View File

@ -1,233 +1,184 @@
# DocType, Newsletter
[ [
# These values are common in all dictionaries
{ {
u'creation': '2012-08-23 18:49:12', "owner": "Administrator",
u'docstatus': 0, "docstatus": 0,
u'modified': '2012-08-24 14:45:00', "creation": "2012-08-24 14:48:05",
u'modified_by': u'Administrator', "modified_by": "Administrator",
u'owner': u'Administrator' "modified": "2012-11-26 11:18:43"
}, },
# These values are common for all DocType
{ {
'description': u'Create and Send Newsletters', "autoname": "naming_series:",
u'doctype': u'DocType', "description": "Create and Send Newsletters",
'document_type': u'Other', "doctype": "DocType",
'module': u'Support', "module": "Support",
u'name': u'__common__', "document_type": "Other",
'version': 1 "name": "__common__"
}, },
# These values are common for all DocField
{ {
u'doctype': u'DocField', "name": "__common__",
u'name': u'__common__', "parent": "Newsletter",
'parent': u'Newsletter', "doctype": "DocField",
'parentfield': u'fields', "parenttype": "DocType",
'parenttype': u'DocType' "parentfield": "fields"
}, },
# These values are common for all DocPerm
{ {
u'doctype': u'DocPerm', "name": "__common__",
u'name': u'__common__', "parent": "Newsletter",
'parent': u'Newsletter', "read": 1,
'parentfield': u'permissions', "doctype": "DocPerm",
'parenttype': u'DocType', "parenttype": "DocType",
'read': 1 "parentfield": "permissions"
}, },
# DocType, Newsletter
{ {
u'doctype': u'DocType', "name": "Newsletter",
u'name': u'Newsletter' "doctype": "DocType"
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'basic_info', "label": "Basic Info",
'fieldtype': u'Section Break', "fieldname": "basic_info",
'label': u'Basic Info', "fieldtype": "Section Break",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "default": "NL-",
'default': u'NL-', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'naming_series', "label": "Naming Series",
'fieldtype': u'Select', "options": "NL-",
'label': u'Naming Series', "fieldname": "naming_series",
'options': u'NL-', "fieldtype": "Select",
'permlevel': 0, "reqd": 1,
'reqd': 1 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "description": "A Lead with this email id should exist",
'description': u'A Lead with this email id should exist', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'test_email_id', "label": "Test Email Id",
'fieldtype': u'Data', "fieldname": "test_email_id",
'label': u'Test Email Id', "fieldtype": "Data",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'test_send', "label": "Test",
'fieldtype': u'Button', "options": "test_send",
'label': u'Test', "fieldname": "test_send",
'options': u'test_send', "fieldtype": "Button",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'column_break1', "label": "Send To",
'fieldtype': u'Column Break', "fieldname": "column_break1",
'label': u'Send To', "fieldtype": "Column Break",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'contacts', "label": "All Contacts",
'fieldtype': u'Check', "fieldname": "contacts",
'label': u'All Contacts', "fieldtype": "Check",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'customer_contacts', "label": "All Customer Contacts",
'fieldtype': u'Check', "fieldname": "customer_contacts",
'label': u'All Customer Contacts', "fieldtype": "Check",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'leads', "label": "All Leads",
'fieldtype': u'Check', "fieldname": "leads",
'label': u'All Leads', "fieldtype": "Check",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'active_leads', "label": "All Active Leads",
'fieldtype': u'Check', "fieldname": "active_leads",
'label': u'All Active Leads', "fieldtype": "Check",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'blog_subscribers', "label": "All Blog Subscribers",
'fieldtype': u'Check', "fieldname": "blog_subscribers",
'label': u'All Blog Subscribers', "fieldtype": "Check",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'newsletter_content', "label": "Newsletter Content",
'fieldtype': u'Section Break', "fieldname": "newsletter_content",
'label': u'Newsletter Content', "fieldtype": "Section Break",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'subject', "label": "Subject",
'fieldtype': u'Small Text', "fieldname": "subject",
'label': u'Subject', "fieldtype": "Small Text",
'permlevel': 0, "reqd": 1,
'reqd': 1 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "colour": "White:FFF",
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'message', "label": "Message",
'fieldtype': u'Code', "options": "Markdown",
'label': u'Message', "fieldname": "message",
'options': u'Markdown', "fieldtype": "Code",
'permlevel': 0, "reqd": 0,
'reqd': 0 "permlevel": 0
}, },
# DocField
{ {
u'doctype': u'DocField', "doctype": "DocField",
'fieldname': u'newsletter_status', "label": "Newsletter Status",
'fieldtype': u'Section Break', "fieldname": "newsletter_status",
'label': u'Newsletter Status', "fieldtype": "Section Break",
'permlevel': 0 "permlevel": 0
}, },
# DocField
{ {
'colour': u'White:FFF', "no_copy": 1,
u'doctype': u'DocField', "colour": "White:FFF",
'fieldname': u'email_sent', "doctype": "DocField",
'fieldtype': u'Check', "label": "Email Sent?",
'label': u'Email Sent?', "fieldname": "email_sent",
'no_copy': 1, "fieldtype": "Check",
'permlevel': 1 "permlevel": 1
}, },
# DocPerm
{ {
'cancel': 1, "create": 1,
'create': 1, "doctype": "DocPerm",
u'doctype': u'DocPerm', "write": 1,
'permlevel': 0, "role": "Sales Manager",
'role': u'Sales Manager', "cancel": 1,
'write': 1 "permlevel": 0
}, },
# DocPerm
{ {
'cancel': 1, "create": 1,
'create': 1, "doctype": "DocPerm",
u'doctype': u'DocPerm', "write": 1,
'permlevel': 0, "role": "Support Manager",
'role': u'Support Manager', "cancel": 1,
'write': 1 "permlevel": 0
}, },
# DocPerm
{ {
u'doctype': u'DocPerm', "doctype": "DocPerm",
'permlevel': 1, "role": "Sales Manager",
'role': u'Sales Manager' "permlevel": 1
}, },
# DocPerm
{ {
u'doctype': u'DocPerm', "doctype": "DocPerm",
'permlevel': 1, "role": "Support Manager",
'role': u'Support Manager' "permlevel": 1
} }
] ]

View File

@ -26,9 +26,6 @@ class DocType(TransactionBase):
self.doc = doc self.doc = doc
self.doclist = doclist self.doclist = doclist
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
def onload(self): def onload(self):
self.add_communication_list() self.add_communication_list()
@ -106,7 +103,6 @@ class DocType(TransactionBase):
import email.utils import email.utils
d = webnotes.doc('Communication') d = webnotes.doc('Communication')
d.naming_series = "COMM-"
d.subject = self.doc.subject d.subject = self.doc.subject
d.email_address = from_email or webnotes.user.name d.email_address = from_email or webnotes.user.name
email_addr = email.utils.parseaddr(d.email_address)[1] email_addr = email.utils.parseaddr(d.email_address)[1]
@ -117,6 +113,16 @@ class DocType(TransactionBase):
d.communication_medium = "Email" d.communication_medium = "Email"
d.save(1) d.save(1)
if not d.lead and not d.contact:
self.make_lead(d, email_addr[0])
def make_lead(self, d, real_name):
d = webnotes.doc("Lead")
d.lead_name = real_name or d.email_address
d.email_id = d.email_address
d.source = "Email"
d.save(1)
def close_ticket(self): def close_ticket(self):
webnotes.conn.set(self.doc,'status','Closed') webnotes.conn.set(self.doc,'status','Closed')
update_feed(self.doc) update_feed(self.doc)

View File

@ -4,9 +4,10 @@
"docstatus": 0, "docstatus": 0,
"creation": "2012-11-02 17:17:05", "creation": "2012-11-02 17:17:05",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-11-24 16:41:45" "modified": "2012-11-26 11:17:10"
}, },
{ {
"autoname": "naming_series:",
"allow_attach": 1, "allow_attach": 1,
"default_print_format": "Standard", "default_print_format": "Standard",
"search_fields": "status,customer,allocated_to,subject,raised_by", "search_fields": "status,customer,allocated_to,subject,raised_by",