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 @@
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'}}
]
});

View File

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

View File

@@ -0,0 +1,102 @@
# DocType, Answer
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:01',
'docstatus': 0,
'modified': '2012-03-27 14:36:01',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_attach': 0,
'allow_trash': 1,
'autoname': u'_ANS.#######',
'colour': u'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'module': u'Utilities',
'name': '__common__',
'read_only': 1,
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Answer',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Answer',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'All',
'write': 1
},
# DocType, Answer
{
'doctype': 'DocType',
'name': u'Answer'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'question',
'fieldtype': u'Link',
'label': u'Question',
'options': u'Question'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'answer',
'fieldtype': u'Text',
'label': u'Answer',
'oldfieldname': u'question',
'oldfieldtype': u'Text'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'points',
'fieldtype': u'Int',
'label': u'Points'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'_users_voted',
'fieldtype': u'Text',
'hidden': 1,
'label': u'Users Voted',
'print_hide': 1
}
]

View File

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

View 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();
}

View 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

View 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
}
]

View 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'}}
]
});

View File

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

View File

@@ -0,0 +1,93 @@
# DocType, GL Mapper
[
# These values are common in all dictionaries
{
'creation': '2012-04-13 11:56:40',
'docstatus': 0,
'modified': '2012-04-23 12:27:38',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1305006361',
'autoname': u'field:doc_type',
'colour': u'White:FFF',
'doctype': 'DocType',
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'GL Mapper',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 0,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'GL Mapper',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1
},
# DocType, GL Mapper
{
'doctype': 'DocType',
'name': u'GL Mapper'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'doctype': u'DocPerm',
'role': u'Accounts User',
'submit': 0,
'write': 0
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'System Manager',
'write': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'doc_type',
'fieldtype': u'Data',
'label': u'Doc Type',
'oldfieldname': u'doc_type',
'oldfieldtype': u'Link',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fields',
'fieldtype': u'Table',
'label': u'Fields',
'oldfieldname': u'fields',
'oldfieldtype': u'Table',
'options': u'GL Mapper Detail'
}
]

View File

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

View File

@@ -0,0 +1,208 @@
# DocType, GL Mapper Detail
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:46',
'docstatus': 0,
'modified': '2012-03-27 14:36:46',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'GLMDetail.#####',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 4
},
# These values are common for all DocField
{
'doctype': u'DocField',
'fieldtype': u'Data',
'name': '__common__',
'oldfieldtype': u'Data',
'parent': u'GL Mapper Detail',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# DocType, GL Mapper Detail
{
'doctype': 'DocType',
'name': u'GL Mapper Detail'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'table_field',
'label': u'Table Field',
'oldfieldname': u'table_field'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'account',
'label': u'Account',
'oldfieldname': u'account',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'debit',
'label': u'Debit',
'oldfieldname': u'debit',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'credit',
'label': u'Credit',
'oldfieldname': u'credit',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'cost_center',
'label': u'Cost Center',
'oldfieldname': u'cost_center',
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'against',
'label': u'Against',
'oldfieldname': u'against',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'remarks',
'label': u'Remarks',
'no_copy': 1,
'oldfieldname': u'remarks',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'voucher_type',
'label': u'Voucher Type',
'oldfieldname': u'voucher_type',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'voucher_no',
'label': u'Voucher No',
'oldfieldname': u'voucher_no',
'reqd': 1
},
# DocField
{
'description': u'The date at which current entry will get or has actually executed.',
'doctype': u'DocField',
'fieldname': u'posting_date',
'label': u'Posting Date',
'oldfieldname': u'posting_date',
'reqd': 1
},
# DocField
{
'description': u'The date at which current entry is made in system.',
'doctype': u'DocField',
'fieldname': u'transaction_date',
'label': u'Transaction Date',
'oldfieldname': u'transaction_date',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'aging_date',
'label': u'Aging Date',
'oldfieldname': u'aging_date',
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fiscal_year',
'in_filter': 1,
'label': u'Fiscal Year',
'oldfieldname': u'fiscal_year',
'reqd': 1,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'against_voucher',
'label': u'Against Voucher',
'oldfieldname': u'against_voucher'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'against_voucher_type',
'label': u'Against Voucher Type',
'oldfieldname': u'against_voucher_type'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'in_filter': 1,
'label': u'Company',
'oldfieldname': u'company',
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'is_opening',
'label': u'Is Opening',
'oldfieldname': u'is_opening'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'is_advance',
'label': u'Is Advance',
'oldfieldname': u'is_advance'
}
]

View File

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

View File

@@ -0,0 +1,75 @@
# 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.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, 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.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
self.last_profile = None
def get_role_permission(self,role):
perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and t1.permlevel = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name "%role)
return perm or ''
#------------return role list -------------------------------------------------------------------------------------------------
# All roles of Role Master
def get_role(self):
r_list=sql("select name from `tabRole` where name not in ('Administrator','All','Guest')")
if r_list[0][0]:
r_list = [x[0] for x in r_list]
return r_list
# Only user specific role
def get_user_role(self,usr):
r_list=sql("select role from `tabUserRole` where parent=%s and role not in ('Administrator','All','Guest')",usr)
if r_list[0][0]:
r_list = [x[0] for x in r_list]
else:
r_list=[]
return r_list
# adding new role
def add_user_role(self,args):
arg=eval(args)
sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['user'])))
role_list = arg['role_list'].split(',')
for r in role_list:
pr=Document('UserRole')
pr.parent = arg['user']
pr.parenttype = 'Profile'
pr.role = r
pr.parentfield = 'userroles'
pr.save(1)

View File

@@ -0,0 +1,31 @@
# DocType, Profile Control
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 12
},
# DocType, Profile Control
{
'doctype': 'DocType',
'name': u'Profile Control'
}
]

View File

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

View File

@@ -0,0 +1,25 @@
# 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/>.
from __future__ import unicode_literals
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_trash(self):
import webnotes
webnotes.conn.sql("delete from tabAnswer where question=%s", self.doc.name)

View File

@@ -0,0 +1,158 @@
# DocType, Question
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:01',
'docstatus': 0,
'modified': '2012-03-27 14:36:01',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_attach': 0,
'allow_trash': 1,
'autoname': u'QUES.#######',
'colour': u'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'module': u'Utilities',
'name': '__common__',
'read_only': 1,
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 7
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Question',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Question',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'All',
'write': 1
},
# DocType, Question
{
'doctype': 'DocType',
'name': u'Question'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'question',
'fieldtype': u'Text',
'label': u'Question',
'oldfieldname': u'question',
'oldfieldtype': u'Text'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'points',
'fieldtype': u'Int',
'hidden': 1,
'label': u'Points'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'answer',
'fieldtype': u'Text Editor',
'label': u'Answer',
'oldfieldname': u'answer',
'oldfieldtype': u'Text Editor'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'_user_tags',
'fieldtype': u'Data',
'hidden': 1,
'label': u'User Tags'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tag_1',
'fieldtype': u'Link',
'label': u'Tag 1',
'oldfieldname': u'tag_1',
'oldfieldtype': u'Link',
'options': u'Question Tag',
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'_users_voted',
'fieldtype': u'Text',
'label': u'Users Voted'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tag_2',
'fieldtype': u'Link',
'label': u'Tag 2',
'oldfieldname': u'tag_2',
'oldfieldtype': u'Link',
'options': u'Question Tag',
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tag_3',
'fieldtype': u'Link',
'label': u'Tag 3',
'oldfieldname': u'tag_3',
'oldfieldtype': u'Link',
'options': u'Question Tag',
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
'label': u'File List',
'oldfieldname': u'file_list',
'oldfieldtype': u'Text'
}
]

View File

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

View File

@@ -0,0 +1,21 @@
// 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/>.
// over-ride the link query to return relevant link names
cur_frm.fields_dict.document_to_rename.get_query = function(doc, dt, dn) {
return "SELECT name FROM `tab"+doc.select_doctype+"` WHERE docstatus<2 AND name LIKE '%s' LIMIT 50";
}

View File

@@ -0,0 +1,37 @@
# 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/>.
from __future__ import unicode_literals
class DocType:
def __init__(self, d, dl=[]):
self.doc, self.doclist = d, dl
def rename(self):
"""
Generate update quereies for rename
"""
import webnotes.model
from webnotes.model.code import get_obj
# call on_rename method if exists
obj = get_obj(self.doc.select_doctype, self.doc.document_to_rename)
if hasattr(obj, 'on_rename'):
obj.on_rename(self.doc.new_name,self.doc.document_to_rename)
# rename the document
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
webnotes.msgprint("Successfully renamed "+self.doc.select_doctype+" : '"+self.doc.document_to_rename+"' to <b>"+self.doc.new_name+"</b>")

View File

@@ -0,0 +1,98 @@
# DocType, Rename Tool
[
# These values are common in all dictionaries
{
'creation': '2012-05-03 18:43:31',
'docstatus': 0,
'modified': '2012-05-25 11:58:44',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1308739509',
'allow_email': 1,
'allow_print': 1,
'colour': u'White:FFF',
'doctype': 'DocType',
'hide_heading': 0,
'hide_toolbar': 0,
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Rename Tool',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Rename Tool',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'System Manager',
'write': 1
},
# DocType, Rename Tool
{
'doctype': 'DocType',
'name': u'Rename Tool'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'select_doctype',
'fieldtype': u'Select',
'label': u'Select DocType',
'options': u'\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem\nProfile'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'document_to_rename',
'fieldtype': u'Link',
'label': u'Document to rename'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'new_name',
'fieldtype': u'Data',
'label': u'New Name'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rename',
'fieldtype': u'Button',
'label': u'Rename',
'options': u'rename'
}
]

View File

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

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/>.
var bin_list = [];
var msg = [];
var binidx = 0;
cur_frm.cscript.repost_bin = function(doc,cdt,cdn) {
args = {'check': 'Bin'};
$c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
bin_list = r.message;
repair_bin();
});
}
function repair_single_bin(){
$c_obj('Reposting Tool', 'repair_bin', cstr(bin_list[binidx]), function(r,rt) {
for(i = 0; i < r.message.length ; i++){
msg.push(r.message[i]);
}
repair_bin();
});
}
function repair_bin(){
if(binidx >= 10) {
args = {'msg': msg, 'subject': 'Item Quantity'};
$c_obj('Reposting Tool', 'send_mail', docstring(args));
alert('Completed');
return;
}
repair_single_bin();
binidx ++;
}
// Batch for Account Balances
//======================================================
var acc_list = [];
var accidx = 0;
cur_frm.cscript.repost_account_balances = function(doc,cdt,cdn) {
args = {'check': 'Account Balance'};
$c_obj('Reposting Tool','get_count_for_reposting', docstring(args), function(r,rt) {
acc_list = r.message;
repair_acc_bal();
});
}
function repair_single_acc_bal(){
$c_obj('Reposting Tool', 'repair_acc_bal', cstr(acc_list[accidx]), function(r,rt) {
for(i = 0; i < r.message.length; i++){
msg.push(r.message[i]);
}
repair_acc_bal();
});
}
function repair_acc_bal(){
if(accidx >= 15) {
args = {'msg' : msg, 'subject': 'Account Balance'};
$c_obj('Reposting Tool', 'send_mail', docstring(args));
alert('Completed');
return;
}
repair_single_acc_bal();
accidx ++;
}

View File

@@ -0,0 +1,211 @@
# 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.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, 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.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.msg = []
# =============================================================================
def get_count_for_reposting(self, args):
args = eval(args)
if args['check'] == 'Bin':
return [d[0] for d in sql("select name from `tabBin` where item_code = 'Repost Item' " )]
if args['check'] == 'Account Balance':
# message
if not self.doc.past_year:
msgprint('<div style="color: ORANGE"> Warning: Opening balances were not imported </div>')
# do not repost from same year
if self.doc.past_year == self.doc.name:
msgprint("Cannot import from the current year")
return [d[0] for d in sql("select name from `tabAccount` ")]
# =============================================================================
def get_bin_qty(self, wh, item):
# get actual_qty
act_qty = sql("select sum(actual_qty) from `tabStock Ledger Entry` where warehouse = '%s' and item_code = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (wh, item))
act_qty = act_qty and flt(act_qty[0][0]) or 0
# get indented_qty
ind_qty = sql("select sum(if( ifnull(t2.qty, 0) > ifnull(t2.ordered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.ordered_qty, 0), 0) ) from `tabPurchase Request` t1, `tabPurchase Request Item`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
ind_qty = ind_qty and flt(ind_qty[0][0]) or 0
# get ordered_qty
ord_qty = sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.received_qty, 0), (ifnull(t2.qty, 0) - ifnull(t2.received_qty, 0)) * ifnull(t2.conversion_factor, 0) , 0) ) from `tabPurchase Order` t1, `tabPurchase Order Item` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
ord_qty = ord_qty and flt(ord_qty[0][0]) or 0
# get reserved_qty
res_qty =sql("select sum(if ( ifnull(t2.qty, 0) > ifnull(t2.delivered_qty, 0), ifnull(t2.qty, 0) - ifnull(t2.delivered_qty, 0) , 0) ) from `tabSales Order` t1, `tabSales Order Item` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' and status != 'Stopped'" % (wh, item))
res_qty = res_qty and flt(res_qty[0][0]) or 0
# get planned_qty
plan_qty = sql("select sum(if ( ifnull(qty, 0) > ifnull(produced_qty,0), ifnull(qty, 0) - ifnull(produced_qty, 0), 0) ) from `tabProduction Order` where fg_warehouse = '%s' and production_item = '%s' and docstatus = 1" % (wh, item))
plan_qty = plan_qty and flt(plan_qty[0][0]) or 0
return {'actual_qty': act_qty, 'indented_qty': ind_qty, 'ordered_qty': ord_qty, 'reserved_qty': res_qty, 'planned_qty': plan_qty }
# =============================================================================
def check_bin_qty(self, bin_obj, qty_dict):
label_dict = {'actual_qty': 'Actual Qty', 'indented_qty': 'Quantity Requested for Purchase', 'ordered_qty': 'Ordered Qty', 'reserved_qty': 'Reserved Qty', 'planned_qty': 'Planned Qty'}
for f in qty_dict:
if flt(bin_obj.doc.fields[f]) != qty_dict[f]:
msgprint('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
self.msg.append('<div style="color: RED"> Difference found in %s for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (label_dict[f], bin_obj.doc.item_code, bin_obj.doc.warehouse, cstr(bin_obj.doc.fields[f]), cstr(qty_dict[f])))
# Check projected qty
projected_qty = flt(qty_dict['actual_qty']) + flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) + flt(qty_dict['planned_qty']) - flt(qty_dict['reserved_qty'])
if flt(projected_qty) != flt(bin_obj.doc.projected_qty):
msgprint('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
self.msg.append('<div style="color: RED">Difference found in Projected Qty for Item:= %s and Warehouse:= %s (Before : %s; After : %s)</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, bin_obj.doc.projected_qty, cstr(projected_qty)))
# =============================================================================
def repair_bin(self, bin):
import webnotes
bin_obj = get_obj('Bin',bin)
bin_act_qty = flt(bin_obj.doc.actual_qty)
try:
# udpate actual qty and item valuation
bin_obj.update_entries_after('0000-00-00', '00:00')
# get bin qty
qty_dict = self.get_bin_qty(bin_obj.doc.warehouse, bin_obj.doc.item_code)
# check bin qty
self.check_bin_qty(bin_obj, qty_dict)
projected_qty = flt(qty_dict['indented_qty']) + flt(qty_dict['ordered_qty']) - flt(qty_dict['reserved_qty']) + flt(qty_dict['planned_qty']) + flt(qty_dict['actual_qty'])
# update indented_qty, ordered_qty, reserved_qty, planned_qty
sql("update `tabBin` set indented_qty = '%s', ordered_qty = '%s', reserved_qty = '%s', planned_qty = '%s', projected_qty = '%s' where warehouse = '%s' and item_code = '%s'" % ( flt(qty_dict['indented_qty']), flt(qty_dict['ordered_qty']), flt(qty_dict['reserved_qty']), flt(qty_dict['planned_qty']), projected_qty, bin_obj.doc.warehouse, bin_obj.doc.item_code))
# update projected_qty
sql("update `tabBin` set projected_qty = ifnull(indented_qty, 0) + ifnull(ordered_qty,0) + ifnull(actual_qty, 0) + ifnull(planned_qty, 0) - ifnull(reserved_qty,0) where warehouse = '%s' and item_code = '%s' " % (bin_obj.doc.warehouse, bin_obj.doc.item_code))
if not self.msg:
msgprint('<div style="color: GREEN"> Reposting of Stock for Item %s and Warehouse %s completed Successfully. </div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse))
except Exception:
msgprint('<div style="color: RED"> Handle Item %s and Warehouse %s seprately. </div> <div style="color: RED"> ERROR: %s</div>' % (bin_obj.doc.item_code, bin_obj.doc.warehouse, str(webnotes.utils.getTraceback())))
self.msg.append('<div style="color: RED"> ERROR: %s</div>' % (str(webnotes.utils.getTraceback())))
# =============================================================================
def repair_all_bins(self):
bins = sql("select name from tabBin")
cnt = 0
for bin in bins:
if cnt % 20 == 0:
sql("commit")
sql("start transaction")
cnt += 1
self.repair_bin(bin[0])
# =============================================================================
def repair_bins_for_illegal_cancelled(self, after_date = '2011-01-01'):
bins = sql("select name from tabBin where modified >= %s", after_date)
cnt = 0
for bin in bins:
if cnt % 20 == 0:
sql("commit")
sql("start transaction")
cnt += 1
self.repair_bin(bin[0])
# =============================================================================
def repair_opening_bal(self, d, acc_obj, past_yr, fiscal_yr):
# check opening balance
opbal = sql("select balance from `tabAccount Balance` where account=%s and period = %s", (acc_obj.doc.name, past_yr))
if flt(d.opening) != flt(opbal and flt(opbal[0][0]) or 0):
msgprint('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
self.msg.append('<div style="color: RED"> Difference found in Opening of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.opening), opbal and flt(opbal[0][0]) or 0))
sql("update `tabAccount Balance` set opening = '%s' where period = '%s' and account = '%s' " % (opbal and flt(opbal[0][0]) or 0, fiscal_yr, acc_obj.doc.name))
# =============================================================================
def repair_bal(self, d, acc_obj, fiscal_yr):
# check balances
ysd = get_value('Fiscal Year', fiscal_yr, 'year_start_date')
bal = get_obj('GL Control').get_as_on_balance(acc_obj.doc.name, fiscal_yr, d.end_date, acc_obj.doc.debit_or_credit, acc_obj.doc.is_pl_account, acc_obj.doc.lft, acc_obj.doc.rgt, ysd)
if flt(d.balance) != flt(bal):
msgprint('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
self.msg.append('<div style="color: RED"> Difference found in Balance of Account %s for Period %s in Fiscal Year %s (Before : %s; After : %s) </div>' % (acc_obj.doc.name, d.period, fiscal_yr, flt(d.balance), flt(bal)))
sql("update `tabAccount Balance` set balance = '%s' where period = '%s' and account = '%s' " % (bal, d.period, acc_obj.doc.name))
# =============================================================================
def repair_acc_bal(self, acc, past_yr = '' , fiscal_yr = ''):
# get account obj
acc_obj = get_obj('Account', acc, with_children = 1)
# get fiscal yr & past yr
if not fiscal_yr:
import webnotes.utils
fiscal_yr = webnotes.utils.get_defaults()['fiscal_year']
if not past_yr: past_yr = get_value('Fiscal Year', fiscal_yr, 'past_year')
# Repair Opening and Balance For Account Balances
for d in getlist(acc_obj.doclist, 'account_balances'):
if d.fiscal_year == fiscal_yr:
if past_yr and (past_yr != fiscal_yr) and d.period == fiscal_yr:
self.repair_opening_bal(d, acc_obj, past_yr, fiscal_yr)
else:
self.repair_bal(d, acc_obj, fiscal_yr)
# Acknowledge USer
if not self.msg:
msgprint('<div style="color: GREEN"> Openings & Balances of Account %s for Fiscal Year %s updated successfully. </div>' % ( acc_obj.doc.name, fiscal_yr))
return self.msg
# =============================================================================
def send_mail(self, args):
args = eval(args)
self.msg, subject = args['msg'], args['subject']
msgprint(self.msg)
if self.msg:
email_msg = """ Dear Administrator,
In Account := %s User := %s has Reposted %s and following was found:-
%s
""" % (get_value('Control Panel', None,'account_id'), session['user'], subject, '\n'.join(self.msg))
sendmail(['support@iwebnotes.com'], subject='Repair of ' + cstr(subject), parts = [('text/plain', email_msg)])

View File

@@ -0,0 +1,94 @@
# DocType, Reposting Tool
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'colour': u'Light Blue:DEF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'hide_toolbar': 1,
'in_create': 0,
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'read_only': 1,
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 1,
'version': 173
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Reposting Tool',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Reposting Tool',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'System Manager',
'write': 1
},
# DocType, Reposting Tool
{
'doctype': 'DocType',
'name': u'Reposting Tool'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'recalculate_mar_&_actual_qty',
'fieldtype': u'Data',
'label': u'Recalculate MAR & Actual Qty'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'repost_bin',
'fieldtype': u'Button',
'label': u'Repost Bin',
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'repost_account_balances',
'fieldtype': u'Button',
'label': u'Repost Account Balances',
'trigger': u'Client'
}
]

View File

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

View File

@@ -0,0 +1,109 @@
// 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/>.
function SMSManager() {
var me = this;
this.get_contact_number = function(contact, key, value) {
$c_obj('SMS Control', 'get_contact_number', {
contact_name:contact,
value:value,
key:key
}, function(r,rt) {
if(r.exc) { msgprint(r.exc); return; }
me.number = r.message;
me.show_dialog();
}
);
}
this.show = function(contact, key, value, mobile_nos, message) {
this.message = message;
if (mobile_nos) {
me.number = mobile_nos;
me.show_dialog();
} else if (contact){
this.get_contact_number(contact, key, value)
} else {
me.show_dialog();
}
}
this.show_dialog = function() {
if(!me.dialog)
me.make_dialog();
me.dialog.set_values({
'message': me.message,
'number': me.number
})
me.dialog.show();
}
this.make_dialog = function() {
var d = new wn.widgets.Dialog({
title: 'Send SMS',
width: 400,
fields: [
{fieldname:'number', fieldtype:'Data', label:'Mobile Number', reqd:1},
{fieldname:'message', fieldtype:'Text', label:'Message', reqd:1},
{fieldname:'send', fieldtype:'Button', label:'Send'}
]
})
d.make();
d.fields_dict.send.input.onclick = function() {
var btn = d.fields_dict.send.input;
var v = me.dialog.get_values();
if(v) {
btn.set_working();
$c_obj('SMS Control', 'send_form_sms', v, function(r,rt) {
btn.done_working();
if(r.exc) {msgprint(r.exc); return; }
msgprint('Message Sent');
me.dialog.hide();
})
}
}
this.dialog = d;
}
}
cur_frm.cscript.send_sms = function(doc,dt,dn) {
var doc = cur_frm.doc;
var sms_man = new SMSManager();
var default_msg = {
'Lead' : '',
'Opportunity' : 'Your enquiry has been logged into the system. Ref No: ' + doc.name,
'Quotation' : 'Quotation ' + doc.name + ' has been sent via email. Thanks!',
'Sales Order' : 'Sales Order ' + doc.name + ' has been created against '
+ (doc.quotation_no ? ('Quote No:' + doc.quotation_no) : '')
+ (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
'Delivery Note' : 'Items has been delivered against delivery note: ' + doc.name
+ (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
'Sales Invoice': 'Invoice ' + doc.name + ' has been sent via email '
+ (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
'Purchase Request' : 'Purchase Request ' + doc.name + ' has been raised in the system',
'Purchase Order' : 'Purchase Order ' + doc.name + ' has been sent via email',
'Purchase Receipt' : 'Items has been received against purchase receipt: ' + doc.name
}
if (in_list(['Quotation', 'Sales Order', 'Delivery Note', 'Sales Invoice'], doc.doctype))
sms_man.show(doc.contact_person, 'customer', doc.customer, '', default_msg[doc.doctype]);
else if (in_list(['Purchase Order', 'Purchase Receipt'], doc.doctype))
sms_man.show(doc.contact_person, 'supplier', doc.supplier, '', default_msg[doc.doctype]);
else if (doc.doctype == 'Lead')
sms_man.show('', '', '', doc.mobile_no, default_msg[doc.doctype]);
else if (doc.doctype == 'Opportunity')
sms_man.show('', '', '', doc.contact_no, default_msg[doc.doctype]);
else if (doc.doctype == 'Purchase Request')
sms_man.show('', '', '', '', default_msg[doc.doctype]);
}

View File

@@ -0,0 +1,164 @@
# 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.utils import cint, flt, load_json, nowdate, cstr
from webnotes.model.code import get_obj
from webnotes.model.doc import Document
from webnotes import session, msgprint
from webnotes.model.doclist import getlist, copy_doclist
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# validate receiver numbers
# =========================================================
def validate_receiver_nos(self,receiver_list):
validated_receiver_list = []
for d in receiver_list:
# remove invalid character
invalid_char_list = [' ', '+', '-', '(', ')']
for x in invalid_char_list:
d = d.replace(x, '')
# mobile no validation for erpnext gateway
if get_value('SMS Settings', None, 'sms_gateway_url'):
mob_no = d
else:
if not d.startswith("0") and len(d) == 10:
mob_no = "91" + d
elif d.startswith("0") and len(d) == 11:
mob_no = "91" + d[1:]
elif len(d) == 12:
mob_no = d
else:
msgprint("Invalid mobile no : " + cstr(d))
raise Exception
if not mob_no.isdigit():
msgprint("Invalid mobile no : " + cstr(mob_no))
raise Exception
validated_receiver_list.append(mob_no)
if not validated_receiver_list:
msgprint("Please enter valid mobile nos")
raise Exception
return validated_receiver_list
def get_sender_name(self):
"returns name as SMS sender"
sender_name = webnotes.conn.get_value('Global Defaults', None, 'sms_sender_name') or 'ERPNXT'
if len(sender_name) > 6:
msgprint("""
As per TRAI rule, sender name must be exactly 6 characters.
Kindly change sender name in Setup --> Global Defaults.
Note: Hyphen, space, numeric digit, special characters are not allowed.
""", raise_exception=1)
return sender_name
def get_contact_number(self, arg):
"returns mobile number of the contact"
args = load_json(arg)
number = sql('select mobile_no, phone from tabContact where name=%s and %s=%s' % ('%s', args['key'], '%s'),\
(args['contact_name'], args['value']))
return number and (number[0][0] or number[0][1]) or ''
def send_form_sms(self, arg):
"called from client side"
args = load_json(arg)
self.send_sms([str(args['number'])], str(args['message']))
# Send SMS
# =========================================================
def send_sms(self, receiver_list, msg, sender_name = ''):
receiver_list = self.validate_receiver_nos(receiver_list)
arg = { 'account_name' : webnotes.conn.get_value('Control Panel',None,'account_id'),
'receiver_list' : receiver_list,
'message' : msg,
'sender_name' : sender_name or self.get_sender_name()
}
# personalized or erpnext gateway
if get_value('SMS Settings', None, 'sms_gateway_url'):
ret = self.send_via_personalized_gateway(arg)
msgprint(ret)
# Send sms via personalized gateway
# ==========================================================
def send_via_personalized_gateway(self, arg):
ss = get_obj('SMS Settings', 'SMS Settings', with_children=1)
args = {ss.doc.message_parameter : arg.get('message')}
for d in getlist(ss.doclist, 'static_parameter_details'):
args[d.parameter] = d.value
resp = []
for d in arg.get('receiver_list'):
args[ss.doc.receiver_parameter] = d
resp.append(self.send_request(ss.doc.sms_gateway_url, args))
return resp
# Send Request
# =========================================================
def send_request(self, gateway_url, args):
import httplib, urllib
server, api_url = self.scrub_gateway_url(gateway_url)
conn = httplib.HTTPConnection(server) # open connection
headers = {}
headers['Accept'] = "text/plain, text/html, */*"
conn.request('GET', api_url + urllib.urlencode(args), headers = headers) # send request
resp = conn.getresponse() # get response
resp = resp.read()
return resp
# Split gateway url to server and api url
# =========================================================
def scrub_gateway_url(self, url):
url = url.replace('http://', '').strip().split('/')
server = url.pop(0)
api_url = '/' + '/'.join(url)
if not api_url.endswith('?'):
api_url += '?'
return server, api_url
# Create SMS Log
# =========================================================
def create_sms_log(self, arg, sent_sms):
sl = Document('SMS Log')
sl.sender_name = arg['sender_name']
sl.sent_on = nowdate()
sl.receiver_list = cstr(arg['receiver_list'])
sl.message = arg['message']
sl.no_of_requested_sms = len(arg['receiver_list'])
sl.no_of_sent_sms = sent_sms
sl.save(new=1)

View File

@@ -0,0 +1,57 @@
# DocType, SMS Control
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'in_create': 0,
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 8
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'SMS Control',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1,
'role': u'System Manager'
},
# DocType, SMS Control
{
'doctype': 'DocType',
'name': u'SMS Control'
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1
}
]

View File

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

View File

@@ -0,0 +1,123 @@
# DocType, SMS Log
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'SMSLOG/.########',
'colour': u'White:FFF',
'doctype': 'DocType',
'module': u'Utilities',
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 3
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'SMS Log',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# These values are common for all DocPerm
{
'create': 0,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'SMS Log',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'role': u'System Manager',
'write': 0
},
# DocType, SMS Log
{
'doctype': 'DocType',
'name': u'SMS Log'
},
# DocPerm
{
'doctype': u'DocPerm'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sender_name',
'fieldtype': u'Data',
'label': u'Sender Name'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'sent_on',
'fieldtype': u'Date',
'label': u'Sent On'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'receiver_list',
'fieldtype': u'Small Text',
'label': u'Receiver List'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'no_of_requested_sms',
'fieldtype': u'Int',
'label': u'No of Requested SMS'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'no_of_sent_sms',
'fieldtype': u'Int',
'label': u'No of Sent SMS'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'message',
'fieldtype': u'Small Text',
'label': u'Message'
}
]

View File

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

View File

@@ -0,0 +1,69 @@
# DocType, SMS Receiver
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'istable': 1,
'module': u'Utilities',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'version': 2
},
# These values are common for all DocField
{
'doctype': u'DocField',
'fieldtype': u'Data',
'name': '__common__',
'oldfieldtype': u'Data',
'parent': u'SMS Receiver',
'parentfield': u'fields',
'parenttype': u'DocType',
'permlevel': 0
},
# DocType, SMS Receiver
{
'doctype': 'DocType',
'name': u'SMS Receiver'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'customer_name',
'label': u'Customer Name',
'oldfieldname': u'customer_name'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'receiver_name',
'label': u'Receiver Name',
'oldfieldname': u'receiver_name',
'width': u'350px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'mobile_no',
'label': u'Mobile No',
'oldfieldname': u'mobile_no',
'reqd': 1,
'width': u'200px'
}
]

View File

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

View File

@@ -0,0 +1,76 @@
# 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.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, 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.doc import Document, addchild, getchildren, make_autoname
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
# Get Masters
# -----------
def get_masters(self):
mlist = []
res = sql("select distinct t1.name from tabDocType t1, tabDocPerm t2 where ifnull(t1.allow_trash, 0) = 1 and (ifnull(t2.write, 0) = 1 or ifnull(t2.create, 0) = 1) and t2.role in (%s) and t2.parent = t1.name and t1.module not in ('DocType','Application Internal','Recycle Bin','Development','Testing','Testing System','Test') ORDER BY t1.name" % ("'"+"', '".join(webnotes.user.get_roles())+"'"))
for r in res:
mlist.append(r[0])
return mlist
# Get Trash Records
# -----------------
def get_trash_records(self, mast_name):
mlist = []
rec_dict = {}
if mast_name == 'All':
mlist = self.get_masters()
else:
mlist.append(mast_name)
for i in mlist:
rec = [r[0] for r in sql("select name from `tab%s` where docstatus = 2" % i)]
if rec:
rec_dict[i] = rec
return rec_dict
# Restore Records
# ---------------
def restore_records(self, arg):
arg = eval(arg)
for k in arg:
for r in arg[k]:
sql("update `tab%s` set docstatus = 0, modified = '%s', trash_reason = '' where name = '%s'" % (k, now(), r))
dt_obj = get_obj(k,r)
if hasattr(dt_obj, 'on_restore'): dt_obj.on_restore()

View File

@@ -0,0 +1,32 @@
# DocType, Trash Control
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'colour': u'White:FFF',
'doctype': 'DocType',
'in_create': 1,
'issingle': 1,
'module': u'Utilities',
'name': '__common__',
'read_only': 1,
'section_style': u'Simple',
'server_code_error': u' ',
'version': 35
},
# DocType, Trash Control
{
'doctype': 'DocType',
'name': u'Trash Control'
}
]