mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
first cut for lazy loading framework
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
//-------------------------- Onload ---------------------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
|
||||
}
|
||||
|
||||
//------------------- Get Contact Person based on customer selected ---------------------------
|
||||
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
if(doc.customer)
|
||||
return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE (`tabContact`.is_customer = 1 AND `tabContact`.customer_name = "'+ doc.customer+'") AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
|
||||
else
|
||||
msgprint("Please select Customer first")
|
||||
}
|
||||
|
||||
//-------------------------------- get query select Territory ------------------------------------------
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
|
||||
//------------------------ Customer and its primary contact Details ------------------------------------
|
||||
cur_frm.cscript.customer = function(doc, cdt, cdn) {
|
||||
if(doc.customer) get_server_fields('get_customer_details', '','', doc, cdt, cdn, 1);
|
||||
}
|
||||
|
||||
//--------------------- Customer's Contact Person Details --------------------------------------------
|
||||
cur_frm.cscript.contact_person = function(doc, cdt, cdn) {
|
||||
if(doc.contact_person) {
|
||||
get_server_fields('get_contact_details','','',doc, cdt, cdn, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------- calculate gross profit --------------------------------
|
||||
cur_frm.cscript.project_value = function(doc, cdt, cdn){
|
||||
get_server_fields('get_gross_profit','','',doc, cdt, cdn, 1);
|
||||
}
|
||||
|
||||
//--------- calculate gross profit --------------------------------
|
||||
cur_frm.cscript.est_material_cost = function(doc, cdt, cdn){
|
||||
get_server_fields('get_gross_profit','','',doc, cdt, cdn, 1);
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
# 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 Customer Details along with its primary contact details
|
||||
# ==============================================================
|
||||
def get_customer_details(self):
|
||||
details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
|
||||
if details:
|
||||
ret = {
|
||||
'customer_address' : details and details[0]['address'] or '',
|
||||
'territory' : details and details[0]['territory'] or '',
|
||||
'customer_group' : details and details[0]['customer_group'] or '',
|
||||
'customer_name' : details and details[0]['customer_name'] or ''
|
||||
}
|
||||
#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
|
||||
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact='Yes' and docstatus!=2" %(self.doc.customer), as_dict = 1)
|
||||
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
|
||||
ret['contact_no'] = contact_det and contact_det[0]['contact_no'] or ''
|
||||
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
|
||||
return ret
|
||||
else:
|
||||
msgprint("Customer : %s does not exist in system." % (self.doc.customer))
|
||||
raise Exception
|
||||
|
||||
# Get customer's contact person details
|
||||
# ==============================================================
|
||||
def get_contact_details(self):
|
||||
contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1)
|
||||
if contact:
|
||||
ret = {
|
||||
'contact_no' : contact and contact[0]['contact_no'] or '',
|
||||
'email_id' : contact and contact[0]['email_id'] or ''
|
||||
}
|
||||
return ret
|
||||
else:
|
||||
msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person))
|
||||
raise Exception
|
||||
|
||||
#calculate gross profit
|
||||
#=============================================
|
||||
def get_gross_profit(self):
|
||||
pft, per_pft =0, 0
|
||||
pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost)
|
||||
#if pft > 0:
|
||||
per_pft = (flt(pft) / flt(self.doc.project_value)) * 100
|
||||
ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft}
|
||||
return ret
|
||||
|
||||
# validate
|
||||
#================================================
|
||||
def validate(self):
|
||||
if self.doc.project_start_date and self.doc.completion_date:
|
||||
if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date):
|
||||
msgprint("Expected Completion Date can not be less than Project Start Date")
|
||||
raise Exception
|
||||
@@ -1,485 +0,0 @@
|
||||
# DocType, Project
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-08-08 17:09:14',
|
||||
'docstatus': 0,
|
||||
'modified': '2011-01-05 15:24:43',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': '1305714062',
|
||||
'allow_trash': 1,
|
||||
'autoname': 'field:project_name',
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': 'Master',
|
||||
'module': 'Projects',
|
||||
'name': '__common__',
|
||||
'search_fields': 'customer, status, priority, is_active',
|
||||
'section_style': 'Tabbed',
|
||||
'server_code_error': ' ',
|
||||
'subject': ' ',
|
||||
'tag_fields': 'status',
|
||||
'version': 32
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'name': '__common__',
|
||||
'parent': 'Project',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': 'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': 'Project',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Project
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': 'Project'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 1,
|
||||
'role': 'All'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': 'DocPerm',
|
||||
'idx': 2,
|
||||
'role': 'Projects User'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Helps you keep track of your projects and links to Tasks. You can tag a task to a project to track its progress',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 1,
|
||||
'label': 'Basic Info',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': 'Project will get saved and will be searchable with project name given',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'project_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 2,
|
||||
'label': 'Project Name',
|
||||
'oldfieldname': 'project_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'default': 'Open',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'status',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 3,
|
||||
'in_filter': 1,
|
||||
'label': 'Status',
|
||||
'oldfieldname': 'status',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Open\nCompleted\nCancelled',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'is_active',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 4,
|
||||
'label': 'Is Active',
|
||||
'oldfieldname': 'is_active',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Yes\nNo',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'priority',
|
||||
'fieldtype': 'Select',
|
||||
'idx': 5,
|
||||
'label': 'Priority',
|
||||
'oldfieldname': 'priority',
|
||||
'oldfieldtype': 'Select',
|
||||
'options': 'Medium\nLow\nHigh',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'project_value',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 6,
|
||||
'label': 'Project Value',
|
||||
'oldfieldname': 'project_value',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'gross_margin_value',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 7,
|
||||
'label': 'Gross Margin Value',
|
||||
'oldfieldname': 'gross_margin_value',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'per_gross_margin',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 8,
|
||||
'label': 'Gross Margin %',
|
||||
'oldfieldname': 'per_gross_margin',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'est_material_cost',
|
||||
'fieldtype': 'Currency',
|
||||
'idx': 9,
|
||||
'label': 'Estimated Material Cost',
|
||||
'oldfieldname': 'est_material_cost',
|
||||
'oldfieldtype': 'Currency',
|
||||
'permlevel': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'project_type',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 10,
|
||||
'label': 'Project Type',
|
||||
'oldfieldname': 'project_type',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'project_start_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 11,
|
||||
'in_filter': 1,
|
||||
'label': 'Project Start Date',
|
||||
'oldfieldname': 'project_start_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'completion_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 12,
|
||||
'label': 'Completion Date',
|
||||
'oldfieldname': 'completion_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'act_completion_date',
|
||||
'fieldtype': 'Date',
|
||||
'idx': 13,
|
||||
'label': 'Actual Completion Date',
|
||||
'oldfieldname': 'act_completion_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amended_from',
|
||||
'fieldtype': 'Data',
|
||||
'hidden': 1,
|
||||
'idx': 14,
|
||||
'label': 'Amended From',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amended_from',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'print_hide': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'amemdment_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': 1,
|
||||
'idx': 15,
|
||||
'label': 'Amemdment Date',
|
||||
'no_copy': 1,
|
||||
'oldfieldname': 'amemdment_date',
|
||||
'oldfieldtype': 'Date',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 16,
|
||||
'label': 'Project Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Column Break',
|
||||
'idx': 17,
|
||||
'oldfieldtype': 'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': '50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 18,
|
||||
'oldfieldtype': 'Section Break',
|
||||
'options': 'Simple',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'notes',
|
||||
'fieldtype': 'Text Editor',
|
||||
'idx': 19,
|
||||
'label': 'Notes',
|
||||
'oldfieldname': 'notes',
|
||||
'oldfieldtype': 'Text Editor',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 20,
|
||||
'label': 'Customer Details',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Select name of Customer to whom project belongs',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 21,
|
||||
'in_filter': 1,
|
||||
'label': 'Customer',
|
||||
'oldfieldname': 'customer',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Customer',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'reqd': 0,
|
||||
'search_index': 1,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_name',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 22,
|
||||
'in_filter': 1,
|
||||
'label': 'Customer Name',
|
||||
'oldfieldname': 'customer_name',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_address',
|
||||
'fieldtype': 'Small Text',
|
||||
'idx': 23,
|
||||
'label': 'Customer Address',
|
||||
'oldfieldname': 'customer_address',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_person',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 24,
|
||||
'in_filter': 1,
|
||||
'label': 'Contact Person',
|
||||
'oldfieldname': 'contact_person',
|
||||
'oldfieldtype': 'Link',
|
||||
'permlevel': 0,
|
||||
'reqd': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'territory',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 25,
|
||||
'in_filter': 1,
|
||||
'label': 'Territory',
|
||||
'oldfieldname': 'territory',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Territory',
|
||||
'permlevel': 0,
|
||||
'reqd': 0,
|
||||
'search_index': 0,
|
||||
'trigger': 'Client'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'contact_no',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 26,
|
||||
'label': 'Contact No',
|
||||
'oldfieldname': 'contact_no',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'email_id',
|
||||
'fieldtype': 'Data',
|
||||
'idx': 27,
|
||||
'label': 'Email Id',
|
||||
'oldfieldname': 'email_id',
|
||||
'oldfieldtype': 'Data',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer_group',
|
||||
'fieldtype': 'Link',
|
||||
'idx': 28,
|
||||
'label': 'Customer Group',
|
||||
'oldfieldname': 'customer_group',
|
||||
'oldfieldtype': 'Link',
|
||||
'options': 'Customer Group',
|
||||
'permlevel': 1,
|
||||
'search_index': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': 'White:FFF',
|
||||
'description': 'Important dates and commitments in your project life cycle',
|
||||
'doctype': 'DocField',
|
||||
'fieldtype': 'Section Break',
|
||||
'idx': 29,
|
||||
'label': 'Milestones',
|
||||
'oldfieldtype': 'Section Break',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'project_milestones',
|
||||
'fieldtype': 'Table',
|
||||
'idx': 30,
|
||||
'label': 'Project Milestones',
|
||||
'oldfieldname': 'project_milestones',
|
||||
'oldfieldtype': 'Table',
|
||||
'options': 'Project Milestone',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'trash_reason',
|
||||
'fieldtype': 'Small Text',
|
||||
'hidden': 1,
|
||||
'idx': 31,
|
||||
'label': 'Trash Reason',
|
||||
'oldfieldname': 'trash_reason',
|
||||
'oldfieldtype': 'Small Text',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user