mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-25 07:54:46 +00:00
restructured erpnext and deleted unwanted
This commit is contained in:
0
utilities/doctype/__init__.py
Normal file
0
utilities/doctype/__init__.py
Normal file
@@ -0,0 +1,95 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
|
||||
# get dashboard counts
|
||||
# --------------------
|
||||
def get_dashboard_counts(self, dt):
|
||||
dtl = eval(dt)
|
||||
dt = {}
|
||||
|
||||
for d in dtl:
|
||||
# if Lead
|
||||
if d=='Lead':
|
||||
dt[d] = {'To follow up':sql("select count(name) from tabLead where status!='Converted' and docstatus=1")[0][0] or 0}
|
||||
|
||||
# if Enquiry
|
||||
elif d=='Enquiries':
|
||||
args = {}
|
||||
args['Quotations to be sent'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabEnquiry`t2 where t1.enq_no!=t2.name and t2.docstatus=1")[0][0] or 0
|
||||
args['To follow up'] = sql("select count(name) from `tabQuotation` where docstatus=0")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Sales Order
|
||||
elif d=='Sales Order':
|
||||
args = {}
|
||||
args['To be delivered'] = sql("select count(name) from `tabSales Order` where per_delivered<100 and delivery_date>now() and docstatus=1")[0][0] or 0
|
||||
args['To be billed'] = sql("select count(name) from `tabSales Order` where per_billed<100 and docstatus=1")[0][0] or 0
|
||||
args['Overdue'] = sql("select count(name) from `tabSales Order` where per_delivered<100 and delivery_date<now() and docstatus=1")[0][0] or 0
|
||||
args['To be submitted'] = sql("select count(name) from `tabSales Order` where status='Draft'")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Invoice
|
||||
elif d=='Invoices':
|
||||
args = {}
|
||||
args['To receive payment'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date>now() and outstanding_amount!=0")[0][0] or 0
|
||||
args['Overdue'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=1 and due_date<now() and outstanding_amount!=0")[0][0] or 0
|
||||
args['To be submitted'] = sql("select count(name) from `tabReceivable Voucher` where docstatus=0")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Indent
|
||||
elif d=='Indent':
|
||||
args = {}
|
||||
args['Purchase Order to be made'] = sql("select count(name) from `tabIndent` where per_ordered<100 and docstatus=1")[0][0] or 0
|
||||
args['To be submitted'] = sql("select count(name) from `tabIndent` where status='Draft'")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Purchase Order
|
||||
elif d=='Purchase Order':
|
||||
args = {}
|
||||
args['To receive items'] = sql("select count(name) from `tabPurchase Order` where per_received<100 and docstatus=1")[0][0] or 0
|
||||
args['To be billed'] = sql("select count(name) from `tabPurchase Order` where per_billed<100 and docstatus=1")[0][0] or 0
|
||||
args['To be submitted'] = sql("select count(name) from `tabPurchase Order` where status='Draft'")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Bills
|
||||
elif d=='Bills':
|
||||
args = {}
|
||||
args['To be payed'] = sql("select count(name) from `tabPayable Voucher` where docstatus=1 and outstanding_amount!=0")[0][0] or 0
|
||||
args['To be submitted'] = sql("select count(name) from `tabPayable Voucher` where docstatus=0")[0][0] or 0 #Draft
|
||||
dt[d] = args
|
||||
|
||||
# if Tasks
|
||||
elif d=='Tasks':
|
||||
dt[d] = {'Open': sql("select count(name) from `tabTicket` where status='Open'")[0][0] or 0}
|
||||
|
||||
# if Maintenance
|
||||
elif d=='Serial No':
|
||||
args = {}
|
||||
args['AMC to expire this month'] = sql("select count(name) from `tabSerial No` where docstatus=1 and month(getdate()) = month(amc_expiry_date) and year(getdate()) = year(amc_expiry_date)")[0][0] or 0
|
||||
args['Warranty to expire this month'] = ql("select count(name) from `tabSerial No` where docstatus=1 and month(getdate()) = month(warranty_expiry_date) and year(getdate())=year(warranty_expiry_date)")[0][0] or 0
|
||||
dt[d] = args
|
||||
|
||||
msgprint(dt)
|
||||
return dt
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Activity Dashboard Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 42
|
||||
},
|
||||
|
||||
# DocType, Activity Dashboard Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Activity Dashboard Control'
|
||||
}
|
||||
]
|
||||
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
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/contact/__init__.py
Normal file
0
utilities/doctype/contact/__init__.py
Normal file
54
utilities/doctype/contact/contact.js
Normal file
54
utilities/doctype/contact/contact.js
Normal file
@@ -0,0 +1,54 @@
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(doc.customer) cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
|
||||
if(doc.supplier) cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
|
||||
}
|
||||
/*
|
||||
//---------- on refresh ----------------------
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------- Trigger on customer ---------------------
|
||||
cur_frm.cscript.is_customer = function(doc,cdt,cdn){
|
||||
if(!doc.is_customer){
|
||||
doc.customer = doc.customer_name = doc.customer_address = doc.customer_group = '';
|
||||
refresh_many(['customer','customer_name','customer_address','customer_group']);
|
||||
}
|
||||
}
|
||||
|
||||
//------------- Trigger on supplier -----------------------
|
||||
cur_frm.cscript.is_supplier = function(doc,cdt,cdn){
|
||||
if(!doc.is_supplier){
|
||||
doc.supplier = doc.supplier_name = doc.supplier_address = doc.supplier_type = '';
|
||||
refresh_many(['supplier','supplier_address','supplier_name','supplier_type']);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------- Trigger on sales partner ---------------------
|
||||
cur_frm.cscript.is_sales_partner = function(doc,cdt,cdn){
|
||||
if(!doc.is_sales_partner){
|
||||
doc.sales_partner = doc.sales_partner_address = doc.partner_type = '';
|
||||
refresh_many(['sales_partner','sales_partner_address','partner_type']);
|
||||
}
|
||||
}
|
||||
|
||||
//----------- Trigger on supplier name ------------------------
|
||||
cur_frm.cscript.supplier = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Supplier','dn':doc.supplier,'nm':'supplier_name','fld':'supplier_address','type':'supplier_type'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//------------ Trigger on customer name ------------------------
|
||||
cur_frm.cscript.customer = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Customer','dn':doc.customer,'nm':'customer_name','fld':'customer_address','type':'customer_group'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
//------------ Trigger on sales partner ------------------------
|
||||
cur_frm.cscript.sales_partner = function(doc,cdt,cdn){
|
||||
arg = {'dt':'Sales Partner','dn':doc.sales_partner,'nm':'partner_name','fld':'sales_partner_address','type':'partner_type'};
|
||||
get_server_fields('get_address',docstring(arg),'',doc,cdt,cdn,1);
|
||||
}
|
||||
*/
|
||||
43
utilities/doctype/contact/contact.py
Normal file
43
utilities/doctype/contact/contact.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
if self.doc.customer:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.customer
|
||||
elif self.doc.supplier:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.supplier
|
||||
elif self.doc.sales_partner:
|
||||
self.doc.name = self.doc.first_name + (self.doc.last_name and ' ' + self.doc.last_name or '') + '-' + self.doc.sales_partner
|
||||
|
||||
# filter out bad characters in name
|
||||
#self.doc.name = self.doc.name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','')
|
||||
|
||||
#----------------------
|
||||
# Call to Validate
|
||||
#----------------------
|
||||
def validate(self):
|
||||
self.validate_primary_contact()
|
||||
|
||||
#----------------------
|
||||
# Validate that there can only be one primary contact for particular customer, supplier
|
||||
#----------------------
|
||||
def validate_primary_contact(self):
|
||||
if self.doc.is_primary_contact == 1:
|
||||
if self.doc.customer:
|
||||
sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
|
||||
elif self.doc.supplier:
|
||||
sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))
|
||||
elif self.doc.sales_partner:
|
||||
sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
|
||||
339
utilities/doctype/contact/contact.txt
Normal file
339
utilities/doctype/contact/contact.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
# DocType, Contact
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:55',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-26 11:00:36',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1306307671',
|
||||
'allow_trash': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'in_create': 0,
|
||||
'in_dialog': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
|
||||
'version': 242
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Contact
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Contact'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase User'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 3,
|
||||
'permlevel': 0,
|
||||
'role': 'Sales Master Manager',
|
||||
'submit': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 4,
|
||||
'permlevel': 1,
|
||||
'role': 'All',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 5,
|
||||
'permlevel': 2,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 6,
|
||||
'permlevel': 0,
|
||||
'role': 'Purchase Master Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 7,
|
||||
'permlevel': 0,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Contact Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 2,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'first_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'First Name',
|
||||
'oldfieldname': 'first_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'last_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Last Name',
|
||||
'oldfieldname': 'last_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 5,
|
||||
'label': 'Customer',
|
||||
'oldfieldname': 'customer',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'print_hide': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.supplier && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 6,
|
||||
'label': 'Customer Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Supplier',
|
||||
'options': 'Supplier',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'allow_on_submit': 0,
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.sales_partner',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'supplier_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 8,
|
||||
'label': 'Supplier Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'depends_on': 'eval:!doc.customer && !doc.supplier',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_partner',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 9,
|
||||
'label': 'Sales Partner',
|
||||
'options': 'Sales Partner',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': '0',
|
||||
'depends_on': 'eval:(cint(doc.is_customer) || cint(doc.is_supplier) || cint(doc.is_sales_partner))',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_primary_contact',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 10,
|
||||
'label': 'Is Primary Contact',
|
||||
'oldfieldname': 'is_primary_contact',
|
||||
'oldfieldtype': 'Select',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 11,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 12,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'phone',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 13,
|
||||
'label': 'Phone',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mobile_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 14,
|
||||
'label': 'Mobile No',
|
||||
'oldfieldname': 'mobile_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter department to which this Contact belongs',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 15,
|
||||
'label': 'Department',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Enter designation of this Contact',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 16,
|
||||
'label': 'Designation',
|
||||
'options': 'Suggest',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 17,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/contact_detail/__init__.py
Normal file
0
utilities/doctype/contact_detail/__init__.py
Normal file
98
utilities/doctype/contact_detail/contact_detail.txt
Normal file
98
utilities/doctype/contact_detail/contact_detail.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, Contact Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:56',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'CD/.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'show_in_menu': 0,
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Contact Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Contact Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Contact Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_person',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Contact Person',
|
||||
'oldfieldname': 'contact_person',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Contact No',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'department',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Department',
|
||||
'oldfieldname': 'department',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'designation',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Designation',
|
||||
'oldfieldname': 'designation',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 5,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Small Text'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/doctype_label/__init__.py
Normal file
0
utilities/doctype/doctype_label/__init__.py
Normal file
1
utilities/doctype/doctype_label/doctype_label.txt
Normal file
1
utilities/doctype/doctype_label/doctype_label.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-06-10 10:41:58', 'search_fields': None, 'module': 'Application Internal', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': None, 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'field:dt', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'DocType Label', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'Administrator', 'name': 'PERM01036', 'parent': 'DocType Label', 'read': 1, 'create': 1, 'creation': '2010-06-10 10:41:58', 'modified': '2010-06-10 10:44:09', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Select', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Select DocType', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05322', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt', 'fieldtype': 'Select', 'options': 'link:DocType', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-06-10 10:41:58', 'doctype': 'DocField', 'oldfieldname': 'dt_label', 'owner': 'Administrator', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'DocType Label', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'DocType Label', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL05323', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-06-10 10:44:09', 'parenttype': 'DocType', 'fieldname': 'dt_label', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]
|
||||
@@ -0,0 +1,15 @@
|
||||
class DocType:
|
||||
def __init__(self,d,dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def update_dt(self):
|
||||
sql("update tabDocType set module=%s, autoname=%s, read_only_onload=%s, section_style=%s, description=%s where name=%s limit 1", (self.doc.module, self.doc.autoname, self.doc.show_print_format_first, self.doc.page_style, self.doc.description, self.doc.select_doctype))
|
||||
|
||||
def get_details(self):
|
||||
ret = sql("select module, autoname, read_only_onload, section_style, description from tabDocType where name=%s", (self.doc.select_doctype))
|
||||
self.doc.module = ret[0][0] or ''
|
||||
self.doc.autoname = ret[0][1] or ''
|
||||
self.doc.show_print_format_first = ret[0][2] or 0
|
||||
self.doc.page_style = ret[0][3] or 'Simple'
|
||||
self.doc.description = ret[0][4] or ''
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
# DocType, DocType Property Setter
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:08:59',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 4
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'DocType Property Setter',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'DocType Property Setter',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, DocType Property Setter
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'DocType Property Setter'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'select_doctype',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Select DocType',
|
||||
'options': 'link:DocType'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 2,
|
||||
'label': 'Get Details',
|
||||
'options': 'get_details',
|
||||
'trigger': 'Server'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'module',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 3,
|
||||
'label': 'Module',
|
||||
'options': 'Module Def'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'autoname',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Autoname'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'page_style',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'label': 'Page Style',
|
||||
'options': 'Simple\nTabbed\nTray'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'show_print_format_first',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 6,
|
||||
'label': 'Show Print Format First'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Text Editor',
|
||||
'idx': 7,
|
||||
'label': 'Description',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 8,
|
||||
'label': 'Update',
|
||||
'options': 'update_dt',
|
||||
'trigger': 'Server'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/file_browser_control/__init__.py
Normal file
0
utilities/doctype/file_browser_control/__init__.py
Normal file
198
utilities/doctype/file_browser_control/file_browser_control.py
Normal file
198
utilities/doctype/file_browser_control/file_browser_control.py
Normal file
@@ -0,0 +1,198 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
# All root file groups(where parent_group is null).
|
||||
def get_root_file_grps(self):
|
||||
fl_grp = convert_to_lists(sql("select name,group_name,ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where (parent_group='' or parent_group is null)"))
|
||||
return fl_grp
|
||||
|
||||
# Get children of selected file group.
|
||||
def get_children(self,grp):
|
||||
ret = {}
|
||||
ret['parent_grp'] = grp
|
||||
|
||||
fl_grp = convert_to_lists(sql("select name,group_name,ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where parent_group=%s",grp))
|
||||
ret['fl_grp'] = fl_grp or ''
|
||||
fl = convert_to_lists(sql("select name,ifnull(file_name,''),ifnull(file_list,''),ifnull(can_edit,''),ifnull(can_view,''),owner from tabFile where file_group=%s and (file_name != '' and file_name is not null)",grp))
|
||||
ret['fl'] = fl or ''
|
||||
|
||||
return ret
|
||||
|
||||
# Create a new file group.
|
||||
def create_new_grp(self,arg):
|
||||
arg = eval(arg)
|
||||
|
||||
grp = Document('File Group')
|
||||
grp.group_name = arg['grp_nm']
|
||||
grp.parent_group = arg['parent_grp']
|
||||
grp.description = arg['desc']
|
||||
grp.name = arg['grp_nm']
|
||||
grp.save(1)
|
||||
msgprint('Created a New Group')
|
||||
return grp.name
|
||||
|
||||
# Create a new file.
|
||||
def create_new_file(self,arg):
|
||||
arg = eval(arg)
|
||||
|
||||
f = Document('File')
|
||||
f.file_name = arg['file_name']
|
||||
f.description = arg['desc']
|
||||
f.type = arg['type']
|
||||
f.file_group = arg['file_grp']
|
||||
f_obj = get_obj(doc=f)
|
||||
f_obj.validate()
|
||||
f_obj.doc.save(1)
|
||||
msgprint('Created a New File')
|
||||
ret = {
|
||||
'name' : f_obj.doc.name,
|
||||
'label' : f_obj.doc.file_name
|
||||
}
|
||||
return cstr(ret)
|
||||
|
||||
# Update changes done to selected file group.
|
||||
def update_grp(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("update `tabFile Group` set group_name=%s, parent_group=%s, description=%s where name=%s",(arg['grp_nm'],arg['parent_grp'],arg['desc'],arg['name']))
|
||||
msgprint("Changes are saved.")
|
||||
return arg['name']
|
||||
|
||||
# Update changes done to selected file.
|
||||
def update_file(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("update `tabFile` set description=%s, file_group=%s where name=%s",(arg['desc'],arg['file_grp'],arg['name']))
|
||||
msgprint("Changes are saved.")
|
||||
return arg['name']
|
||||
|
||||
# Get details of selected file.
|
||||
def get_file_details(self,file_id):
|
||||
file_det = convert_to_lists(sql("select name,file_name, description, file_group, file_list from tabFile where name=%s",file_id))
|
||||
file_det = {
|
||||
'name' : file_det[0][0] or '',
|
||||
'file_name' : file_det[0][1] or '',
|
||||
'description' : file_det[0][2] or '',
|
||||
'file_group' : file_det[0][3] or '',
|
||||
'file_list' : file_det[0][4] or ''
|
||||
}
|
||||
return file_det
|
||||
|
||||
# Delete File Data and File record.
|
||||
def delete(self,arg):
|
||||
arg = eval(arg)
|
||||
if arg['dt'] == 'File Group':
|
||||
sql("delete from `tabFile Group` where name= %s", arg['dn'])
|
||||
elif arg['dt'] == 'File':
|
||||
file_list = sql("select file_list from tabFile where name=%s", arg['dn'])[0][0] or ''
|
||||
f_id = file_list.split(',')[-1]
|
||||
if f_id:
|
||||
sql("delete from `tabFile Data` where name=%s", f_id)
|
||||
sql("delete from tabFile where name = %s", arg['dn'])
|
||||
else:
|
||||
pass
|
||||
|
||||
#Move to another group.
|
||||
def move(self,arg):
|
||||
msgprint('need to write code')
|
||||
|
||||
# Upload Image
|
||||
def upload_many(self,form):
|
||||
import os
|
||||
# from file browser
|
||||
if form.getvalue('form_name') == 'File Browser':
|
||||
if form.getvalue('filedata'):
|
||||
i = form['filedata']
|
||||
|
||||
#creat file data
|
||||
fd = Document('File Data')
|
||||
fd.blob_content = i.file.read()
|
||||
fd.file_name = i.filename
|
||||
|
||||
file_det = form.getvalue('file_det').split('~~')
|
||||
|
||||
if(file_det[0] == 'NIL'):
|
||||
file_desc = ''
|
||||
else:
|
||||
file_desc = file_det[0]
|
||||
|
||||
if(file_det[1] == 'NIL'):
|
||||
file_grp = ''
|
||||
return 'File Group is mandatory.'
|
||||
raise Exception
|
||||
else:
|
||||
file_grp = file_det[1]
|
||||
|
||||
if "" in fd.file_name:
|
||||
fd.file_name = fd.file_name.split("")[-1]
|
||||
if '/' in fd.file_name:
|
||||
fd.file_name = fd.file_name.split('/')[-1]
|
||||
fd.save(1)
|
||||
|
||||
f = Document('File')
|
||||
f.file_list = fd.file_name + ',' + fd.name
|
||||
f.file_name = fd.file_name
|
||||
f.description = file_desc
|
||||
f.file_group = file_grp
|
||||
f.save(1)
|
||||
|
||||
ret = {
|
||||
'name' : f.name,
|
||||
'file_name' : f.file_name
|
||||
}
|
||||
|
||||
return cstr(ret)
|
||||
else:
|
||||
return 'No file found.'
|
||||
else:
|
||||
return 'No file found.'
|
||||
|
||||
# Get all system roles.
|
||||
def get_all_roles(self):
|
||||
roles = convert_to_lists(sql("select name from tabRole"))
|
||||
return roles
|
||||
|
||||
# Get details for selected File Group.
|
||||
def get_fg_details(self,grp):
|
||||
grp_det = convert_to_lists(sql("select name,group_name, ifnull(parent_group,''), ifnull(description,''), ifnull(can_edit,''),ifnull(can_view,''),owner from `tabFile Group` where name=%s",grp))
|
||||
grp_det = {
|
||||
'Name' : grp_det[0][0] or '',
|
||||
'Group Name' : grp_det[0][1] or '',
|
||||
'Parent Group' : grp_det[0][2] or '',
|
||||
'Description' : grp_det[0][3] or '',
|
||||
'Can Edit' : grp_det[0][4] or '',
|
||||
'Can View' : grp_det[0][5] or '',
|
||||
'Owner' : grp_det[0][6] or ''
|
||||
}
|
||||
return grp_det
|
||||
|
||||
# Update Edit/ View privileges to selected File/ File Group.
|
||||
def update_privileges(self,arg):
|
||||
arg = eval(arg)
|
||||
sql("update `tab%s` set can_edit='%s', can_view='%s' where name='%s'" % (arg['type'],arg['edit_roles'], arg['view_roles'], arg['name']))
|
||||
msgprint('Privileges updated.')
|
||||
|
||||
# Get Edit/ View privileges from selected File/ File Group.
|
||||
def get_privileges(self,arg):
|
||||
arg = eval(arg)
|
||||
privilege = convert_to_lists(sql("select ifnull(can_edit,''), ifnull(can_view,''),owner from `tab%s` where name='%s'" % (arg['dt'],arg['dn'])))
|
||||
return privilege
|
||||
@@ -0,0 +1,31 @@
|
||||
# DocType, File Browser Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-10-28 10:25:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-27 11:09:53',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 81
|
||||
},
|
||||
|
||||
# DocType, File Browser Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'File Browser Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/gl_mapper/__init__.py
Normal file
0
utilities/doctype/gl_mapper/__init__.py
Normal file
98
utilities/doctype/gl_mapper/gl_mapper.txt
Normal file
98
utilities/doctype/gl_mapper/gl_mapper.txt
Normal file
@@ -0,0 +1,98 @@
|
||||
# DocType, GL Mapper
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-05-10 11:16:01',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1305006361',
|
||||
'autoname': 'field:doc_type',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Mapper',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'GL Mapper',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, GL Mapper
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Mapper'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'amend': 0,
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'Accounts User',
|
||||
'submit': 0,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'doc_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Doc Type',
|
||||
'oldfieldname': 'doc_type',
|
||||
'oldfieldtype': 'Link',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fields',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 2,
|
||||
'label': 'Fields',
|
||||
'oldfieldname': 'fields',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'GL Mapper Detail'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/gl_mapper_detail/__init__.py
Normal file
0
utilities/doctype/gl_mapper_detail/__init__.py
Normal file
225
utilities/doctype/gl_mapper_detail/gl_mapper_detail.txt
Normal file
225
utilities/doctype/gl_mapper_detail/gl_mapper_detail.txt
Normal file
@@ -0,0 +1,225 @@
|
||||
# DocType, GL Mapper Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:03',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'GLMDetail.#####',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Data',
|
||||
'name': '__common__',
|
||||
'oldfieldtype': 'Data',
|
||||
'parent': 'GL Mapper Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, GL Mapper Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'GL Mapper Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'table_field',
|
||||
'idx': 1,
|
||||
'label': 'Table Field',
|
||||
'oldfieldname': 'table_field'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account',
|
||||
'idx': 2,
|
||||
'label': 'Account',
|
||||
'oldfieldname': 'account',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'debit',
|
||||
'idx': 3,
|
||||
'label': 'Debit',
|
||||
'oldfieldname': 'debit',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit',
|
||||
'idx': 4,
|
||||
'label': 'Credit',
|
||||
'oldfieldname': 'credit',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'cost_center',
|
||||
'idx': 5,
|
||||
'label': 'Cost Center',
|
||||
'oldfieldname': 'cost_center',
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against',
|
||||
'idx': 6,
|
||||
'label': 'Against',
|
||||
'oldfieldname': 'against',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'remarks',
|
||||
'idx': 7,
|
||||
'label': 'Remarks',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'remarks',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_type',
|
||||
'idx': 8,
|
||||
'label': 'Voucher Type',
|
||||
'oldfieldname': 'voucher_type',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'voucher_no',
|
||||
'idx': 9,
|
||||
'label': 'Voucher No',
|
||||
'oldfieldname': 'voucher_no',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry will get or has actually executed.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'posting_date',
|
||||
'idx': 10,
|
||||
'label': 'Posting Date',
|
||||
'oldfieldname': 'posting_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'The date at which current entry is made in system.',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'transaction_date',
|
||||
'idx': 11,
|
||||
'label': 'Transaction Date',
|
||||
'oldfieldname': 'transaction_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'aging_date',
|
||||
'idx': 12,
|
||||
'label': 'Aging Date',
|
||||
'oldfieldname': 'aging_date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'fiscal_year',
|
||||
'idx': 13,
|
||||
'in_filter': 1,
|
||||
'label': 'Fiscal Year',
|
||||
'oldfieldname': 'fiscal_year',
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher',
|
||||
'idx': 14,
|
||||
'label': 'Against Voucher',
|
||||
'oldfieldname': 'against_voucher'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'against_voucher_type',
|
||||
'idx': 15,
|
||||
'label': 'Against Voucher Type',
|
||||
'oldfieldname': 'against_voucher_type'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'idx': 16,
|
||||
'in_filter': 1,
|
||||
'label': 'Company',
|
||||
'oldfieldname': 'company',
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_opening',
|
||||
'idx': 17,
|
||||
'label': 'Is Opening',
|
||||
'oldfieldname': 'is_opening'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_advance',
|
||||
'idx': 18,
|
||||
'label': 'Is Advance',
|
||||
'oldfieldname': 'is_advance'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/menu_control/__init__.py
Normal file
0
utilities/doctype/menu_control/__init__.py
Normal file
82
utilities/doctype/menu_control/menu_control.js
Normal file
82
utilities/doctype/menu_control/menu_control.js
Normal file
@@ -0,0 +1,82 @@
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
if globals().has_key('version') and version=='v170':
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_read
|
||||
else:
|
||||
roles = in_roles or session['data']['roles']
|
||||
all_read = session['data']['all_readtypes']
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl = arg.split('~~~')
|
||||
|
||||
out = {}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
if sf and sf[0]:
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
else:
|
||||
res = []
|
||||
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = NEWLINE.join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
fl = fl.split(NEWLINE)
|
||||
fl = [f.split(',')[0] for f in fl]
|
||||
res = []
|
||||
for f in fl:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt]] + res
|
||||
|
||||
return out
|
||||
|
||||
265
utilities/doctype/menu_control/menu_control.py
Normal file
265
utilities/doctype/menu_control/menu_control.py
Normal file
@@ -0,0 +1,265 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import cint, cstr
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.code import get_obj
|
||||
from webnotes import session, form, msgprint, errprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d,dl
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_children(self, arg='', only_type='', in_roles=[]):
|
||||
|
||||
type_cond = only_type and (" and menu_item_type='%s'" % only_type) or ''
|
||||
|
||||
import webnotes
|
||||
roles = webnotes.user.get_roles()
|
||||
all_read = webnotes.user.can_get_report
|
||||
|
||||
cl = sql("select name, menu_item_label, menu_item_type, link_id, link_content, has_children, icon, `order`, criteria_name, doctype_fields, onload from `tabMenu Item` where ifnull(disabled,'No')!='Yes' and ifnull(parent_menu_item,'')='%s' %s order by `order` asc" % (arg, type_cond), as_dict=1)
|
||||
ol = []
|
||||
for c in cl:
|
||||
c['has_children'] = cint(c['has_children'])
|
||||
c['order'] = cint(c['order'])
|
||||
for k in c.keys():
|
||||
if c[k]==None: c[k] = ''
|
||||
|
||||
# check permission
|
||||
if c['menu_item_type'] in ('DocType','Single','Report'):
|
||||
if c['link_id'] in all_read:
|
||||
ol.append(c)
|
||||
elif c['menu_item_type']=='Page':
|
||||
# page
|
||||
if c['link_id'].startswith('_'):
|
||||
ol.append(c)
|
||||
elif has_common([r[0] for r in sql("select role from `tabPage Role` where parent=%s", c['link_id'])], roles):
|
||||
ol.append(c)
|
||||
elif cstr(c['menu_item_type'])=='':
|
||||
# sections
|
||||
if has_common([r[0] for r in sql("select role from `tabMenu Item Role` where parent=%s", c['name'])], roles):
|
||||
ol.append(c)
|
||||
else:
|
||||
ol.append(c)
|
||||
|
||||
return ol
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def has_result(self, dt):
|
||||
return sql("select name from `tab%s` limit 1" % dt) and 'Yes' or 'No'
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def is_submittable(self, dt):
|
||||
return sql("select name from tabDocPerm where parent=%s and ifnull(submit,0)=1 and docstatus<1 limit 1", dt)
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def can_cancel(self, dt):
|
||||
return sql('select name from tabDocPerm where parent="%s" and ifnull(cancel,0)=1 and docstatus<1 and role in ("%s") limit 1' % (dt, '", "'.join(webnotes.user.get_roles())))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
def get_dt_trend(self, dt):
|
||||
ret = {}
|
||||
for r in sql("select datediff(now(),modified), count(*) from `tab%s` where datediff(now(),modified) between 0 and 30 group by date(modified)" % dt):
|
||||
ret[cint(r[0])] = cint(r[1])
|
||||
return ret
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_columns(self, out, sf, fl, dt):
|
||||
if not fl:
|
||||
fl = sf
|
||||
|
||||
res = []
|
||||
for f in fl:
|
||||
if f:
|
||||
res += [[c or '' for c in r] for r in sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname='%s'" % (dt, f))]
|
||||
|
||||
return res
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def check_user_tags(self, dt):
|
||||
try:
|
||||
sql("select `_user_tags` from `tab%s` limit 1" % dt)
|
||||
except Exception, e:
|
||||
if e.args[0] == 1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table `tab%s` add column `_user_tags` varchar(180)" % dt)
|
||||
webnotes.conn.begin()
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# NOTE: THIS SHOULD BE CACHED IN DOCTYPE CACHE
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_dt_details(self, arg):
|
||||
dt, fl, color_map = eval(arg)
|
||||
submittable = self.is_submittable(dt) and 1 or 0
|
||||
|
||||
out = {
|
||||
'submittable':(self.is_submittable(dt) and 1 or 0),
|
||||
'can_cancel':(self.can_cancel(dt) and 1 or 0)
|
||||
}
|
||||
|
||||
# filters
|
||||
# -------
|
||||
|
||||
sf = sql("select search_fields from tabDocType where name=%s", dt)[0][0] or ''
|
||||
|
||||
# get fields from in_filter (if not in search_fields)
|
||||
if not sf.strip():
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent=%s and `in_filter` = 1 and ifnull(fieldname,'') != ''", dt)
|
||||
sf = [s[0] for s in res]
|
||||
else:
|
||||
sf = [s.strip() for s in sf.split(',')]
|
||||
res = sql("select fieldname, label, fieldtype, options from tabDocField where parent='%s' and fieldname in (%s)" % (dt, '"'+'","'.join(sf)+'"'))
|
||||
|
||||
# select "link" options
|
||||
res = [[c or '' for c in r] for r in res]
|
||||
for r in res:
|
||||
if r[2]=='Select' and r[3] and r[3].startswith('link:'):
|
||||
tdt = r[3][5:]
|
||||
ol = sql("select name from `tab%s` where docstatus!=2 order by name asc" % tdt)
|
||||
r[3] = "\n".join([''] + [o[0] for o in ol])
|
||||
|
||||
if not res:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']]
|
||||
else:
|
||||
out['filters'] = [['name', 'ID', 'Data', '']] + res
|
||||
|
||||
# columns
|
||||
# -------
|
||||
res = self.get_columns(out, sf, fl, dt)
|
||||
|
||||
self.check_user_tags(dt)
|
||||
|
||||
out['columns'] = [['name', 'ID', 'Link', dt], ['modified', 'Modified', 'Data', ''], ['_user_tags', 'Tags', 'Data', '']] + res
|
||||
|
||||
if cint(color_map):
|
||||
out['color_map'] = self.get_color_map()
|
||||
|
||||
return out
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_color_map(self):
|
||||
d={}
|
||||
try:
|
||||
for tag in sql("select name, tag_color from tabTag"):
|
||||
d[tag[0]] = tag[1]
|
||||
except Exception, e:
|
||||
if e.args[0] in (1146, 1054):
|
||||
return {}
|
||||
else:
|
||||
raise e
|
||||
return d
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_trend(self, dt):
|
||||
return {'trend': self.get_dt_trend(dt)}
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def get_tags(self, dt, dn):
|
||||
tl = sql("select ifnull(_user_tags,'') from tab%s where name=%s" % (dt,'%s'), dn)[0][0]
|
||||
return tl and tl.split(',') or []
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def update_tags(self, dt, dn, tl):
|
||||
if len(','.join(tl)) > 179:
|
||||
msgprint("Too many tags")
|
||||
raise Exception
|
||||
|
||||
tl = filter(lambda x: x, tl)
|
||||
|
||||
# update in table
|
||||
sql("update tab%s set _user_tags=%s where name=%s" % (dt,'%s','%s'), (',' + ','.join(tl), dn))
|
||||
|
||||
# update in feed (if present)
|
||||
sql("update tabFeed set _user_tags=%s where doc_label=%s and doc_name=%s", (',' + ','.join(tl), dt, dn))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def _add_tag_to_master(self, tag, color):
|
||||
if color:
|
||||
t, cond = color, ("on duplicate key update tag_color='%s'" % color)
|
||||
else:
|
||||
t, cond = 'Default', ''
|
||||
|
||||
sql("insert ignore into tabTag(name, tag_color) values ('%s', '%s') %s" % (tag, t, cond))
|
||||
|
||||
def create_tag(self, tag, color):
|
||||
try:
|
||||
self._add_tag_to_master(tag, color)
|
||||
except Exception, e:
|
||||
# add the table
|
||||
if e.args[0]==1146:
|
||||
webnotes.conn.commit()
|
||||
sql("create table `tabTag`(`name` varchar(180), tag_color varchar(180), primary key (`name`))")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
# udpate the color column
|
||||
if e.args[0]==1054:
|
||||
webnotes.conn.commit()
|
||||
sql("alter table tabTag add column tag_color varchar(180)")
|
||||
webnotes.conn.begin()
|
||||
self._add_tag_to_master(tag, color)
|
||||
|
||||
else:
|
||||
raise e
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def add_tag(self,arg):
|
||||
dt, dn, tag, color = eval(arg)
|
||||
|
||||
# create tag in tag table
|
||||
self.create_tag(tag, color)
|
||||
|
||||
# add in _user_tags
|
||||
tl = self.get_tags(dt, dn)
|
||||
|
||||
if not tag in tl:
|
||||
tl.append(tag)
|
||||
self.update_tags(dt, dn, tl)
|
||||
|
||||
return tag
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def remove_tag(self,arg):
|
||||
dt, dn, tag = eval(arg)
|
||||
tl = self.get_tags(dt, dn)
|
||||
self.update_tags(dt, dn, filter(lambda x:x!=tag, tl))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def delete_items(self,arg):
|
||||
il = eval(arg)
|
||||
from webnotes.model import delete_doc
|
||||
for d in il:
|
||||
dt_obj = get_obj(d[0], d[1])
|
||||
if hasattr(dt_obj, 'on_trash'):
|
||||
dt_obj.on_trash()
|
||||
delete_doc(d[0], d[1])
|
||||
|
||||
# --------------------------------------------------------------
|
||||
|
||||
def archive_items(self,arg):
|
||||
arg = eval(arg)
|
||||
|
||||
from webnotes.utils.archive import archive_doc
|
||||
for d in arg['items']:
|
||||
archive_doc(d[0], d[1], arg['action']=='Restore' and 1 or 0)
|
||||
31
utilities/doctype/menu_control/menu_control.txt
Normal file
31
utilities/doctype/menu_control/menu_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Menu Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-06-09 13:43:49',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-03 12:01:42',
|
||||
'modified_by': 'sneha@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 38
|
||||
},
|
||||
|
||||
# DocType, Menu Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Menu Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/patch_util/__init__.py
Normal file
0
utilities/doctype/patch_util/__init__.py
Normal file
101
utilities/doctype/patch_util/patch_util.py
Normal file
101
utilities/doctype/patch_util/patch_util.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
def get_field_id(self, doctype, fieldname):
|
||||
f = sql("select name, idx from tabDocField where parent=%s and fieldname=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
f=sql("select name, idx from tabDocField where parent=%s and label=%s", (doctype, fieldname))
|
||||
if not f:
|
||||
return '__notfound__', 0
|
||||
#msgprint("No field found for %s" % fieldname)
|
||||
#raise Exception
|
||||
return f[0]
|
||||
|
||||
def set_field_property(self, doctype, fieldname, property, value):
|
||||
f = self.get_field_id(doctype, fieldname)
|
||||
sql("update tabDocField set `%s`=%s where name=%s" % (property,'%s','%s'), (value, f[0]))
|
||||
|
||||
def move_field(self, doctype, fieldname, before_field='', after_field=''):
|
||||
f1 = self.get_field_id(doctype, fieldname)
|
||||
|
||||
# get new id
|
||||
new_idx = self.get_field_id(doctype, before_field or after_field)[1]
|
||||
if after_field:
|
||||
new_idx = new_idx + 1
|
||||
|
||||
# push fields down at new idx
|
||||
sql("update tabDocField set idx=idx+1 where idx>=%s and parent=%s", (new_idx, doctype))
|
||||
|
||||
# push fields up at old idx
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
# set field idx
|
||||
sql("update tabDocField set idx=%s where name=%s", (new_idx, f1[0]))
|
||||
|
||||
def delete_field(self, doctype, fieldname):
|
||||
sql("delete from tabDocField where name=%s limit 1", self.get_field_id(doctype, fieldname)[0])
|
||||
|
||||
def delete_unnamed_field(self, doctype, after_field=''):
|
||||
f1 = self.get_field_id(doctype, after_field)
|
||||
|
||||
if f1[0]=='__notfound__':
|
||||
return
|
||||
|
||||
# check if truly un-named
|
||||
f2 = sql("select name, fieldname, label from tabDocField where idx=%s and parent=%s limit 1", (f1[1]+1, doctype))
|
||||
|
||||
if not f2:
|
||||
return
|
||||
f2 = f2[0]
|
||||
|
||||
if f2[1] or f2[2]:
|
||||
return
|
||||
else:
|
||||
sql("delete from tabDocField where name=%s limit 1", (f2[0]))
|
||||
|
||||
# move fields up
|
||||
sql("update tabDocField set idx=idx-1 where idx>%s and parent=%s", (f1[1], doctype))
|
||||
|
||||
def add_permission(self, doctype, role, level=0, read=0, write=0, create=0, submit=0, cancel=0, amend=0, match=''):
|
||||
# check if exists
|
||||
pid = sql("select name from tabDocPerm where parent=%s and role=%s and permlevel=%s", (doctype, role, level))
|
||||
if pid:
|
||||
d = Document('DocPerm', pid[0][0])
|
||||
else:
|
||||
d = Document('DocPerm')
|
||||
d.parent = doctype
|
||||
d.parenttype = 'DocType'
|
||||
d.parentfield = 'permissions'
|
||||
|
||||
d.role = role
|
||||
d.read = read
|
||||
d.write = write
|
||||
d.create = create
|
||||
d.submit = submit
|
||||
d.cancel = cancel
|
||||
d.amend = amend
|
||||
d.match = match
|
||||
|
||||
d.save(new = (not d.name and 1 or 0))
|
||||
|
||||
def delete_permission(self, doctype, role, level):
|
||||
sql("delete from `tabDocPerm` where role = '%s' and parent = '%s' and permlevel = '%s'" % (role, doctype, level))
|
||||
30
utilities/doctype/patch_util/patch_util.txt
Normal file
30
utilities/doctype/patch_util/patch_util.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
# DocType, Patch Util
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-10-27 14:33:29',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-21 10:19:44',
|
||||
'modified_by': 'sneha@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 5
|
||||
},
|
||||
|
||||
# DocType, Patch Util
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Patch Util'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,71 @@
|
||||
// Global dictionary of next steps for doctypes
|
||||
// ============================================
|
||||
pscript.tip_prod_dict = {'Production Order':['Material Transfer', 'Backflush']};
|
||||
|
||||
|
||||
// Set tips depending on conditions
|
||||
// ================================
|
||||
cur_frm.cscript.get_tips = function(doc, cdt, cdn){
|
||||
var next_step_list = pscript.tip_prod_dict[cur_frm.doctype] ? pscript.tip_prod_dict[cur_frm.doctype] : 0;
|
||||
|
||||
if(cur_frm.doctype!='Production Planning Tool'){
|
||||
// new doc
|
||||
if(doc.__islocal){
|
||||
if(doc.status=='Cancelled' || doc.amended_from)
|
||||
cur_frm.set_tip("You can now make changes in this " + cur_frm.doctype + " and save it by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
else{
|
||||
cur_frm.set_tip("To create " + cur_frm.doctype + " please start by entering all the mandatory fields (marked <div style='color:Red; display:inline'> Red</div>).");
|
||||
if(cur_frm.doctype=='Stock Entry') cur_frm.append_tip("If your purpose is Production Order, please go to <div style='font-weight:bold; display:inline'>Items</div> tab and click <div style='font-weight:bold; display:inline'>Get Items</div> to fetch the items.");
|
||||
cur_frm.append_tip("You can then save this form by clicking on the <div style='font-weight:bold; display:inline'>Save</div> button in the above toolbar.");
|
||||
}
|
||||
}
|
||||
|
||||
// doc exists
|
||||
else if(!doc.__islocal){
|
||||
// execute when doc is saved
|
||||
if(doc.docstatus==0 && cur_frm.doctype!='Production Planning Tool')
|
||||
cur_frm.set_tip("You have saved your " + cur_frm.doctype + ". You can make this draft permanent by clicking on <div style='font-weight:bold; display:inline'>Submit</div> button above.");
|
||||
|
||||
// execute if doc is submitted
|
||||
else if(doc.docstatus==1){
|
||||
cur_frm.set_tip("You have submitted this " + cur_frm.doctype + ".");
|
||||
for(var i=0; i<next_step_list.length; i++){
|
||||
if(i==0) cur_frm.append_tip("To proceed select the <div style='font-weight:bold; display:inline'>Next Steps</div> tab below. To transfer raw materials to Finished Goods Warehouse click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] +"</div>.");
|
||||
else cur_frm.append_tip("To update the quantity of finished goods and raw materials in their respective warehouses click on <div style='font-weight:bold; display:inline'>" + next_step_list[i] + "</div>.");
|
||||
}
|
||||
cur_frm.append_tip("(To amend this "+ cur_frm.doctype + " click on the <div style='font-weight:bold; display:inline'>Cancel</div> button above.)");
|
||||
}
|
||||
|
||||
// execute when doc is amended
|
||||
else if(doc.docstatus==2){
|
||||
cur_frm.set_tip("To make this " + cur_frm.doctype + " editable click on the <div style='font-weight:bold; display:inline'>Amend</div> button above.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Execute if current doctype is Production Planning Tool
|
||||
// ======================================================
|
||||
cur_frm.cscript.get_PPT_tips = function(doc, cdt, cdn)
|
||||
{
|
||||
cur_frm.set_tip('Welcome to Production Planning Wizard. This helps you to raise production order and see your raw material status as you plan your production.');
|
||||
cur_frm.append_tip("To start fetch all open Production Orders and Sales Orders by clicking on the <div style='font-weight:bold; display:inline'>Get Open Documents</div> button in the <div style='font-weight:bold; display:inline'>Against Document</div> tab below");
|
||||
|
||||
cur_frm.cscript['Get Open Documents'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("To include the required orders in the Production Plan check mark the <div style='font-weight:bold; display:inline'>Include In Plan</div> cell below.");
|
||||
cur_frm.append_tip("Next you can go to the <div style='font-weight:bold; display:inline'>Items</div> tab and click on <div style='font-weight:bold; display:inline'>Get Items</div> button to fetch the items of the selected orders.");
|
||||
}
|
||||
|
||||
cur_frm.cscript['Get Items'] = function(doc, cdt, cdn){
|
||||
cur_frm.set_tip("Now to raise a Production Order just click on <div style='font-weight:bold; display:inline'>Raise Production Ordre</div> button below the table.");
|
||||
cur_frm.append_tip("In order to see the Raw Material Report click on <div style='font-weight:bold; display:inline'>Get Raw Material Report</div> button below the table.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Executes when doc is edit status of doc is changed
|
||||
// ==================================================
|
||||
cur_frm.cscript.edit_status_changed = function(doc, cdt, cdn){
|
||||
cur_frm.cscript.get_tips();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
# DocType, Production Tips Common
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:14',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 37
|
||||
},
|
||||
|
||||
# DocType, Production Tips Common
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Production Tips Common'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/profile_control/__init__.py
Normal file
0
utilities/doctype/profile_control/__init__.py
Normal file
187
utilities/doctype/profile_control/profile_control.py
Normal file
187
utilities/doctype/profile_control/profile_control.py
Normal file
@@ -0,0 +1,187 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
# Sync Profile with Gateway
|
||||
# -------------------------
|
||||
def sync_with_gateway(self,pid):
|
||||
p = Document('Profile',pid)
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call add profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
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 ''
|
||||
|
||||
|
||||
# Check if password is expired
|
||||
# --------------------------------
|
||||
def has_pwd_expired(self):
|
||||
if session['user'] != 'Administrator' and session['user'].lower() != 'demo':
|
||||
last_pwd_date = None
|
||||
try:
|
||||
last_pwd_date = sql("select password_last_updated from tabProfile where name=%s",session['user'])[0][0] or ''
|
||||
except:
|
||||
return 'No'
|
||||
if cstr(last_pwd_date) == '':
|
||||
sql("update tabProfile set password_last_updated = '%s' where name='%s'"% (nowdate(),session['user']))
|
||||
return 'No'
|
||||
else:
|
||||
date_diff = (getdate(nowdate()) - last_pwd_date).days
|
||||
expiry_period = sql("select value from tabSingles where doctype='Control Panel' and field='password_expiry_days'")
|
||||
if expiry_period and cint(expiry_period[0][0]) and cint(expiry_period[0][0]) < date_diff:
|
||||
return 'Yes'
|
||||
return 'No'
|
||||
|
||||
def reset_password(self,pwd):
|
||||
if sql("select name from tabProfile where password=PASSWORD(%s) and name=%s", (pwd,session['user'])):
|
||||
return 'Password cannot be same as old password'
|
||||
sql("update tabProfile set password=PASSWORD(%s),password_last_updated=%s where name = %s", (pwd,nowdate(),session['user']))
|
||||
return 'ok'
|
||||
|
||||
#-------------------------------------------------------------------------------------------------------
|
||||
#functions for manage user page
|
||||
#-----------Enable/Disable Profile-----------------------------------------------------------------------------------------------
|
||||
def change_login(self,args):
|
||||
args = eval(args)
|
||||
|
||||
if cint(args['set_disabled'])==0:
|
||||
sql("update `tabProfile` set enabled=1 where name='%s'"%args['user'])
|
||||
else:
|
||||
sql("update `tabProfile` set enabled=0 where name='%s'"%args['user'])
|
||||
|
||||
return 'ok'
|
||||
|
||||
#------------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)
|
||||
|
||||
|
||||
|
||||
# Add new member
|
||||
# ---------------
|
||||
def add_profile(self,arg):
|
||||
|
||||
# Check credit balance
|
||||
get_obj('WN ERP Client Control').check_credit_balance()
|
||||
|
||||
arg=eval(arg)
|
||||
pr=Document('Profile')
|
||||
for d in arg.keys():
|
||||
if d!='role':
|
||||
pr.fields[d] = arg[d]
|
||||
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
pr_obj = get_obj('Profile',pr.name)
|
||||
if (pr.name):
|
||||
msg="New member is added"
|
||||
pr_obj.on_update()
|
||||
else:
|
||||
msg="Profile not created"
|
||||
|
||||
return cstr(msg)
|
||||
|
||||
# to find currently login user
|
||||
def current_login(self):
|
||||
cl_list=sql("select distinct user from tabSessions")
|
||||
if cl_list:
|
||||
cl_list=[x[0] for x in cl_list]
|
||||
|
||||
return cl_list
|
||||
|
||||
|
||||
# Remove Profile
|
||||
# ---------------
|
||||
def remove_profile(self, user):
|
||||
# delete profile
|
||||
webnotes.model.delete_doc('Profile',user)
|
||||
|
||||
# Update WN ERP Client Control
|
||||
sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")
|
||||
|
||||
# login to gateway
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
|
||||
account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
|
||||
|
||||
# call remove profile
|
||||
ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
|
||||
return "User Removed Successfully"
|
||||
|
||||
|
||||
# Create Profile
|
||||
# ---------------
|
||||
def create_profile(self, email):
|
||||
if sql("select name from tabProfile where name = %s", email):
|
||||
sql("update tabProfile set docstatus = 0 where name = %s", email)
|
||||
else:
|
||||
pr = Document('Profile')
|
||||
pr.email = email
|
||||
pr.enabled=0
|
||||
pr.user_type='System User'
|
||||
pr.save(1)
|
||||
31
utilities/doctype/profile_control/profile_control.txt
Normal file
31
utilities/doctype/profile_control/profile_control.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# DocType, Profile Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-29 12:19:21',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-11-03 11:03:11',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 12
|
||||
},
|
||||
|
||||
# DocType, Profile Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Profile Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/receiver_detail/__init__.py
Normal file
0
utilities/doctype/receiver_detail/__init__.py
Normal file
72
utilities/doctype/receiver_detail/receiver_detail.txt
Normal file
72
utilities/doctype/receiver_detail/receiver_detail.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
# DocType, Receiver Detail
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Tray',
|
||||
'server_code_error': ' ',
|
||||
'version': 2
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Data',
|
||||
'name': '__common__',
|
||||
'oldfieldtype': 'Data',
|
||||
'parent': 'Receiver Detail',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Receiver Detail
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Receiver Detail'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'idx': 1,
|
||||
'label': 'Customer Name',
|
||||
'oldfieldname': 'customer_name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'receiver_name',
|
||||
'idx': 2,
|
||||
'label': 'Receiver Name',
|
||||
'oldfieldname': 'receiver_name',
|
||||
'width': '350px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'mobile_no',
|
||||
'idx': 3,
|
||||
'label': 'Mobile No',
|
||||
'oldfieldname': 'mobile_no',
|
||||
'reqd': 1,
|
||||
'width': '200px'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/rename_tool/__init__.py
Executable file
0
utilities/doctype/rename_tool/__init__.py
Executable file
5
utilities/doctype/rename_tool/rename_tool.js
Normal file
5
utilities/doctype/rename_tool/rename_tool.js
Normal file
@@ -0,0 +1,5 @@
|
||||
// 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";
|
||||
}
|
||||
20
utilities/doctype/rename_tool/rename_tool.py
Normal file
20
utilities/doctype/rename_tool/rename_tool.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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)
|
||||
|
||||
# rename the document
|
||||
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
|
||||
|
||||
webnotes.msgprint("Item renamed successfully")
|
||||
102
utilities/doctype/rename_tool/rename_tool.txt
Executable file
102
utilities/doctype/rename_tool/rename_tool.txt
Executable file
@@ -0,0 +1,102 @@
|
||||
# DocType, Rename Tool
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-06-23 11:03:25',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-06-23 11:03:25',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308739509',
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'hide_heading': 0,
|
||||
'hide_toolbar': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 6
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Rename Tool',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Rename Tool',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Rename Tool
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Rename Tool'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'select_doctype',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 1,
|
||||
'label': 'Select DocType',
|
||||
'options': 'link:DocType'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'document_to_rename',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 2,
|
||||
'label': 'Document to rename'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'new_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'New Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 4,
|
||||
'label': 'Rename',
|
||||
'options': 'rename'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/reposting_tool/__init__.py
Normal file
0
utilities/doctype/reposting_tool/__init__.py
Normal file
63
utilities/doctype/reposting_tool/reposting_tool.js
Normal file
63
utilities/doctype/reposting_tool/reposting_tool.js
Normal file
@@ -0,0 +1,63 @@
|
||||
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 ++;
|
||||
}
|
||||
183
utilities/doctype/reposting_tool/reposting_tool.py
Normal file
183
utilities/doctype/reposting_tool/reposting_tool.py
Normal file
@@ -0,0 +1,183 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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 ifnull(actual_qty, 0) from `tabBin` where warehouse = '%s' and item_code = '%s'" % (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 `tabIndent` t1, `tabIndent Detail`t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (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, `tabPO Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.warehouse = '%s' and t2.item_code = '%s'" % (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 Detail` t2 where t1.name = t2.parent and t1.docstatus = 1 and t2.reserved_warehouse = '%s' and t2.item_code = '%s' " % (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': 'Indent Qty', '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_item_valuation('', '2000-01-01', '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_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)])
|
||||
96
utilities/doctype/reposting_tool/reposting_tool.txt
Normal file
96
utilities/doctype/reposting_tool/reposting_tool.txt
Normal file
@@ -0,0 +1,96 @@
|
||||
# DocType, Reposting Tool
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:19',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-04-19 11:50:09',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1308741898',
|
||||
'allow_copy': 1,
|
||||
'allow_email': 1,
|
||||
'allow_print': 1,
|
||||
'colour': 'Light Blue:DEF',
|
||||
'doctype': 'DocType',
|
||||
'hide_toolbar': 1,
|
||||
'in_create': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 1,
|
||||
'version': 174
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Reposting Tool',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'Reposting Tool',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Reposting Tool
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Reposting Tool'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'recalculate_mar_&_actual_qty',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 1,
|
||||
'label': 'Recalculate MAR & Actual Qty'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 2,
|
||||
'label': 'Repost Bin',
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Button',
|
||||
'idx': 3,
|
||||
'label': 'Repost Account Balances',
|
||||
'trigger': 'Client'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sms_center/__init__.py
Normal file
0
utilities/doctype/sms_center/__init__.py
Normal file
8
utilities/doctype/sms_center/sms_center.js
Normal file
8
utilities/doctype/sms_center/sms_center.js
Normal file
@@ -0,0 +1,8 @@
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.send_to == 'Customer Group')
|
||||
unhide_field('customer_group_name');
|
||||
else
|
||||
hide_field('customer_group_name');
|
||||
}
|
||||
|
||||
cur_frm.cscript.send_to = cur_frm.cscript.refresh;
|
||||
59
utilities/doctype/sms_center/sms_center.py
Normal file
59
utilities/doctype/sms_center/sms_center.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
def create_receiver_table(self):
|
||||
if self.doc.send_to:
|
||||
self.doc.clear_table(self.doclist, 'receiver_details')
|
||||
rec = ''
|
||||
if self.doc.send_to == 'All Customer':
|
||||
rec = sql("select customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(customer_name,'') !='' and ifnull(mobile_no,'')!=''")
|
||||
|
||||
elif self.doc.send_to == 'Customer Group' and self.doc.customer_group_name:
|
||||
|
||||
rec = sql("select t2.customer_name, CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), t1.mobile_no from `tabContact` t1, `tabCustomer` t2 where t2.name = t1.customer_name and ifnull(t1.mobile_no,'')!='' and t2.customer_group = '%s'"%self.doc.customer_group_name)
|
||||
if not rec:
|
||||
msgprint("Either customer having no contact or customer's contact does not have mobile no")
|
||||
raise Exception
|
||||
|
||||
for d in rec:
|
||||
ch = addchild(self.doc, 'receiver_details', 'Receiver Detail', 1, self.doclist)
|
||||
ch.customer_name = d[0]
|
||||
ch.receiver_name = d[1]
|
||||
ch.mobile_no = d[2]
|
||||
else:
|
||||
msgprint("Please select 'Send To' field")
|
||||
|
||||
|
||||
def send_sms(self):
|
||||
if not self.doc.message:
|
||||
msgprint("Please type the message before sending")
|
||||
elif not getlist(self.doclist, 'receiver_details'):
|
||||
msgprint("Receiver Table is blank.")
|
||||
else:
|
||||
receiver_list = []
|
||||
for d in getlist(self.doclist, 'receiver_details'):
|
||||
if d.mobile_no:
|
||||
receiver_list.append(d.mobile_no)
|
||||
if receiver_list:
|
||||
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.message))
|
||||
1
utilities/doctype/sms_center/sms_center.txt
Normal file
1
utilities/doctype/sms_center/sms_center.txt
Normal file
File diff suppressed because one or more lines are too long
0
utilities/doctype/sms_control/__init__.py
Normal file
0
utilities/doctype/sms_control/__init__.py
Normal file
93
utilities/doctype/sms_control/sms_control.js
Normal file
93
utilities/doctype/sms_control/sms_control.js
Normal file
@@ -0,0 +1,93 @@
|
||||
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' : '',
|
||||
'Enquiry' : '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) : ''),
|
||||
'Receivable Voucher': 'Invoice ' + doc.name + ' has been sent via email '
|
||||
+ (doc.po_no ? (' for your PO: ' + doc.po_no) : ''),
|
||||
'Indent' : 'Indent ' + 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', 'Receivable Voucher'], 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 == 'Enquiry')
|
||||
sms_man.show('', '', '', doc.contact_no, default_msg[doc.doctype]);
|
||||
else if (doc.doctype == 'Indent')
|
||||
sms_man.show('', '', '', '', default_msg[doc.doctype]);
|
||||
}
|
||||
190
utilities/doctype/sms_control/sms_control.py
Normal file
190
utilities/doctype/sms_control/sms_control.py
Normal file
@@ -0,0 +1,190 @@
|
||||
# Please edit this list and import only required elements
|
||||
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
|
||||
|
||||
|
||||
# Connect Gateway
|
||||
# =========================================================
|
||||
def connect_gateway(self):
|
||||
"login to gateway"
|
||||
from webnotes.utils.webservice import FrameworkServer
|
||||
fw = FrameworkServer('www.erpnext.com','/','__system@webnotestech.com','password',https=1)
|
||||
return fw
|
||||
|
||||
def get_sender_name(self):
|
||||
"returns name as SMS sender"
|
||||
return webnotes.conn.get_value('Manage Account', None, 'sms_sender_name') or 'ERPNext'
|
||||
|
||||
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)
|
||||
else:
|
||||
ret = self.send_via_erpnext_gateway(arg)
|
||||
|
||||
# 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 sms via ERPNext gateway
|
||||
# ==========================================================
|
||||
def send_via_erpnext_gateway(self, arg):
|
||||
fw = self.connect_gateway()
|
||||
ret = fw.run_method(method = 'erpnext_utils.sms_control.send_sms', args = arg)
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
elif ret['message']:
|
||||
sms_sent = cint(ret['message']['sms_sent'])
|
||||
sms_bal = cint(ret['message']['sms_balance'])
|
||||
self.create_sms_log(arg, ret['message']['sms_sent'])
|
||||
|
||||
if not sms_sent:
|
||||
if sms_bal < len(arg['receiver_list']):
|
||||
msgprint("You do not have enough SMS balance. Current SMS Balance: " + cstr(sms_bal) + "\nYou can send mail to sales@erpnext.com to buy additional sms packages")
|
||||
raise Exception
|
||||
else:
|
||||
msgprint("Message sent failed. May be numbers are invalid or some other issues.")
|
||||
else:
|
||||
msgprint(cstr(sms_sent) + " message sucessfully sent!\nCurrent SMS Balance: " + cstr(cint(ret['message']['sms_balance']) - cint(ret['message']['sms_sent'])))
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
# Get SMS Balance
|
||||
# =========================================================
|
||||
def get_sms_balance(self):
|
||||
arg = { 'account_name' : webnotes.conn.get_value('Control Panel',None,'account_id') }
|
||||
if get_value('SMS Settings', None, 'sms_gateway_url'):
|
||||
ret = {}
|
||||
else:
|
||||
fw = self.connect_gateway()
|
||||
ret = fw.run_method(mothod = 'erpnext_utils.sms_control.get_sms_balance', args = arg)
|
||||
|
||||
if ret.get('exc'):
|
||||
msgprint(ret['exc'])
|
||||
raise Exception
|
||||
else:
|
||||
msgprint("Current SMS Balance: " + cstr(ret['message']) + "\nYou can send mail to sales@erpnext.com to buy sms packages")
|
||||
59
utilities/doctype/sms_control/sms_control.txt
Normal file
59
utilities/doctype/sms_control/sms_control.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
# DocType, SMS Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-11 18:40:35',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 0,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0,
|
||||
'version': 8
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Control',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, SMS Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SMS Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sms_log/__init__.py
Normal file
0
utilities/doctype/sms_log/__init__.py
Normal file
130
utilities/doctype/sms_log/sms_log.txt
Normal file
130
utilities/doctype/sms_log/sms_log.txt
Normal file
@@ -0,0 +1,130 @@
|
||||
# DocType, SMS Log
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2011-01-11 13:00:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-11 12:51:46',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'SMSLOG/.########',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Log',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'SMS Log',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, SMS Log
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SMS Log'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 1,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sender_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Sender Name'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sent_on',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 3,
|
||||
'label': 'Sent On'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'receiver_list',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 4,
|
||||
'label': 'Receiver List'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 5,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_requested_sms',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 6,
|
||||
'label': 'No of Requested SMS'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'no_of_sent_sms',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 7,
|
||||
'label': 'No of Sent SMS'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'message',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 8,
|
||||
'label': 'Message'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/sso_control/__init__.py
Normal file
0
utilities/doctype/sso_control/__init__.py
Normal file
30
utilities/doctype/sso_control/sso_control.py
Normal file
30
utilities/doctype/sso_control/sso_control.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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
|
||||
|
||||
def logout_sso(self):
|
||||
import webnotes
|
||||
import webnotes.utils.webservice
|
||||
|
||||
if session['data'].get('login_from'):
|
||||
sso = webnotes.utils.webservice.FrameworkServer(session['data'].get('login_from'), '/', '__system@webnotestech.com', 'password')
|
||||
sso.runserverobj('SSO Control', 'SSO Control', 'logout_user', session['user'])
|
||||
30
utilities/doctype/sso_control/sso_control.txt
Normal file
30
utilities/doctype/sso_control/sso_control.txt
Normal file
@@ -0,0 +1,30 @@
|
||||
# DocType, SSO Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-20 19:44:29',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# DocType, SSO Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'SSO Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/todo_item/__init__.py
Normal file
0
utilities/doctype/todo_item/__init__.py
Normal file
142
utilities/doctype/todo_item/todo_item.txt
Normal file
142
utilities/doctype/todo_item/todo_item.txt
Normal file
@@ -0,0 +1,142 @@
|
||||
# DocType, ToDo Item
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2009-05-12 11:19:11',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'yogesh@webnotestech.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'autoname': 'TDI.########',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'ToDo Item',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'name': '__common__',
|
||||
'parent': 'ToDo Item',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocType, ToDo Item
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'ToDo Item'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'description',
|
||||
'fieldtype': 'Text',
|
||||
'idx': 1,
|
||||
'label': 'Description',
|
||||
'oldfieldname': 'description',
|
||||
'oldfieldtype': 'Text',
|
||||
'width': '300px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Date',
|
||||
'oldfieldname': 'date',
|
||||
'oldfieldtype': 'Date',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'priority',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 3,
|
||||
'label': 'Priority',
|
||||
'oldfieldname': 'priority',
|
||||
'oldfieldtype': 'Data',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'reference_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 4,
|
||||
'label': 'Reference Type',
|
||||
'oldfieldname': 'reference_type',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'reference_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 5,
|
||||
'label': 'Reference Name',
|
||||
'oldfieldname': 'reference_name',
|
||||
'oldfieldtype': 'Data'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'checked',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 6,
|
||||
'label': 'Checked',
|
||||
'oldfieldname': 'checked',
|
||||
'oldfieldtype': 'Check'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'role',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 7,
|
||||
'label': 'Role',
|
||||
'oldfieldname': 'role',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Role'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/trash_control/__init__.py
Normal file
0
utilities/doctype/trash_control/__init__.py
Normal file
59
utilities/doctype/trash_control/trash_control.py
Normal file
59
utilities/doctype/trash_control/trash_control.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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" % cstr(tuple(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()
|
||||
32
utilities/doctype/trash_control/trash_control.txt
Normal file
32
utilities/doctype/trash_control/trash_control.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# DocType, Trash Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:29',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-30 11:44:36',
|
||||
'modified_by': 'umair@iwebnotes.com',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'in_create': 1,
|
||||
'issingle': 1,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'version': 35
|
||||
},
|
||||
|
||||
# DocType, Trash Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Trash Control'
|
||||
}
|
||||
]
|
||||
0
utilities/doctype/wn_erp_client_control/__init__.py
Normal file
0
utilities/doctype/wn_erp_client_control/__init__.py
Normal file
141
utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
Normal file
141
utilities/doctype/wn_erp_client_control/wn_erp_client_control.py
Normal file
@@ -0,0 +1,141 @@
|
||||
# Please edit this list and import only required elements
|
||||
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, removechild, getchildren, make_autoname, SuperDocType
|
||||
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, self.doclist = doc, doclist
|
||||
|
||||
|
||||
# Check End of Trial Period
|
||||
# -------------------------
|
||||
def trial_payment_reminders(self):
|
||||
if cint(self.doc.is_trial_account)==1:
|
||||
# Trial Period Expiry
|
||||
trial_end_date = add_days(self.doc.account_start_date, 30)
|
||||
days = date_diff(trial_end_date, nowdate())
|
||||
# check if trial period has expired
|
||||
if days < 10 and days >= 0 and has_common(['System Manager'],webnotes.user.get_roles()):
|
||||
return "Your Trial Period expires on '%s'. Please buy credits online using Manage Account." % (formatdate(trial_end_date))
|
||||
|
||||
# trial period has already expired
|
||||
elif days < 0 and days >= -6:
|
||||
extended_days = 7 + days
|
||||
return "Your Trial Period has expired on %s. However, your account will be live for %s days. Please contact your System Manager to buy credits." % (formatdate(trial_end_date),cstr(extended_days))
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()) and days < -6:
|
||||
return "Stopped"
|
||||
|
||||
# Account is not a trial account
|
||||
else:
|
||||
return self.account_expiry_reminder()
|
||||
|
||||
|
||||
# Account Expiry Reminder
|
||||
# -----------------------
|
||||
def account_expiry_reminder(self):
|
||||
import webnotes.utils
|
||||
from datetime import datetime
|
||||
# Payment Reminder in case of not enough balance
|
||||
cr_reqd = cint(self.doc.total_users)
|
||||
days_left = cint(self.calc_days())
|
||||
# check if account balance is sufficient
|
||||
if cint(self.doc.credit_balance)<(cr_reqd):
|
||||
|
||||
# Difference between last payment date and current date
|
||||
if self.doc.last_deduction_date: last_payment = date_diff(nowdate(),self.doc.last_deduction_date)
|
||||
else: last_payment = -1
|
||||
|
||||
# 7 days extension
|
||||
remaining_days = days_left - 24
|
||||
if last_payment > 30 or last_payment == -1:
|
||||
if remaining_days < 8 and remaining_days >= 1:
|
||||
return "Your account will be de-activated in " + cstr(remaining_days) + " days. Please contact your System Manager to buy credits."
|
||||
elif remaining_days==0:
|
||||
return "Your account will be disabled from tomorrow. Please contact your System Manager to buy credits."
|
||||
elif not has_common(['Administrator'],webnotes.user.get_roles()):
|
||||
return "Stopped"
|
||||
|
||||
# check if user account is extended for seven days
|
||||
if cint(self.doc.is_trial_account)==0:
|
||||
if days_left < 10 and days_left >= 0:
|
||||
return "You have only %s Credits in your account. Buy credits before %s." % (cint(self.doc.credit_balance),formatdate(self.next_bill_sdate))
|
||||
|
||||
|
||||
|
||||
# Calculate days between current date and billing cycle end date
|
||||
# --------------------------------------------------------------
|
||||
def calc_days(self):
|
||||
if self.doc.billing_cycle_date:
|
||||
next_bill_month = cint(nowdate().split('-')[1])
|
||||
if cint(nowdate().split('-')[2]) > cint(self.doc.billing_cycle_date.split('-')[2]):
|
||||
next_bill_month = cint(nowdate().split('-')[1]) + 1
|
||||
next_bill_year = nowdate().split('-')[0]
|
||||
if next_bill_month > 12:
|
||||
next_bill_month = next_bill_month % 12
|
||||
next_bill_year += 1
|
||||
self.next_bill_sdate = cstr(next_bill_year)+'-'+cstr(next_bill_month)+'-'+(self.calc_next_day(next_bill_year,next_bill_month))
|
||||
#msgprint("next_bill_month :::" + self.next_bill_sdate)
|
||||
return date_diff(self.next_bill_sdate, nowdate())
|
||||
|
||||
|
||||
# Calculate next billing date day
|
||||
# --------------------------------
|
||||
def calc_next_day(self, next_year, next_month):
|
||||
bill_cycle_day = cstr(self.doc.billing_cycle_date).split('-')[2]
|
||||
if cint(next_month) == 2 and next_year%4==0 and (next_year%100!=0 or next_year%400==0) and cint(bill_cycle_day) > 28:
|
||||
bill_cycle_day = '28'
|
||||
elif cint(bill_cycle_day) == 31 and cint(next_month) in (4,6,9,11):
|
||||
bill_cycle_day = '30'
|
||||
return bill_cycle_day
|
||||
|
||||
|
||||
# Update acc credits and balance (making payment from gateway)
|
||||
# -------------------------------------------------------------
|
||||
def update_acc_bal(self,args):
|
||||
args = eval(args)
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) + cint(args.get('net_cr'))
|
||||
self.doc.total_users = cint(self.doc.total_users) + cint(args.get('total_users'))
|
||||
if cint(self.doc.is_trial_account) == 1:
|
||||
if not self.doc.account_start_date:
|
||||
self.doc.account_start_date = nowdate()
|
||||
self.doc.is_trial_account = 0
|
||||
self.doc.billing_cycle_date = nowdate()
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Check Credit Balance
|
||||
# ---------------------
|
||||
def check_credit_balance(self):
|
||||
if cint(self.doc.is_trial_account) == 0:
|
||||
if cint(self.doc.credit_balance) < 1:
|
||||
msgprint("You do not have enough credits to add new user. Please buy credits.")
|
||||
raise Exception
|
||||
else:
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - 1
|
||||
msgprint("Your one credit is consumed. Balance Credits : %s" % (self.doc.credit_balance))
|
||||
self.doc.total_users = cint(self.doc.total_users) + 1
|
||||
self.doc.save()
|
||||
|
||||
|
||||
# Monthly Deduction
|
||||
# ------------------
|
||||
def monthly_deduction(self, cr_ded):
|
||||
self.doc.credit_balance = cint(self.doc.credit_balance) - cint(cr_ded)
|
||||
self.doc.last_deduction_date = nowdate()
|
||||
self.doc.save()
|
||||
@@ -0,0 +1,124 @@
|
||||
# DocType, WN ERP Client Control
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:30',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'istable': 0,
|
||||
'module': 'Utilities',
|
||||
'name': '__common__',
|
||||
'read_only': 1,
|
||||
'section_style': 'Simple',
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': 1,
|
||||
'version': 137
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'WN ERP Client Control',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'WN ERP Client Control',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'read': 1,
|
||||
'role': 'System Manager'
|
||||
},
|
||||
|
||||
# DocType, WN ERP Client Control
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'WN ERP Client Control'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'account_start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 1,
|
||||
'label': 'Account Start Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'billing_cycle_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 2,
|
||||
'label': 'Billing Cycle Date'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'total_users',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 3,
|
||||
'label': 'Total Users'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'credit_balance',
|
||||
'fieldtype': 'Int',
|
||||
'idx': 4,
|
||||
'label': 'Credit Balance'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_trial_account',
|
||||
'fieldtype': 'Check',
|
||||
'idx': 5,
|
||||
'label': 'Is Trial Account'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'last_deduction_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 6,
|
||||
'label': 'Last Credit Deduction Date'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user