mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
restructured erpnext and deleted unwanted
This commit is contained in:
0
utilities/doctype/contact/__init__.py
Normal file
0
utilities/doctype/contact/__init__.py
Normal file
54
utilities/doctype/contact/contact.js
Normal file
54
utilities/doctype/contact/contact.js
Normal file
@@ -0,0 +1,54 @@
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
|
||||
if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
|
||||
}
|
||||
/*
|
||||
//---------- on refresh ----------------------
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------- Trigger on customer ---------------------
|
||||
cur_frm.cscript.is_customer = function(doc,cdt,cdn){
|
||||
if(!doc.is_customer){
|
||||
doc.customer = doc.customer_name = doc.customer_address = doc.customer_group = '';
|
||||
refresh_many(['customer','customer_name','customer_address','customer_group']);
|
||||
}
|
||||
}
|
||||
|
||||
//------------- Trigger on supplier -----------------------
|
||||
cur_frm.cscript.is_supplier = function(doc,cdt,cdn){
|
||||
if(!doc.is_supplier){
|
||||
doc.supplier = doc.supplier_name = doc.supplier_address = doc.supplier_type = '';
|
||||
refresh_many(['supplier','supplier_address','supplier_name','supplier_type']);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------- Trigger on sales partner ---------------------
|
||||
cur_frm.cscript.is_sales_partner = function(doc,cdt,cdn){
|
||||
if(!doc.is_sales_partner){
|
||||
doc.sales_partner = doc.sales_partner_address = doc.partner_type = '';
|
||||
refresh_many(['sales_partner','sales_partner_address','partner_type']);
|
||||
}
|
||||
}
|
||||
|
||||
//----------- Trigger on supplier name ------------------------
|
||||
cur_frm.cscript.supplier = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Supplier','dn':doc.supplier,'nm':'supplier_name','fld':'supplier_address','type':'supplier_type'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//------------ Trigger on customer name ------------------------
|
||||
cur_frm.cscript.customer = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Customer','dn':doc.customer,'nm':'customer_name','fld':'customer_address','type':'customer_group'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//------------ Trigger on sales partner ------------------------
|
||||
cur_frm.cscript.sales_partner = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Sales Partner','dn':doc.sales_partner,'nm':'partner_name','fld':'sales_partner_address','type':'partner_type'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
*/
|
||||
43
utilities/doctype/contact/contact.py
Normal file
43
utilities/doctype/contact/contact.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
if self.doc.customer:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
|
||||
elif self.doc.supplier:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
|
||||
elif self.doc.sales_partner:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner
|
||||
|
||||
# filter out bad characters in name
|
||||
#self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','')
|
||||
|
||||
#----------------------
|
||||
# Call to Validate
|
||||
#----------------------
|
||||
def validate(self):
|
||||
self.validate_primary_contact()
|
||||
|
||||
#----------------------
|
||||
# Validate that there can only be one primary contact for particular customer, supplier
|
||||
#----------------------
|
||||
def validate_primary_contact(self):
|
||||
if self.doc.is_primary_contact == 1:
|
||||
if self.doc.customer:
|
||||
sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
|
||||
elif self.doc.supplier:
|
||||
sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
elif self.doc.sales_partner:
|
||||
sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
339
utilities/doctype/contact/contact.txt
Normal file
339
utilities/doctype/contact/contact.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
# DocType, Contact
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-26 11:00:36',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1306307671',
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 0,
|
||||
'in_dialog': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
||||
'version': 242
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Contact
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Contact'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales Master Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 2,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Contact Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 2,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'first_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'First Name',
|
||||
'oldfieldname': 'first_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'last_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Last Name',
|
||||
'oldfieldname': 'last_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 5,
|
||||
'label': 'Customer',
|
||||
'oldfieldname': 'customer',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Supplier',
|
||||
'options': 'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 0,
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'label': 'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_partner',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 9,
|
||||
'label': 'Sales Partner',
|
||||
'options': 'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'depends_on': 'eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_primary_contact',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 10,
|
||||
'label': 'Is Primary Contact',
|
||||
'oldfieldname': 'is_primary_contact',
|
||||
'oldfieldtype': 'Select',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 11,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'phone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 13,
|
||||
'label': 'Phone',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mobile_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Mobile No',
|
||||
'oldfieldname': 'mobile_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter department to which this Contact belongs',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 15,
|
||||
'label': 'Department',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter designation of this Contact',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 16,
|
||||
'label': 'Designation',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 17,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user