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/address/__init__.py
Normal file
0
utilities/doctype/address/__init__.py
Normal file
5
utilities/doctype/address/address.js
Normal file
5
utilities/doctype/address/address.js
Normal file
@@ -0,0 +1,5 @@
|
||||
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');
|
||||
}
|
||||
|
||||
56
utilities/doctype/address/address.py
Normal file
56
utilities/doctype/address/address.py
Normal file
@@ -0,0 +1,56 @@
|
||||
# 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.customer + '-' + self.doc.address_type
|
||||
elif self.doc.supplier:
|
||||
self.doc.name = self.doc.supplier + '-' + self.doc.address_type
|
||||
elif self.doc.sales_partner:
|
||||
self.doc.name = self.doc.sales_partner + '-' + self.doc.address_type
|
||||
|
||||
# filter out bad characters in name
|
||||
#self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
|
||||
|
||||
#----------------------
|
||||
# Call to Validate
|
||||
#----------------------
|
||||
def validate(self):
|
||||
self.validate_primary_address()
|
||||
self.validate_shipping_address()
|
||||
|
||||
#----------------------
|
||||
# Validate that there can only be one primary address for particular customer, supplier
|
||||
#----------------------
|
||||
def validate_primary_address(self):
|
||||
if self.doc.is_primary_address == 1:
|
||||
if self.doc.customer:
|
||||
sql("update tabAddress set is_primary_address=0 where customer = '%s'" % (self.doc.customer))
|
||||
elif self.doc.supplier:
|
||||
sql("update tabAddress set is_primary_address=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
elif self.doc.sales_partner:
|
||||
sql("update tabAddress set is_primary_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
|
||||
#----------------------
|
||||
# Validate that there can only be one shipping address for particular customer, supplier
|
||||
#----------------------
|
||||
def validate_shipping_address(self):
|
||||
if self.doc.is_shipping_address == 1:
|
||||
if self.doc.customer:
|
||||
sql("update tabAddress set is_shipping_address=0 where customer = '%s'" % (self.doc.customer))
|
||||
elif self.doc.supplier:
|
||||
sql("update tabAddress set is_shipping_address=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
elif self.doc.sales_partner:
|
||||
sql("update tabAddress set is_shipping_address=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
306
utilities/doctype/address/address.txt
Normal file
306
utilities/doctype/address/address.txt
Normal file
@@ -0,0 +1,306 @@
|
||||
# DocType, Address
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-05-24 10:14:48',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-09 12:28:53',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1307602735',
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_dialog': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 42
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Address',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Address',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Address
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Address'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Address Details',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': '<em>e.g. Office, Billing, Shipping</em>',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Address Type',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_line1',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Address Line1',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'address_line2',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Address Line2',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'city',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'in_filter': 1,
|
||||
'label': 'City/Town',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'pincode',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'in_filter': 1,
|
||||
'label': 'Pincode',
|
||||
'permlevel': 0,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'country',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 7,
|
||||
'in_filter': 1,
|
||||
'label': 'Country',
|
||||
'options': 'link:Country',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'state',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'in_filter': 1,
|
||||
'label': 'State',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 9,
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'phone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'Phone',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 11,
|
||||
'label': 'Email Id',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fax',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Fax',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 13,
|
||||
'label': 'Customer',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 15,
|
||||
'label': 'Supplier',
|
||||
'options': 'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 16,
|
||||
'label': 'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_partner',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 17,
|
||||
'label': 'Sales Partner',
|
||||
'options': 'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'description': 'Check to make primary address',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_primary_address',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 18,
|
||||
'label': 'Is Primary Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'description': 'Check to make Shipping Address',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_shipping_address',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 19,
|
||||
'label': 'Is Shipping Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 20,
|
||||
'label': 'Trash Reason',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user