moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,44 @@
// 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/>.
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;
doc.address_type = 'Office';
} else if(route[1]=='Customer') {
var customer = wn.container.page.frm.doc;
doc.customer = customer.name;
doc.customer_name = customer.customer_name;
doc.address_type = 'Office';
} else if(route[1]=='Sales Partner') {
var sp = wn.container.page.frm.doc;
doc.sales_partner = sp.name;
doc.address_type = 'Office';
}
}
cur_frm.cscript.hide_dialog = function() {
if(cur_frm.address_list)
cur_frm.address_list.run();
}

View File

@@ -0,0 +1,79 @@
# 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.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
def validate(self):
self.validate_for_whom()
self.validate_primary_address()
self.validate_shipping_address()
def validate_for_whom(self):
if not (self.doc.customer or self.doc.supplier or self.doc.sales_partner):
msgprint("Please enter value in atleast one of customer, supplier and sales partner field", raise_exception=1)
def validate_primary_address(self):
"""Validate that there can only be one primary address for particular customer, supplier"""
sql = webnotes.conn.sql
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))
elif not self.doc.is_shipping_address:
if self.doc.customer:
if not sql("select name from tabAddress where is_primary_address=1 and customer = '%s'" % (self.doc.customer)):
self.doc.is_primary_address = 1
elif self.doc.supplier:
if not sql("select name from tabAddress where is_primary_address=1 and supplier = '%s'" % (self.doc.supplier)):
self.doc.is_primary_address = 1
elif self.doc.sales_partner:
if not sql("select name from tabAddress where is_primary_address=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
self.doc.is_primary_address = 1
def validate_shipping_address(self):
"""Validate that there can only be one shipping address for particular customer, supplier"""
sql = webnotes.conn.sql
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))

View File

@@ -0,0 +1,395 @@
# DocType, Address
[
# These values are common in all dictionaries
{
'creation': '2012-07-02 19:57:47',
'docstatus': 0,
'modified': '2012-07-02 20:24:15',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1319016431',
'allow_trash': 1,
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'document_type': u'Master',
'in_dialog': 1,
'module': u'Utilities',
'name': '__common__',
'search_fields': u'customer, supplier, sales_partner, country, state',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Address',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Address',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Address
{
'doctype': 'DocType',
'name': u'Address'
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'System Manager',
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales Master Manager',
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Master Manager',
'write': 1
},
# DocPerm
{
'cancel': 0,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Maintenance Manager',
'write': 1
},
# DocPerm
{
'cancel': 0,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts Manager',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales Manager',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase Manager',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales User',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Purchase User',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Maintenance User',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts User',
'write': 1
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'All',
'write': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'address_details',
'fieldtype': u'Section Break',
'label': u'Address Details',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'<em>e.g. Office, Billing, Shipping</em>',
'doctype': u'DocField',
'fieldname': u'address_type',
'fieldtype': u'Data',
'label': u'Address Type',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'address_line1',
'fieldtype': u'Data',
'label': u'Address Line1',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'address_line2',
'fieldtype': u'Data',
'label': u'Address Line2',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'city',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'City/Town',
'permlevel': 0,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'pincode',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'Pincode',
'permlevel': 0,
'search_index': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'country',
'fieldtype': u'Select',
'in_filter': 1,
'label': u'Country',
'options': u'link:Country',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'state',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'State',
'options': u'Suggest',
'permlevel': 0,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'permlevel': 0,
'print_hide': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'phone',
'fieldtype': u'Data',
'label': u'Phone',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'email_id',
'fieldtype': u'Data',
'label': u'Email Id',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fax',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'Fax',
'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',
'options': u'Customer',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:!doc.supplier && !doc.sales_partner',
'doctype': u'DocField',
'fieldname': u'customer_name',
'fieldtype': u'Data',
'in_filter': 1,
'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
},
# DocField
{
'colour': u'White:FFF',
'depends_on': u'eval:!doc.customer && !doc.sales_partner',
'doctype': u'DocField',
'fieldname': u'supplier_name',
'fieldtype': u'Data',
'in_filter': 1,
'label': u'Supplier Name',
'permlevel': 1,
'search_index': 0
},
# 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',
'description': u'Check to make primary address',
'doctype': u'DocField',
'fieldname': u'is_primary_address',
'fieldtype': u'Check',
'label': u'Is Primary Address',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'0',
'description': u'Check to make Shipping Address',
'doctype': u'DocField',
'fieldname': u'is_shipping_address',
'fieldtype': u'Check',
'label': u'Is Shipping Address',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'label': u'Trash Reason',
'permlevel': 0
}
]

View File

@@ -0,0 +1,55 @@
wn.doclistviews['Address'] = wn.views.ListView.extend({
init: function(d) {
this._super(d)
this.fields = this.fields.concat([
"`tabAddress`.customer_name",
"`tabAddress`.supplier",
"`tabAddress`.supplier_name",
"`tabAddress`.sales_partner",
"`tabAddress`.city",
"`tabAddress`.country",
"ifnull(`tabAddress`.is_shipping_address, 0) as is_shipping_address",
]);
},
prepare_data: function(data) {
this._super(data);
// prepare address
var address = []
$.each(['city', 'country'], function(i, v) {
if(data[v]) address.push(data[v]);
});
data.address = address.join(", ");
// prepare shipping tag
if(data.is_shipping_address) {
data.shipping = '<span class="label label-info">Shipping</span>';
}
// 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: 'name'},
{width: '15%', content: 'contact_type'},
{width: '20%', content: 'description'},
{width: '30%', content: 'address+shipping+tags', css: {'padding': '2px 0px'}},
{width: '12%', content: 'modified', css: {'text-align': 'right', 'color':'#777'}}
]
});