mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 08:54:45 +00:00
moved directory structure
This commit is contained in:
1
utilities/doctype/contact/__init__.py
Normal file
1
utilities/doctype/contact/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
45
utilities/doctype/contact/contact.js
Normal file
45
utilities/doctype/contact/contact.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//--------- 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');
|
||||
|
||||
var route = wn.get_route();
|
||||
if(route[1]=='Supplier') {
|
||||
var supplier = wn.container.page.frm.doc;
|
||||
doc.supplier = supplier.name;
|
||||
doc.supplier_name = supplier.supplier_name;
|
||||
} else if(route[1]=='Customer') {
|
||||
var customer = wn.container.page.frm.doc;
|
||||
doc.customer = customer.name;
|
||||
doc.customer_name = customer.customer_name;
|
||||
if(customer.customer_type == 'Individual') {
|
||||
doc.first_name = customer.customer_name;
|
||||
}
|
||||
} else if(route[1]=='Sales Partner') {
|
||||
var sp = wn.container.page.frm.doc;
|
||||
doc.sales_partner = sp.name;
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.hide_dialog = function() {
|
||||
if(cur_frm.contact_list)
|
||||
cur_frm.contact_list.run();
|
||||
}
|
||||
|
||||
|
||||
67
utilities/doctype/contact/contact.py
Normal file
67
utilities/doctype/contact/contact.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Please edit this list and import only required elements
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
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
|
||||
else:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '')
|
||||
|
||||
#----------------------
|
||||
# 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):
|
||||
sql = webnotes.conn.sql
|
||||
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))
|
||||
else:
|
||||
if self.doc.customer:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
|
||||
self.doc.is_primary_contact = 1
|
||||
elif self.doc.supplier:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
|
||||
self.doc.is_primary_contact = 1
|
||||
elif self.doc.sales_partner:
|
||||
if not sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
|
||||
self.doc.is_primary_contact = 1
|
||||
257
utilities/doctype/contact/contact.txt
Normal file
257
utilities/doctype/contact/contact.txt
Normal file
@@ -0,0 +1,257 @@
|
||||
# DocType, Contact
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-03 14:22:38',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-08-02 13:16:48',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1327314958',
|
||||
'allow_trash': 1,
|
||||
'colour': u'White:FFF',
|
||||
'default_print_format': u'Standard',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Master',
|
||||
'in_create': 0,
|
||||
'in_dialog': 1,
|
||||
'module': u'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'server_code_error': u' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': u'%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Contact',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# DocType, Contact
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Contact'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'contact_details',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Contact Details',
|
||||
'oldfieldtype': u'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break0',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'first_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'First Name',
|
||||
'oldfieldname': u'first_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'last_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Last Name',
|
||||
'oldfieldname': u'last_name',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customer',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Customer',
|
||||
'oldfieldname': u'customer',
|
||||
'oldfieldtype': u'Link',
|
||||
'options': u'Customer',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'customer_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'supplier',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Supplier',
|
||||
'options': u'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': u'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 0,
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'supplier_name',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'depends_on': u'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sales_partner',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Sales Partner',
|
||||
'options': u'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'default': u'0',
|
||||
'depends_on': u'eval:(doc.customer || doc.supplier || doc.sales_partner)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'is_primary_contact',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Is Primary Contact',
|
||||
'oldfieldname': u'is_primary_contact',
|
||||
'oldfieldtype': u'Select',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'column_break1',
|
||||
'fieldtype': u'Column Break',
|
||||
'oldfieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'email_id',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Email Id',
|
||||
'oldfieldname': u'email_id',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'phone',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Phone',
|
||||
'oldfieldname': u'contact_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'mobile_no',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Mobile No',
|
||||
'oldfieldname': u'mobile_no',
|
||||
'oldfieldtype': u'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enter department to which this Contact belongs',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'department',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Department',
|
||||
'options': u'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Enter designation of this Contact',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'designation',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Designation',
|
||||
'options': u'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'unsubscribed',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Unsubscribed',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'trash_reason',
|
||||
'fieldtype': u'Small Text',
|
||||
'label': u'Trash Reason',
|
||||
'oldfieldname': u'trash_reason',
|
||||
'oldfieldtype': u'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
50
utilities/doctype/contact/contact_list.js
Normal file
50
utilities/doctype/contact/contact_list.js
Normal file
@@ -0,0 +1,50 @@
|
||||
wn.doclistviews['Contact'] = wn.views.ListView.extend({
|
||||
init: function(d) {
|
||||
this._super(d)
|
||||
this.fields = this.fields.concat([
|
||||
"`tabContact`.first_name",
|
||||
"`tabContact`.last_name",
|
||||
"`tabContact`.customer",
|
||||
"`tabContact`.customer_name",
|
||||
"`tabContact`.supplier",
|
||||
"`tabContact`.supplier_name",
|
||||
"`tabContact`.sales_partner",
|
||||
"`tabContact`.email_id",
|
||||
]);
|
||||
},
|
||||
|
||||
prepare_data: function(data) {
|
||||
this._super(data);
|
||||
|
||||
// prepare fullname
|
||||
data.fullname = (data.first_name || '') +
|
||||
(data.last_name ? ' ' + data.last_name : '');
|
||||
if(!data.fullname) data.fullname = data.name;
|
||||
data.fullname = repl("<a href='#!Form/Contact/%(name)s'>%(fullname)s\
|
||||
</a>", data);
|
||||
|
||||
// prepare description
|
||||
if(data.customer) {
|
||||
data.description = (data.customer_name || data.customer);
|
||||
data.contact_type = 'Customer';
|
||||
} else if (data.supplier) {
|
||||
data.description = (data.supplier_name || data.supplier);
|
||||
data.contact_type = 'Supplier';
|
||||
} else if (data.sales_partner) {
|
||||
data.description = data.sales_partner;
|
||||
data.contact_type = 'Sales Partner'
|
||||
} else {
|
||||
data.description = '';
|
||||
data.contact_type = '';
|
||||
}
|
||||
},
|
||||
|
||||
columns: [
|
||||
{width: '3%', content: 'check'},
|
||||
{width: '20%', content: 'fullname'},
|
||||
{width: '15%', content: 'contact_type'},
|
||||
{width: '20%', content: 'description+tags'},
|
||||
{width: '30%', content: 'email_id'},
|
||||
{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user