Sourced wnframework-modules from Google Code as erpnext

This commit is contained in:
Pratik Vyas
2011-06-08 14:37:15 +05:30
commit c1e6e4c752
1680 changed files with 162635 additions and 0 deletions

694
crm/Module Def/CRM/CRM.txt Normal file
View File

@@ -0,0 +1,694 @@
[
{
'_last_update': None,
'creation': '2010-11-30 17:31:24',
'disabled': 'No',
'docstatus': 0,
'doctype': 'Module Def',
'doctype_list': 'Print Format, Sales Order\nPrint Format, Quotation Format\nPrint Format, Delivery Note Format',
'file_list': 'crm.gif,FileData/00208',
'idx': None,
'is_hidden': 'No',
'last_updated_date': '2010-12-09 17:04:58',
'modified': '2011-02-24 17:36:51',
'modified_by': 'Administrator',
'module_desc': 'Manage you sales team, with your leads, customers, quotes, orders etc.',
'module_icon': 'Selling.gif',
'module_label': 'Selling',
'module_name': 'CRM',
'module_page': None,
'module_seq': 4,
'name': 'CRM',
'owner': 'Administrator',
'parent': None,
'parentfield': None,
'parenttype': None,
'trash_reason': None,
'widget_code': None
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': 'Database of potential customers you need to keep in touch with',
'display_name': 'Lead',
'doc_name': 'Lead',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'status\nlead_owner\nlead_name\ncontact_no\ncontact_by\ncontact_date\nexpected_month',
'hide': None,
'icon': None,
'idx': 1,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00067',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': 'Your Customer Database',
'display_name': 'Customer',
'doc_name': 'Customer',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'customer_group\ncountry',
'hide': None,
'icon': None,
'idx': 2,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00068',
'owner': 'harshada@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': 'Specific requirements from a Lead / Customer',
'display_name': 'Enquiry',
'doc_name': 'Enquiry',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ncompany',
'hide': None,
'icon': None,
'idx': 3,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00069',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': 'Offers you have made to your customers',
'display_name': 'Quotation',
'doc_name': 'Quotation',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'status\ntransaction_date\ncustomer\ncontact_person\ncost_center\ngrand_total\ncompany',
'hide': None,
'icon': None,
'idx': 4,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00070',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': 'Database of confirmed Sale Orders from your Customers',
'display_name': 'Sales Order',
'doc_name': 'Sales Order',
'doc_type': 'Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'status\ntransaction_date\ncustomer\ncost_center\ngrand_total\nper_delivered\nper_billed\ncompany',
'hide': None,
'icon': None,
'idx': 5,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00071',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2010-11-30 17:31:24',
'description': None,
'display_name': 'Sales Dashboard',
'doc_name': 'Sales Dashboard',
'doc_type': 'Pages',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 6,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00072',
'owner': 'harshada@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': None,
'doc_name': 'Reports',
'doc_type': 'Separator',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 7,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00309',
'owner': 'saumil@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Territory, Item Group wise GP',
'doc_name': 'Delivery Note',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 9,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00311',
'owner': 'harshada@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Itemwise Delivery Details',
'doc_name': 'Delivery Note Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 11,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00313',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Personwise Transaction Summary',
'doc_name': 'Sales Person',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 12,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00314',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Persons Target Variance (Item Group wise)',
'doc_name': 'Target Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 14,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00316',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Territories Target Variance (Item Group wise)',
'doc_name': 'Target Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 15,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00315',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Territories Target Variance (Item Group wise)',
'doc_name': 'Target Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 15,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00317',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Order Pending Items',
'doc_name': 'Sales Order Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 16,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00318',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Orderwise Booking & Delivery Summary',
'doc_name': 'Sales Order Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 17,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00319',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Orderwise Pending Qty To Deliver',
'doc_name': 'Sales Order Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 18,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00320',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Orderwise Pending Packing Item Summary',
'doc_name': 'Delivery Note Packing Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 19,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00321',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Orderwise Pending Amount To Bill',
'doc_name': 'Sales Order Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 20,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00312',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Sales Orderwise Pending Amount To Bill',
'doc_name': 'Sales Order Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 20,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00322',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Delivered Items to be Install',
'doc_name': 'Delivery Note Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 21,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00310',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Delivered Items to be Install',
'doc_name': 'Delivery Note Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 21,
'modified': '2011-03-01 13:53:34',
'modified_by': 'Administrator',
'name': 'MDI00323',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Itemwise Price List',
'doc_name': 'Ref Rate Detail',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 22,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00324',
'owner': 'harshada@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': None,
'display_name': 'Follow-up Report',
'doc_name': 'Follow up',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 23,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00325',
'owner': 'ashwini@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Ledger details of your debtors',
'display_name': "Debtor's Ledger",
'doc_name': 'GL Entry',
'doc_type': 'Reports',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': None,
'hide': None,
'icon': None,
'idx': 24,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00326',
'owner': 'nabin@webnotestech.com',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Customer Category',
'display_name': 'Customer Group',
'doc_name': 'Customer Group',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'id\ndescription',
'hide': None,
'icon': None,
'idx': 25,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00327',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Sales person details',
'display_name': 'Sales Person',
'doc_name': 'Sales Person',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'id\nterritory\ndepartment\nmobile_no\nemail_id',
'hide': None,
'icon': None,
'idx': 26,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00328',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Item master',
'display_name': 'Item',
'doc_name': 'Item',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'name\nitem_group\ndescription',
'hide': None,
'icon': None,
'idx': 27,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00329',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Sales partner details',
'display_name': 'Sales Partner',
'doc_name': 'Sales Partner',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'id\npartner_type\nmobile\nemail\nterritory',
'hide': None,
'icon': None,
'idx': 28,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00330',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'click_function': None,
'creation': '2011-03-01 13:53:34',
'description': 'Business campaigns',
'display_name': 'Campaign',
'doc_name': 'Campaign',
'doc_type': 'Setup Forms',
'docstatus': 0,
'doctype': 'Module Def Item',
'fields': 'id\ncampaign_name\ndescription',
'hide': None,
'icon': None,
'idx': 29,
'modified': '2011-03-24 15:04:46',
'modified_by': 'Administrator',
'name': 'MDI00331',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'items',
'parenttype': 'Module Def'
},
{
'creation': '2010-11-30 17:31:24',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 1,
'modified': '2010-11-30 17:31:24',
'modified_by': 'Administrator',
'name': 'MDR00008',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Administrator'
},
{
'creation': '2010-11-30 17:31:24',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 2,
'modified': '2010-11-30 17:31:24',
'modified_by': 'Administrator',
'name': 'MDR00009',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales Manager'
},
{
'creation': '2010-11-30 17:31:24',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 3,
'modified': '2010-11-30 17:31:24',
'modified_by': 'Administrator',
'name': 'MDR00010',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales User'
},
{
'creation': '2010-11-30 17:31:24',
'docstatus': 0,
'doctype': 'Module Def Role',
'idx': 4,
'modified': '2010-11-30 17:31:24',
'modified_by': 'Administrator',
'name': 'MDR00011',
'owner': 'Administrator',
'parent': 'CRM',
'parentfield': 'roles',
'parenttype': 'Module Def',
'role': 'Sales Master Manager'
}
]

0
crm/__init__.py Normal file
View File

0
crm/doctype/__init__.py Normal file
View File

View File

View File

@@ -0,0 +1,10 @@
$import(Tips Common)
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.get_tips(doc, cdt, cdn);
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.get_tips(doc, cdt, cdn);
}

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,211 @@
$import(Contact Control)
/* ********************************* onload ********************************************* */
cur_frm.cscript.onload = function(doc,dt,dn){
// history doctypes and scripts
cur_frm.history_dict = {
'Quotation' : 'cur_frm.cscript.make_qtn_list(this.body, this.doc)',
'Sales Order' : 'cur_frm.cscript.make_so_list(this.body, this.doc)',
'Delivery Note' : 'cur_frm.cscript.make_dn_list(this.body, this.doc)',
'Sales Invoice' : 'cur_frm.cscript.make_si_list(this.body, this.doc)'
}
// make address, contact, shipping, history list body
cur_frm.cscript.make_hl_body();
//cur_frm.cscript.make_sl_body();
}
cur_frm.add_fetch('lead_name', 'company_name', 'customer_name');
cur_frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
/* ********************************* refresh ********************************************* */
cur_frm.cscript.refresh = function(doc,dt,dn) {
if(sys_defaults.cust_master_name == 'Customer Name')
hide_field('naming_series');
else
unhide_field('naming_series');
if(doc.__islocal){
hide_field(['Address HTML','Contact HTML']);
//cur_frm.cscript.set_hl_msg(doc);
//cur_frm.cscript.set_sl_msg(doc);
}else{
unhide_field(['Address HTML','Contact HTML']);
// make lists
cur_frm.cscript.make_address(doc,dt,dn);
cur_frm.cscript.make_contact(doc,dt,dn);
cur_frm.cscript.make_history(doc,dt,dn);
//cur_frm.cscript.make_shipping_address(doc,dt,dn);
}
}
cur_frm.cscript.make_address = function() {
if(!cur_frm.address_list) {
cur_frm.address_list = new wn.widgets.Listing({
parent: cur_frm.fields_dict['Address HTML'].wrapper,
page_length: 2,
new_doctype: "Address",
new_doc_onload: function(dn) {
ndoc = locals["Address"][dn];
ndoc.customer = cur_frm.doc.name;
ndoc.customer_name = cur_frm.doc.customer_name;
ndoc.address_type = 'Office';
},
new_doc_onsave: function(dn) {
cur_frm.address_list.run()
},
get_query: function() {
return "select name, address_type, address_line1, address_line2, city, state, country, pincode, fax, email_id, phone, is_primary_address, is_shipping_address from tabAddress where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_address desc"
},
as_dict: 1,
no_results_message: 'No addresses created',
render_row: function(wrapper, data) {
$(wrapper).css('padding','5px 0px');
var link = $ln(wrapper,cstr(data.name), function() { loaddoc("Address", this.dn); }, {fontWeight:'bold'});
link.dn = data.name
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_address ? '[Primary]' : '') + (data.is_shipping_address ? '[Shipping]' : ''));
$a(wrapper,'div','',{marginTop:'5px', color:'#555'},
(data.address_line1 ? data.address_line1 + '<br />' : '') +
(data.address_line2 ? data.address_line2 + '<br />' : '') +
(data.city ? data.city + '<br />' : '') +
(data.state ? data.state + ', ' : '') +
(data.country ? data.country + '<br />' : '') +
(data.pincode ? 'Pincode: ' + data.pincode + '<br />' : '') +
(data.phone ? 'Phone: ' + data.phone + '<br />' : '') +
(data.fax ? 'Fax: ' + data.fax + '<br />' : '') +
(data.email_id ? 'Email: ' + data.email_id + '<br />' : ''));
}
});
}
cur_frm.address_list.run();
}
cur_frm.cscript.make_contact = function() {
if(!cur_frm.contact_list) {
cur_frm.contact_list = new wn.widgets.Listing({
parent: cur_frm.fields_dict['Contact HTML'].wrapper,
page_length: 2,
new_doctype: "Contact",
new_doc_onload: function(dn) {
ndoc = locals["Contact"][dn];
ndoc.customer = cur_frm.doc.name;
ndoc.customer_name = cur_frm.doc.customer_name;
if(cur_frm.doc.customer_type == 'Individual') {
ndoc.first_name = cur_frm.doc.customer_name;
}
},
new_doc_onsave: function(dn) {
cur_frm.contact_list.run()
},
get_query: function() {
return "select name, first_name, last_name, email_id, phone, mobile_no, department, designation, is_primary_contact from tabContact where customer='"+cur_frm.docname+"' and docstatus != 2 order by is_primary_contact desc"
},
as_dict: 1,
no_results_message: 'No contacts created',
render_row: function(wrapper, data) {
$(wrapper).css('padding', '5px 0px');
var link = $ln(wrapper, cstr(data.name), function() { loaddoc("Contact", this.dn); }, {fontWeight:'bold'});
link.dn = data.name
$a(wrapper,'span','',{marginLeft:'5px', color: '#666'},(data.is_primary_contact ? '[Primary]' : ''));
$a(wrapper,'div', '',{marginTop:'5px', color:'#555'}, data.first_name + (data.last_name ? ' ' + data.last_name + '<br />' : '<br>') + (data.phone ? 'Tel: ' + data.phone + '<br />' : '') + (data.mobile_no ? 'Mobile: ' + data.mobile_no + '<br />' : '') + (data.email_id ? 'Email: ' + data.email_id + '<br />' : '') + (data.department ? 'Department: ' + data.department + '<br />' : '') + (data.designation ? 'Designation: ' + data.designation + '<br />' : ''));
}
});
}
cur_frm.contact_list.run();
}
/* ********************************* client triggers ************************************** */
// ---------------
// customer group
// ---------------
cur_frm.fields_dict['customer_group'].get_query = function(doc,dt,dn) {
return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50';
}
cur_frm.cscript.CGHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Customer Group');
}
loadpage('Sales Browser',call_back);
}
// -----
// lead
// -----
cur_frm.fields_dict['lead_name'].get_query = function(doc,dt,dn){
return 'SELECT `tabLead`.`name` FROM `tabLead` WHERE `tabLead`.`status`!="Converted" AND `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';
}
/* ********************************* transaction history ************************************** */
// --------------------
// make quotation list
// --------------------
cur_frm.cscript.make_qtn_list = function(parent,doc){
var lst = new Listing();
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
lst.colnames = ['Sr.','Id','Status','Quotation Date','Contact Person','Grand Total'];
lst.coltypes = ['Data','Link','Data','Data','Data','Currency'];
lst.coloptions = ['','Quotation','','','',''];
var q = repl("select name,status,transaction_date, contact_person, grand_total from tabQuotation where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
var q_max = repl("select count(name) from tabQuotation where customer='%(cust)s'", {'cust':doc.name});
cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Quotation','Quotation');
}
// -------------
// make so list
// -------------
cur_frm.cscript.make_so_list = function(parent,doc){
var lst = new Listing();
lst.colwidths = ['5%','20%','20%','30%','25%'];
lst.colnames = ['Sr.','Id','Status','Sales Order Date','Grand Total'];
lst.coltypes = ['Data','Link','Data','Data','Currency'];
lst.coloptions = ['','Sales Order','','',''];
var q = repl("select name,status,transaction_date, grand_total from `tabSales Order` where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
var q_max = repl("select count(name) from `tabSales Order` where customer='%(cust)s'", {'cust':doc.name});
cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Order','Sales Order');
}
// -------------
// make dn list
// -------------
cur_frm.cscript.make_dn_list = function(parent,doc){
var lst = new Listing();
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
lst.colnames = ['Sr.','Id','Status','Delivery Note Date','Territory','Grand Total'];
lst.coltypes = ['Data','Link','Data','Data','Link','Currency'];
lst.coloptions = ['','Delivery Note','','','Territory',''];
var q = repl("select name,status,transaction_date,territory,grand_total from `tabDelivery Note` where customer='%(cust)s' order by transaction_date desc", {'cust':doc.name});
var q_max = repl("select count(name) from `tabDelivery Note` where customer='%(cust)s'", {'cust':doc.name});
cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Delivery Note','Delivery Note');
}
// -------------
// make si list
// -------------
cur_frm.cscript.make_si_list = function(parent,doc){
var lst = new Listing();
lst.colwidths = ['5%','20%','20%','20%','20%','15%'];
lst.colnames = ['Sr.','Id','Posting Date','Due Date','Debit To','Grand Total'];
lst.coltypes = ['Data','Link','Data','Data','Link','Currency'];
lst.coloptions = ['','Receivable Voucher','','','Account',''];
var q = repl("select name,posting_date,due_date,debit_to,grand_total from `tabReceivable Voucher` where customer='%(cust)s' order by posting_date desc", {'cust':doc.name});
var q_max = repl("select count(name) from `tabReceivable Voucher` where customer='%(cust)s'", {'cust':doc.name});
cur_frm.cscript.run_list(lst,parent,q,q_max,doc,'Sales Invoice','Receivable Voucher');
}

View File

@@ -0,0 +1,220 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import cstr, date_diff, flt, formatdate, get_defaults, getdate, has_common, now, nowdate, replace_newlines, sendmail, set_default, user_format, validate_email_add
from webnotes.model.doc import Document, make_autoname
from webnotes.model.code import get_obj
from webnotes import msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
class DocType:
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
# ******************************************************* autoname ***********************************************************
def autoname(self):
cust_master_name = get_defaults().get('cust_master_name')
if cust_master_name == 'Customer Name':
# filter out bad characters in name
cust = self.doc.customer_name.replace('&','and').replace('.','').replace("'",'').replace('"','').replace(',','').replace('`','')
supp = sql("select name from `tabSupplier` where name = %s", (cust))
supp = supp and supp[0][0] or ''
if supp:
msgprint("You already have a Supplier with same name")
raise Exception
else:
self.doc.name = cust
else:
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# ******************************************************* triggers ***********************************************************
# ----------------
# get company abbr
# -----------------
def get_company_abbr(self):
return get_value('Company', self.doc.company, 'abbr')
# -----------------------------------------------------------------------------------------------------
# get parent account(i.e receivables group from company where default account head need to be created)
# -----------------------------------------------------------------------------------------------------
def get_receivables_group(self):
g = sql("select receivables_group from tabCompany where name=%s", self.doc.company)
g = g and g[0][0] or ''
if not g:
msgprint("Update Company master, assign a default group for Receivables")
raise Exception
return g
# ******************************************************* validate *********************************************************
# ----------------
# validate values
# ----------------
def validate_values(self):
# Master name by naming series -> Series field mandatory
if get_defaults().get('cust_master_name') == 'Naming Series' and not self.doc.naming_series:
msgprint("Series is Mandatory.")
raise Exception
# ---------
# validate
# ---------
def validate(self):
self.validate_values()
# ******************************************************* on update *********************************************************
# ------------------------
# create customer address
# ------------------------
def create_customer_address(self):
addr_flds = [self.doc.address_line1, self.doc.address_line2, self.doc.city, self.doc.state, self.doc.country, self.doc.pincode]
address_line = "\n".join(filter(lambda x : (x!='' and x!=None),addr_flds))
if self.doc.phone_1:
address_line = address_line + "\n" + "Phone: " + cstr(self.doc.phone_1)
if self.doc.email_id:
address_line = address_line + "\n" + "E-mail: " + cstr(self.doc.email_id)
set(self.doc,'address', address_line)
telephone = "(O): " + cstr(self.doc.phone_1) +"\n"+ cstr(self.doc.phone_2) + "\n" + "(M): " + "\n" + "(fax): " + cstr(self.doc.fax_1)
set(self.doc,'telephone',telephone)
# ------------------------------------
# create primary contact for customer
# ------------------------------------
def create_p_contact(self,nm,phn_no,email_id,mob_no,fax,cont_addr):
c1 = Document('Contact')
c1.first_name = nm
c1.contact_name = nm
c1.contact_no = phn_no
c1.email_id = email_id
c1.mobile_no = mob_no
c1.fax = fax
c1.contact_address = cont_addr
c1.is_primary_contact = 'Yes'
c1.is_customer =1
c1.customer = self.doc.name
c1.customer_name = self.doc.customer_name
c1.customer_address = self.doc.address
c1.customer_group = self.doc.customer_group
c1.save(1)
# ------------------------
# create customer contact
# ------------------------
def create_customer_contact(self):
contact = sql("select distinct name from `tabContact` where customer_name=%s", (self.doc.customer_name))
contact = contact and contact[0][0] or ''
if not contact:
# create primary contact for individual customer
if self.doc.customer_type == 'Individual':
self.create_p_contact(self.doc.customer_name,self.doc.phone_1,self.doc.email_id,'',self.doc.fax_1,self.doc.address)
# create primary contact for lead
elif self.doc.lead_name:
c_detail = sql("select lead_name, company_name, contact_no, mobile_no, email_id, fax, address from `tabLead` where name =%s", self.doc.lead_name, as_dict=1)
self.create_p_contact(c_detail and c_detail[0]['lead_name'] or '', c_detail and c_detail[0]['contact_no'] or '', c_detail and c_detail[0]['email_id'] or '', c_detail and c_detail[0]['mobile_no'] or '', c_detail and c_detail[0]['fax'] or '', c_detail and c_detail[0]['address'] or '')
# -------------------
# update lead status
# -------------------
def update_lead_status(self):
if self.doc.lead_name:
sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name)
# -------------------------------------------------------------------------
# create accont head - in tree under receivables_group of selected company
# -------------------------------------------------------------------------
def create_account_head(self):
if self.doc.company :
abbr = self.get_company_abbr()
if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)):
parent_account = self.get_receivables_group()
arg = {'account_name':self.doc.name,'parent_account': parent_account, 'group_or_ledger':'Ledger', 'company':self.doc.company,'account_type':'','tax_rate':'0','master_type':'Customer','master_name':self.doc.name,'address':self.doc.address}
# create
ac = get_obj('GL Control').add_ac(cstr(arg))
msgprint("Account Head created for "+ac)
else :
msgprint("Please Select Company under which you want to create account head")
# ----------------------------------------
# update credit days and limit in account
# ----------------------------------------
def update_credit_days_limit(self):
sql("update tabAccount set credit_days = '%s', credit_limit = '%s' where name = '%s'" % (self.doc.credit_days, self.doc.credit_limit, self.doc.name + " - " + self.get_company_abbr()))
#create address and contact from lead
def create_lead_address_contact(self):
if self.doc.lead_name:
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, contact_no, mobile_no, fax, email_id from `tabLead` where name = '%s'" %(self.doc.lead_name), as_dict = 1)
d = Document('Address')
d.address_line1 = details[0]['address_line1']
d.address_line2 = details[0]['address_line2']
d.city = details[0]['city']
d.country = details[0]['country']
d.pincode = details[0]['pincode']
d.state = details[0]['state']
d.fax = details[0]['fax']
d.email_id = details[0]['email_id']
d.phone = details[0]['contact_no']
d.customer = self.doc.name
d.customer_name = self.doc.customer_name
d.is_primary_address = 1
d.address_type = 'Office'
try:
d.save(1)
except NameError, e:
pass
c = Document('Contact')
c.first_name = details[0]['lead_name']
c.email_id = details[0]['email_id']
c.phone = details[0]['contact_no']
c.phone = details[0]['contact_no']
c.customer = self.doc.name
c.customer_name = self.doc.customer_name
c.is_primary_contact = 1
try:
c.save(1)
except NameError, e:
pass
# ----------
# on update
# ----------
def on_update(self):
# create customer addr
#self.create_customer_address()
# create customer contact
#self.create_customer_contact()
# update lead status
self.update_lead_status()
# create account head
self.create_account_head()
# update credit days and limit in account
self.update_credit_days_limit()
#create address and contact from lead
self.create_lead_address_contact()
# ******************************************************* on trash *********************************************************
def on_trash(self):
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)

File diff suppressed because it is too large Load Diff

View File

View File

@@ -0,0 +1,38 @@
$import(SMS Control)
cur_frm.cscript.refresh=function(doc,cdt,cdn){if(!doc.docstatus){hide_field(['Update Follow up']);hide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);}
else{unhide_field(['Update Follow up']);unhide_field(['email_id1','cc_to','subject','message','Attachment Html','Create New File','enquiry_attachment_detail','Send Email']);}
cur_frm.clear_custom_buttons();if(doc.docstatus==1){cur_frm.add_custom_button('Create Quotation',cur_frm.cscript['Create Quotation']);cur_frm.add_custom_button('Enquiry Lost',cur_frm.cscript['Declare Enquiry Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}}
cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.enquiry_from)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.date)doc.transaction_date=date.obj_to_str(new Date());if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.enquiry_from){if(doc.enquiry_from=='Customer'){hide_field(['lead','lead_name']);}
else if(doc.enquiry_from=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}}
if(doc.enquiry_from=='Lead'&&doc.lead){cur_frm.cscript.lead(doc,cdt,cdn);}
cur_frm.cscript.set_fetch();}
cur_frm.cscript.set_fetch=function(){cur_frm.add_fetch('item_code','item_name','item_name');cur_frm.add_fetch('item_code','stock_uom','uom');cur_frm.add_fetch('item_code','description','description');cur_frm.add_fetch('item_code','item_group','item_group');cur_frm.add_fetch('item_code','brand','brand');}
cur_frm.cscript.enquiry_from=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);}
cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.enquiry_from=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}
else if(doc.enquiry_from=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}}
cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);}
cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';}
cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);}
cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query=function(doc,cdt,cdn){if(doc.enquiry_type=='Maintenance')
return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else
return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';}
cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);}}
cur_frm.cscript['Create New File']=function(doc){var fl=LocalDB.create('File');fl=locals['File'][fl];loaddoc('File',fl.name);}
cur_frm.cscript['Update Follow up']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'update_follow_up','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});}
cur_frm.cscript['Create Quotation']=function(){n=createLocal("Quotation");$c('dt_map',args={'docs':compress_doclist([locals["Quotation"][n]]),'from_doctype':'Enquiry','to_doctype':'Quotation','from_docname':cur_frm.docname,'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"},function(r,rt){loaddoc("Quotation",n);});}
cur_frm.cscript['Declare Enquiry Lost']=function(){var e_lost_dialog;set_e_lost_dialog=function(){e_lost_dialog=new Dialog(400,150,'Add Enquiry Lost Reason');e_lost_dialog.make_body([['HTML','Message','<div class="comment">Please add enquiry lost reason</div>'],['Text','Enquiry Lost Reason'],['HTML','Response','<div class = "comment" id="update_enquiry_dialog_response"></div>'],['HTML','Add Reason','<div></div>']]);var add_reason_btn1=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){e_lost_dialog.add();}
var add_reason_btn2=$a($i(e_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){e_lost_dialog.hide();}
e_lost_dialog.onshow=function(){e_lost_dialog.widgets['Enquiry Lost Reason'].value='';$i('update_enquiry_dialog_response').innerHTML='';}
e_lost_dialog.add=function(){$i('update_enquiry_dialog_response').innerHTML='Processing...';var arg=strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_enquiry_dialog_response').innerHTML='Done';e_lost_dialog.hide();}}
if(arg){$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);}
else{msgprint("Please add enquiry lost reason");}}}
if(!e_lost_dialog){set_e_lost_dialog();}
e_lost_dialog.show();}
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';}
cur_frm.cscript.validate=function(doc,cdt,cdn){}

View File

@@ -0,0 +1,334 @@
$import(SMS Control)
cur_frm.cscript.refresh = function(doc, cdt, cdn){
//cur_frm.cscript.get_tips(doc, cdt, cdn);
if(!doc.docstatus){
hide_field(['Update Follow up']);
hide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
}
else{
unhide_field(['Update Follow up']);
unhide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
}
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1) {
cur_frm.add_custom_button('Create Quotation', cur_frm.cscript['Create Quotation']);
cur_frm.add_custom_button('Enquiry Lost', cur_frm.cscript['Declare Enquiry Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
//cur_frm.cscript.clear_values(doc,cdt,cdn);
}
// ONLOAD
// ===============================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.enquiry_from) hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.date) doc.transaction_date = date.obj_to_str(new Date());
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
if(doc.enquiry_from) {
if(doc.enquiry_from == 'Customer') {
hide_field(['lead', 'lead_name']);
}
else if (doc.enquiry_from == 'Lead') {
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name', 'contact_display', 'customer_group']);
}
}
if(doc.enquiry_from == 'Lead' && doc.lead) {
cur_frm.cscript.lead(doc,cdt,cdn);
}
// setup fetch
cur_frm.cscript.set_fetch();
}
// fetch
// ===============================================================
cur_frm.cscript.set_fetch = function() {
// item
cur_frm.add_fetch('item_code', 'item_name', 'item_name');
cur_frm.add_fetch('item_code', 'stock_uom', 'uom');
cur_frm.add_fetch('item_code', 'description', 'description');
cur_frm.add_fetch('item_code', 'item_group', 'item_group');
cur_frm.add_fetch('item_code', 'brand', 'brand');
// customer
}
// hide - unhide fields on basis of enquiry_from lead or customer
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
}
// hide - unhide fields based on lead or customer
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
if(doc.enquiry_from == 'Lead'){
unhide_field(['lead']);
hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
else if(doc.enquiry_from == 'Customer'){
unhide_field(['customer']);
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
}
// customer
cur_frm.cscript.customer = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_default_customer_address', JSON.stringify({customer: doc.customer}),'', doc, dt, dn, 1);
if(doc.customer) unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
// lead
cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
return 'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';
}
cur_frm.cscript.lead = function(doc, cdt, cdn) {
if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
}
//item getquery
//=======================================
cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
if (doc.enquiry_type == 'Maintenance')
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
else
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
}
//Fetch Item Details
//====================================================================================================================
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);
}
}
/*
//Fetch Customer Details
//======================================================================================================================
cur_frm.cscript.customer = function(doc, cdt, cdn){
if (doc.customer) {
get_server_fields('get_cust_address',doc.customer,'',doc,cdt,cdn,1);
}
}
*/
/*
//=======================================================================================================================
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.customer = "'+ doc.customer+'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
}
*/
/*
//=======================================================================================================================
cur_frm.cscript.contact_person = function(doc, cdt, cdn){
if (doc.contact_person) {
arg = {};
arg.contact_person = doc.contact_person;
arg.customer = doc.customer;
get_server_fields('get_contact_details',docstring(arg),'',doc,cdt,cdn,1);
}
}
*/
/*
// hide - unhide fields based on lead or customer..
//=======================================================================================================================
cur_frm.cscript.clear_values = function(doc,cdt,cdn) {
if(doc.enquiry_from == 'Lead') {
doc.customer = doc.customer_name = doc.contact_person = doc.customer_group = "";
}
else if(doc.enquiry_from == 'Customer') {
doc.lead = doc.lead_name = "";
}
refresh_many(['lead','lead_name','customer','customer_name','contact_person','customer_group']);
}
*/
/*
//================ hide - unhide fields on basis of enquiry from either lead or customer ===============================
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
cur_frm.cscript.clear_values(doc,cdt,cdn);
doc.address = doc.territory = doc.contact_no = doc.email_id = "";
refresh_many(['territory','address','contact_no','email_id']);
}
*/
/*
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
}
*/
//=======================================================================================================================
cur_frm.cscript['Create New File'] = function(doc){
var fl = LocalDB.create('File');
fl = locals['File'][fl];
loaddoc('File', fl.name);
}
//update follow up
//=================================================================================
cur_frm.cscript['Update Follow up'] = function(doc,cdt,cdn){
$c_obj(make_doclist(doc.doctype, doc.name),'update_follow_up','',function(r, rt){
refresh_field('follow_up');
doc.__unsaved = 0;
cur_frm.refresh_header();
});
}
// Create New Quotation
// =======================================================================================================================
cur_frm.cscript['Create Quotation'] = function(){
n = createLocal("Quotation");
$c('dt_map', args={
'docs':compress_doclist([locals["Quotation"][n]]),
'from_doctype':'Enquiry',
'to_doctype':'Quotation',
'from_docname':cur_frm.docname,
'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"
}
, function(r,rt) {
loaddoc("Quotation", n);
}
);
}
// declare enquiry lost
//-------------------------
cur_frm.cscript['Declare Enquiry Lost'] = function(){
var e_lost_dialog;
set_e_lost_dialog = function(){
e_lost_dialog = new Dialog(400,150,'Add Enquiry Lost Reason');
e_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add enquiry lost reason</div>'],
['Text', 'Enquiry Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_enquiry_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ e_lost_dialog.add(); }
var add_reason_btn2 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ e_lost_dialog.hide();}
e_lost_dialog.onshow = function() {
e_lost_dialog.widgets['Enquiry Lost Reason'].value = '';
$i('update_enquiry_dialog_response').innerHTML = '';
}
e_lost_dialog.add = function() {
// sending...
$i('update_enquiry_dialog_response').innerHTML = 'Processing...';
var arg = strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_enquiry_dialog_response').innerHTML = 'Done';
e_lost_dialog.hide();
}
}
if(arg) {
$c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);
}
else{
msgprint("Please add enquiry lost reason");
}
}
}
if(!e_lost_dialog){
set_e_lost_dialog();
}
e_lost_dialog.show();
}
//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';}
/*
//===================== Enquiry From validation - either customer or lead is mandatory =====================================
cur_frm.cscript.enq_frm_validate = function(doc,cdt,cdn){
if(doc.enquiry_from == 'Lead'){
if(!doc.lead){
alert("Lead is mandatory.");
validated = false;
}
}
else if(doc.enquiry_from == 'Customer'){
if(!doc.customer){
alert("Customer is mandatory.");
validated = false;
}
else if(!doc.contact_person){
alert("Contact Person is mandatory.");
validated = false;
}
else if(!doc.customer_group){
alert("Customer Group is mandatory.");
validated = false;
}
}
}
*/
//===================validation function ==============================================================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
//cur_frm.cscript.enq_frm_validate(doc,cdt,cdn);
}

View File

@@ -0,0 +1,335 @@
# 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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
self.fname = 'enq_details'
self.tname = 'Enquiry Detail'
# Autoname
# ====================================================================================================================
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.####')
#--------Get customer address-------
# ====================================================================================================================
def get_cust_address(self,name):
details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
if details:
ret = {
'customer_name': details and details[0]['customer_name'] or '',
'address' : details and details[0]['address'] or '',
'territory' : details and details[0]['territory'] or '',
'customer_group' : details and details[0]['customer_group'] or ''
}
# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), 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 cstr(ret)
else:
msgprint("Customer : %s does not exist in system." % (name))
raise Exception
# ====================================================================================================================
def get_contact_details(self, arg):
arg = eval(arg)
contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
ret = {
'contact_no' : contact and contact[0]['contact_no'] or '',
'email_id' : contact and contact[0]['email_id'] or ''
}
return str(ret)
# ====================================================================================================================
def on_update(self):
# Add to calendar
#if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
if self.doc.contact_by:
self.add_calendar_event()
set(self.doc, 'contact_date_ref',self.doc.contact_date)
set(self.doc, 'status', 'Draft')
# Add to Calendar
# ====================================================================================================================
def add_calendar_event(self):
desc=''
user_lst =[]
if self.doc.customer:
if self.doc.contact_person:
desc = 'Contact '+cstr(self.doc.contact_person)
else:
desc = 'Contact customer '+cstr(self.doc.customer)
elif self.doc.lead:
if self.doc.lead_name:
desc = 'Contact '+cstr(self.doc.lead_name)
else:
desc = 'Contact lead '+cstr(self.doc.lead)
desc = desc+ '. By : ' + cstr(self.doc.contact_by)
if self.doc.to_discuss:
desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
ev = Document('Event')
ev.description = desc
ev.event_date = self.doc.contact_date
ev.event_hour = '10:00'
ev.event_type = 'Private'
ev.ref_type = 'Enquiry'
ev.ref_name = self.doc.name
ev.save(1)
user_lst.append(self.doc.owner)
chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
if chk:
user_lst.append(chk[0][0])
for d in user_lst:
ch = addchild(ev, 'event_individuals', 'Event User', 0)
ch.person = d
ch.save(1)
#user_list = ['Sales Manager', 'Sales User']
#for d in user_list:
# ch = addchild(ev, 'event_individuals', 'Event User', 0)
# ch.person = d
# ch.save()
#--------------Validation For Last Contact Date-----------------
# ====================================================================================================================
def set_last_contact_date(self):
#if not self.doc.contact_date_ref:
#self.doc.contact_date_ref=self.doc.contact_date
#self.doc.last_contact_date=self.doc.contact_date_ref
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
self.doc.last_contact_date=self.doc.contact_date_ref
else:
msgprint("Contact Date Cannot be before Last Contact Date")
raise Exception
#set(self.doc, 'contact_date_ref',self.doc.contact_date)
# check if item present in item table
# ====================================================================================================================
def validate_item_details(self):
if not getlist(self.doclist, 'enquiry_details'):
msgprint("Please select items for which enquiry needs to be made")
raise Exception
#check if enquiry date in the range of fiscal year selected
#=====================================================
def validate_fiscal_year(self):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
ysd=fy and fy[0][0] or ""
yed=add_days(str(ysd),365)
if str(self.doc.transaction_date) < str(ysd) or str(self.doc.transaction_date) > str(yed):
msgprint("Enquiry Date is not within the Fiscal Year selected")
raise Exception
def validate(self):
self.validate_fiscal_year()
self.set_last_contact_date()
self.validate_item_details()
# On Submit Functions
# ====================================================================================================================
def on_submit(self):
set(self.doc, 'status', 'Submitted')
# ====================================================================================================================
def on_cancel(self):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus can not be cancelled.")
raise Exception
else:
set(self.doc, 'status', 'Cancelled')
get_obj('Feed Control').make_feed(self.doc, 'cancelled')
# declare as enquiry lost
#---------------------------
def declare_enquiry_lost(self,arg):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus 'Enquiry Lost' can not be declared against it.")
raise Exception
else:
set(self.doc, 'status', 'Enquiry Lost')
set(self.doc, 'order_lost_reason', arg)
return cstr('true')
# ====================================================================================================================
def update_follow_up(self):
sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name);
for d in getlist(self.doclist, 'follow_up'):
d.save()
self.doc.save()
# On Send Email
# ====================================================================================================================
#def send_emails(self,email,sender,subject,message):
# if email:
# sendmail(email,sender,subject=subject or 'Enquiry',parts=[['text/plain',message or self.get_enq_summary()]])
# Prepare HTML Table and Enter Enquiry Details in it, which will be added in enq summary
# ====================================================================================================================
def quote_table(self):
if getlist(self.doclist,'enq_details'):
header_lbl = ['Item Code','Item Name','Description','Reqd Qty','UOM']
item_tbl = '''<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>'''
for i in header_lbl:
item_header = '''<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>''' % i
item_tbl += item_header
item_tbl += '''</tr>'''
for d in getlist(self.doclist,'enq_details'):
item_det = '''
<tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
''' % (d.item_code,d.item_name,d.description,d.reqd_qty,d.uom)
item_tbl += item_det
item_tbl += '''</table>'''
return item_tbl
# Prepare HTML Page containing summary of Enquiry, which will be sent as message in E-mail
# ====================================================================================================================
def get_enq_summary(self):
t = """
<html><head></head>
<body>
<div style="border:1px solid #AAA; padding:20px; width:100%%">
<div style="text-align:center;font-size:14px"><b>Request For Quotation</b><br></div>
<div style="text-align:center;font-size:12px"> %(from_company)s</div>
<div style="text-align:center; font-size:10px"> %(company_address)s</div>
<div style="border-bottom:1px solid #AAA; padding:10px"></div>
<div style="padding-top:10px"><b>Quotation Details</b></div>
<div><table style="width:100%%">
<tr><td style="width:40%%">Enquiry No:</td> <td style="width:60%%"> %(name)s</td></tr>
<tr><td style="width:40%%">Opening Date:</td> <td style="width:60%%"> %(transaction_date)s</td></tr>
<tr><td style="width:40%%">Expected By Date:</td> <td style="width:60%%"> %(expected_date)s</td></tr>
</table>
</div>
<div style="padding-top:10px"><b>Terms and Conditions</b></div>
<div> %(terms_and_conditions)s</div>
<div style="padding-top:10px"><b>Contact Details</b></div>
<div><table style="width:100%%">
<tr><td style="width=40%%">Contact Person:</td><td style="width:60%%"> %(contact_person)s</td></tr>
<tr><td style="width=40%%">Contact No:</td><td style="width:60%%"> %(contact_no)s</td></tr>
<tr><td style="width=40%%">Email:</td><td style="width:60%%"> %(email)s</td></tr>
</table></div>
""" % (self.doc.fields)
t += """<br><div><b>Quotation Items</b><br></div><div style="width:100%%">%s</div>
<br>
To login into the system, use link : <div><a href='http://67.205.111.118/v160/login.html' target='_blank'>http://67.205.111.118/v160/login.html</a></div><br><br>
</div>
</body>
</html>
""" % (self.quote_table())
return t
#-----------------Email--------------------------------------------
# ====================================================================================================================
def send_emails(self, email=[], subject='', message=''):
if email:
sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
if sender_email and sender_email[0][0]:
attach_list=[]
for at in getlist(self.doclist,'enquiry_attachment_detail'):
if at.select_file:
attach_list.append(at.select_file)
cc_list=[]
if self.doc.cc_to:
for cl in (self.doc.cc_to.split(',')):
if not validate_email_add(cl.strip(' ')):
msgprint('error:%s is not a valid email id' % cl.strip(' '))
raise Exception
cc_list.append(cl.strip(' '))
sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)
sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
#sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
msgprint("Mail has been sent")
self.add_in_follow_up(message,'Email')
else:
msgprint("Please enter your mail id in Profile")
raise Exception
#-------------------------Checking Sent Mails Details----------------------------------------------
# ====================================================================================================================
def sent_mail(self):
if not self.doc.subject or not self.doc.message:
msgprint("Please enter subject & message in their respective fields.")
elif not self.doc.email_id1:
msgprint("Recipient not specified. Please add email id in 'Send To'.")
raise Exception
else :
if not validate_email_add(self.doc.email_id1.strip(' ')):
msgprint('error:%s is not a valid email id' % self.doc.email_id1)
else:
self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
#---------------------- Add details in follow up table----------------
# ====================================================================================================================
def add_in_follow_up(self,message,type):
import datetime
child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
child.notes = message
child.follow_up_type = type
child.save()
#-------------------SMS----------------------------------------------
# ====================================================================================================================
def send_sms(self):
if not self.doc.sms_message:
msgprint("Please enter message in SMS Section ")
raise Exception
elif not getlist(self.doclist, 'enquiry_sms_detail'):
msgprint("Please mention mobile no. to which sms needs to be sent")
raise Exception
else:
receiver_list = []
for d in getlist(self.doclist,'enquiry_sms_detail'):
if d.other_mobile_no:
receiver_list.append(d.other_mobile_no)
if receiver_list:
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
self.add_in_follow_up(self.doc.sms_message,'SMS')

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-11 11:38:27', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'dhanalekshmi@webnotestech.com', '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': 0, 'max_attachments': None, 'version': 3, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': None, 'name': 'Enquiry Attachment Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, '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': 'ashwini@webnotestech.com', 'name': 'PERM00530', 'parent': 'Enquiry Attachment Detail', 'read': None, 'create': None, 'creation': '2009-12-11 11:38:27', 'modified': '2010-08-08 11:11:22', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 1, 'parenttype': 'DocType', 'role': '', 'owner': 'dhanalekshmi@webnotestech.com', 'docstatus': 0, 'permlevel': None, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-12-11 11:38:27', 'doctype': 'DocField', 'oldfieldname': 'select_file', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Select File For Attachment', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry Attachment Detail', 'search_index': None, 'allow_on_submit': 1, 'icon': None, 'name': 'FL03493', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 11:11:22', 'parenttype': 'DocType', 'fieldname': 'select_file', 'fieldtype': 'Link', 'options': 'File', 'report_hide': None, 'parentfield': 'fields'}]

View File

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-12-11 11:45:55', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'dhanalekshmi@webnotestech.com', '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': 0, 'max_attachments': None, 'version': 5, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': None, 'name': 'Enquiry SMS Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-12-11 11:45:55', 'doctype': 'DocField', 'oldfieldname': 'other_mobile_no', 'owner': 'dhanalekshmi@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Mobile No', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Enquiry SMS Detail', 'search_index': None, 'allow_on_submit': 1, 'icon': None, 'name': 'FL03494', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-08-08 11:13:11', 'parenttype': 'DocType', 'fieldname': 'other_mobile_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]

View File

View File

@@ -0,0 +1,197 @@
[
{
'_last_update': '1303109476',
'_user_tags': None,
'allow_attach': None,
'allow_copy': None,
'allow_email': None,
'allow_print': None,
'allow_rename': None,
'allow_trash': None,
'autoname': None,
'change_log': None,
'client_script': None,
'client_script_core': None,
'client_string': None,
'colour': 'White:FFF',
'creation': '2010-08-08 17:09:02',
'description': None,
'docstatus': 0,
'doctype': 'DocType',
'document_type': None,
'dt_template': None,
'hide_heading': None,
'hide_toolbar': None,
'idx': None,
'in_create': None,
'in_dialog': None,
'is_transaction_doc': None,
'issingle': None,
'istable': 1,
'max_attachments': None,
'menu_index': None,
'modified': '2011-05-09 15:40:46',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'Follow up',
'name_case': None,
'owner': 'Administrator',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'print_outline': None,
'read_only': None,
'read_only_onload': None,
'search_fields': None,
'section_style': 'Tray',
'server_code': None,
'server_code_compiled': None,
'server_code_core': None,
'server_code_error': ' ',
'show_in_menu': 0,
'smallicon': None,
'use_template': None,
'version': 9
},
{
'allow_on_submit': 1,
'colour': None,
'creation': '2010-08-08 17:09:02',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'date',
'fieldtype': 'Date',
'hidden': None,
'icon': None,
'idx': 1,
'in_filter': 1,
'label': 'Date',
'modified': '2011-05-09 15:40:46',
'modified_by': 'Administrator',
'name': 'FL01361',
'no_copy': None,
'oldfieldname': 'date',
'oldfieldtype': 'Date',
'options': None,
'owner': 'Administrator',
'parent': 'Follow up',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': 1,
'colour': None,
'creation': '2010-08-08 17:09:02',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'notes',
'fieldtype': 'Small Text',
'hidden': None,
'icon': None,
'idx': 2,
'in_filter': None,
'label': 'Notes',
'modified': '2011-05-09 15:40:46',
'modified_by': 'Administrator',
'name': 'FL01362',
'no_copy': None,
'oldfieldname': 'notes',
'oldfieldtype': 'Small Text',
'options': None,
'owner': 'Administrator',
'parent': 'Follow up',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': '300px'
},
{
'allow_on_submit': 1,
'colour': 'White:FFF',
'creation': '2010-08-08 17:09:02',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'follow_up_type',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 3,
'in_filter': 1,
'label': 'Follow up type',
'modified': '2011-05-09 15:40:46',
'modified_by': 'Administrator',
'name': 'FL01363',
'no_copy': None,
'oldfieldname': 'follow_up_type',
'oldfieldtype': 'Select',
'options': '\nPhone\nEmail\nSMS\nVisit\nOther',
'owner': 'Administrator',
'parent': 'Follow up',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': 1,
'colour': None,
'creation': '2010-12-14 10:32:58',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'follow_up_by',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 4,
'in_filter': 1,
'label': 'Follow up by',
'modified': '2011-05-09 15:40:46',
'modified_by': 'Administrator',
'name': 'FL04147',
'no_copy': None,
'oldfieldname': 'follow_up_by',
'oldfieldtype': 'Link',
'options': 'Profile',
'owner': 'harshada@webnotestech.com',
'parent': 'Follow up',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
}
]

View File

View File

@@ -0,0 +1,10 @@
$import(Tips Common)
//--------- ONLOAD -------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.get_tips(doc, cdt, cdn);
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.get_tips(doc, cdt, cdn);
}

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-04 12:28:02', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', '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': 5, '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:industry', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'ashwini@webnotestech.com', 'document_type': 'Master', 'name': 'Industry Type', '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': 'ashwini@webnotestech.com', 'name': 'PERM00998', 'parent': 'Industry Type', 'read': 1, 'create': 1, 'creation': '2010-05-04 12:28:02', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Sales Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM00999', 'parent': 'Industry Type', 'read': 1, 'create': None, 'creation': '2010-05-04 12:31:05', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': None, 'idx': 2, 'parenttype': 'DocType', 'role': 'Sales User', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'ashwini@webnotestech.com', 'name': 'PERM01000', 'parent': 'Industry Type', 'read': 1, 'create': 1, 'creation': '2010-05-04 12:31:05', 'modified': '2010-09-20 09:41:52', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 3, 'parenttype': 'DocType', 'role': 'Sales Master Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2010-05-04 12:28:02', 'doctype': 'DocField', 'oldfieldname': 'industry', 'owner': 'harshada@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'ashwini@webnotestech.com', 'label': 'Industry', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Industry Type', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL04976', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-09-20 09:41:52', 'parenttype': 'DocType', 'fieldname': 'industry', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]

View File

@@ -0,0 +1,69 @@
cur_frm.cscript.tname = "Installed Item Details";
cur_frm.cscript.fname = "installed_item_details";
cur_frm.cscript.onload = function(doc, dt, dn) {
if(!doc.status) set_multiple(dt,dn,{status:'Draft'});
if(doc.__islocal){
set_multiple(dt,dn,{inst_date:get_today()});
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
if (doc.customer) {
unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
}
cur_frm.fields_dict['delivery_note_no'].get_query = function(doc) {
doc = locals[this.doctype][this.docname];
var cond = '';
if(doc.customer) {
cond = '`tabDelivery Note`.customer = "'+doc.customer+'" AND';
}
return repl('SELECT DISTINCT `tabDelivery Note`.name, `tabDelivery Note`.customer_name FROM `tabDelivery Note`, `tabDelivery Note Detail` WHERE `tabDelivery Note`.company = "%(company)s" AND `tabDelivery Note`.docstatus = 1 AND ifnull(`tabDelivery Note`.per_installed,0) < 100 AND %(cond)s `tabDelivery Note`.name LIKE "%s" ORDER BY `tabDelivery Note`.name DESC LIMIT 50', {company:doc.company, cond:cond});
}
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';
}
cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
var callback = function(r,rt) {
unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
cur_frm.refresh();
}
get_server_fields('pull_delivery_note_details','','',doc, dt, dn,1,callback);
}
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
cur_frm.refresh();
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}

View File

@@ -0,0 +1,209 @@
# 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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.tname = 'Installed Item Details'
self.fname = 'installed_item_details'
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
#fetch customer details
#=================================
#def get_customer_details(self):
# det = sql("select t1.customer_name, t1.address,t1.territory,t2.contact_name from `tabCustomer` t1, `tabContact` t2 where t1.name = '%s' and t1.name=t2.customer and t2.is_primary_contact = 'Yes'"%self.doc.customer, as_dict=1)
# ret = {
# 'customer_name': det and det[0]['customer_name'] or '',
# 'address' : det and det[0]['address'] or '',
# 'territory': det and det[0]['territory'] or '',
# 'contact_person' : det and det[0]['contact_name'] or ''
# }
# return str(ret)
#fetch delivery note details
#====================================
def pull_delivery_note_details(self):
self.validate_prev_docname()
self.doclist = get_obj('DocType Mapper', 'Delivery Note-Installation Note').dt_map('Delivery Note', 'Installation Note', self.doc.delivery_note_no, self.doc, self.doclist, "[['Delivery Note', 'Installation Note'],['Delivery Note Detail', 'Installed Item Details']]")
# Validates that Delivery Note is not pulled twice
#============================================
def validate_prev_docname(self):
for d in getlist(self.doclist, 'installed_item_details'):
if self.doc.delivery_note_no == d.prevdoc_docname:
msgprint(cstr(self.doc.delivery_note_no) + " delivery note details have already been pulled. ")
raise Exception, "Validation Error. "
#Fiscal Year Validation
#================================
def validate_fiscal_year(self):
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.inst_date,'Installation Date')
# Validate Mandatory
#===============================
def validate_mandatory(self):
# Amendment Date
if self.doc.amended_from and not self.doc.amendment_date:
msgprint("Please Enter Amendment Date")
raise Exception, "Validation Error. "
# Validate values with reference document
#----------------------------------------
def validate_reference_value(self):
get_obj('DocType Mapper', 'Delivery Note-Installation Note', with_children = 1).validate_reference_value(self, self.doc.name)
#check if serial no added
#-----------------------------
def is_serial_no_added(self,item_code,serial_no):
ar_required = sql("select has_serial_no from tabItem where name = '%s'" % item_code)
ar_required = ar_required and ar_required[0][0] or ''
if ar_required == 'Yes' and not serial_no:
msgprint("Serial No is mandatory for item: "+ item_code)
raise Exception
elif ar_required != 'Yes' and cstr(serial_no).strip():
msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :"+item_code)
raise Exception
#check if serial no exist in system
#-------------------------------------
def is_serial_no_exist(self, item_code, serial_no):
for x in serial_no:
chk = sql("select name from `tabSerial No` where name =%s", x)
if not chk:
msgprint("Serial No "+x+" does not exist in the system")
raise Exception
#check if serial no already installed
#------------------------------------------
def is_serial_no_installed(self,cur_s_no,item_code):
for x in cur_s_no:
status = sql("select status from `tabSerial No` where name = %s", x)
status = status and status[0][0] or ''
if status == 'Installed':
msgprint("Item "+item_code+" with serial no. "+x+" already installed")
raise Exception, "Validation Error."
#get list of serial no from previous_doc
#----------------------------------------------
def get_prevdoc_serial_no(self, prevdoc_detail_docname, prevdoc_docname):
from material_management.doctype.stock_ledger.stock_ledger import get_sr_no_list
res = sql("select serial_no from `tabDelivery Note Detail` where name = '%s' and parent ='%s'" % (prevdoc_detail_docname, prevdoc_docname))
return get_sr_no_list(res[0][0])
#check if all serial nos from current record exist in resp delivery note
#---------------------------------------------------------------------------------
def is_serial_no_match(self, cur_s_no, prevdoc_s_no, prevdoc_docname):
for x in cur_s_no:
if not(x in prevdoc_s_no):
msgprint("Serial No. "+x+" not present in the Delivery Note "+prevdoc_docname, raise_exception = 1)
raise Exception, "Validation Error."
#validate serial number
#----------------------------------------
def validate_serial_no(self):
cur_s_no, prevdoc_s_no, sr_list = [], [], []
from material_management.doctype.stock_ledger.stock_ledger import get_sr_no_list
for d in getlist(self.doclist, 'installed_item_details'):
self.is_serial_no_added(d.item_code, d.serial_no)
if d.serial_no:
sr_list = get_sr_no_list(d.serial_no, d.qty)
self.is_serial_no_exist(d.item_code, sr_list)
prevdoc_s_no = self.get_prevdoc_serial_no(d.prevdoc_detail_docname, d.prevdoc_docname)
if prevdoc_s_no:
self.is_serial_no_match(sr_list, prevdoc_s_no, d.prevdoc_docname)
self.is_serial_no_installed(sr_list, d.item_code)
return sr_list
#validate installation date
#-------------------------------
def validate_installation_date(self):
for d in getlist(self.doclist, 'installed_item_details'):
if d.prevdoc_docname:
d_date = sql("select posting_date from `tabDelivery Note` where name=%s", d.prevdoc_docname)
d_date = d_date and d_date[0][0] or ''
if d_date > getdate(self.doc.inst_date):
msgprint("Installation Date can not be before Delivery Date "+cstr(d_date)+" for item "+d.item_code)
raise Exception
def validate(self):
self.validate_fiscal_year()
self.validate_installation_date()
self.check_item_table()
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.get_prevdoc_date(self)
self.validate_mandatory()
self.validate_reference_value()
def check_item_table(self):
if not(getlist(self.doclist, 'installed_item_details')):
msgprint("Please fetch items from Delivery Note selected")
raise Exception
def on_update(self):
set(self.doc, 'status', 'Draft')
def on_submit(self):
valid_lst = []
valid_lst = self.validate_serial_no()
get_obj("Sales Common").update_prevdoc_detail(1,self)
for x in valid_lst:
wp = sql("select warranty_period from `tabSerial No` where name = '%s'"% x)
wp = wp and wp[0][0] or 0
if wp:
sql("update `tabSerial No` set maintenance_status = 'Under Warranty' where name = '%s'" % x)
sql("update `tabSerial No` set status = 'Installed' where name = '%s'" % x)
set(self.doc, 'status', 'Submitted')
def on_cancel(self):
cur_s_no = []
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.update_prevdoc_detail(0,self)
for d in getlist(self.doclist, 'installed_item_details'):
if d.serial_no:
#get current list of serial no
cur_serial_no = d.serial_no.replace(' ', '')
cur_s_no = cur_serial_no.split(',')
for x in cur_s_no:
sql("update `tabSerial No` set status = 'Delivered' where name = '%s'" % x)
set(self.doc, 'status', 'Cancelled')

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,18 @@
$import(SMS Control)
cur_frm.cscript.onload=function(doc,cdt,cdn){if(user=='Guest'){hide_field(['status','naming_series','order_lost_reason','customer','rating','fax','website','territory','TerritoryHelp','address_line1','address_line2','city','state','country','pincode','address','lead_owner','market_segment','industry','campaign_name','interested_in','company','fiscal_year','contact_by','contact_date','last_contact_date','contact_date_ref','to_discuss','More Info','follow_up','Communication History','cc_to','subject','message','Attachment Html','Create New File','lead_attachment_detail','Send Email','Email','Create Customer','Create Enquiry','Next Steps','transaction_date','type','source']);doc.source='Website';}
if(!doc.status)set_multiple(dt,dn,{status:'Open'});if(!doc.date){doc.date=date.obj_to_str(new Date());}
if(user=='Guest')doc.naming_series='WebLead';cur_frm.add_fetch('customer','customer_name','company_name');}
cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons()
if(!doc.__islocal&&!in_list(['Converted','Lead Lost'],doc.status)){cur_frm.add_custom_button('Create Customer',cur_frm.cscript['Create Customer']);cur_frm.add_custom_button('Create Enquiry',cur_frm.cscript['Create Enquiry']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}}
cur_frm.cscript.status=function(doc,cdt,cdn){cur_frm.cscript.refresh(doc,cdt,cdn);}
cur_frm.cscript.TerritoryHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Territory');}
loadpage('Sales Browser',call_back);}
cur_frm.cscript['Create New File']=function(doc){new_doc("File");}
cur_frm.cscript.item_code=function(doc,cdt,cdn){var d=locals[cdt][cdn];if(d.item_code){get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}}
cur_frm.cscript['Create Customer']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is already converted to customer");}
else{n=createLocal("Customer");$c('dt_map',args={'docs':compress_doclist([locals["Customer"][n]]),'from_doctype':'Lead','to_doctype':'Customer','from_docname':doc.name,'from_to_list':"[['Lead', 'Customer']]"},function(r,rt){loaddoc("Customer",n);});}});}
cur_frm.cscript['Send Email']=function(doc,cdt,cdn){if(doc.__islocal!=1){$c_obj(make_doclist(doc.doctype,doc.name),'send_mail','',function(r,rt){});}else{msgprint("Please save lead first before sending email")}}
cur_frm.cscript['Create Enquiry']=function(){var doc=cur_frm.doc;$c('runserverobj',args={'method':'check_status','docs':compress_doclist([doc])},function(r,rt){if(r.message=='Converted'){msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");}
else{n=createLocal("Enquiry");$c('dt_map',args={'docs':compress_doclist([locals["Enquiry"][n]]),'from_doctype':'Lead','to_doctype':'Enquiry','from_docname':doc.name,'from_to_list':"[['Lead', 'Enquiry']]"},function(r,rt){loaddoc("Enquiry",n);});}});}
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';}

147
crm/doctype/lead/lead.js Normal file
View File

@@ -0,0 +1,147 @@
// Module CRM
$import(SMS Control)
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(user =='Guest'){
hide_field(['status', 'naming_series', 'order_lost_reason', 'customer', 'rating', 'fax', 'website', 'territory', 'TerritoryHelp', 'address_line1', 'address_line2', 'city', 'state', 'country', 'pincode', 'address', 'lead_owner', 'market_segment', 'industry', 'campaign_name', 'interested_in', 'company', 'fiscal_year', 'contact_by', 'contact_date', 'last_contact_date', 'contact_date_ref', 'to_discuss', 'More Info', 'follow_up', 'Communication History', 'cc_to', 'subject', 'message', 'Attachment Html', 'Create New File', 'lead_attachment_detail', 'Send Email', 'Email', 'Create Customer', 'Create Enquiry', 'Next Steps', 'transaction_date', 'type', 'source']);
doc.source = 'Website';
}
if(!doc.status) set_multiple(dt,dn,{status:'Open'});
if (!doc.date){
doc.date = date.obj_to_str(new Date());
}
// set naming series
if(user=='Guest') doc.naming_series = 'WebLead';
cur_frm.add_fetch('customer', 'customer_name', 'company_name');
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// custom buttons
//---------------
cur_frm.clear_custom_buttons()
if(!doc.__islocal && !in_list(['Converted', 'Lead Lost'], doc.status)) {
cur_frm.add_custom_button('Create Customer', cur_frm.cscript['Create Customer']);
cur_frm.add_custom_button('Create Enquiry', cur_frm.cscript['Create Enquiry']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
}
// Client Side Triggers
// ===========================================================
// ************ Status ******************
cur_frm.cscript.status = function(doc, cdt, cdn){
cur_frm.cscript.refresh(doc, cdt, cdn);
}
/*
// *********** Country ******************
// This will show states belonging to country
cur_frm.cscript.country = function(doc, cdt, cdn) {
var mydoc=doc;
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message) {
var doc = locals[mydoc.doctype][mydoc.name];
doc.state = '';
get_field(doc.doctype, 'state' , doc.name).options = r.message;
refresh_field('state');
}
}
);
}
*/
cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
loadpage('Sales Browser',call_back);
}
// Create New File
// ===============================================================
cur_frm.cscript['Create New File'] = function(doc){
new_doc("File");
}
//Trigger in Item Table
//===================================
cur_frm.cscript.item_code=function(doc,cdt,cdn){
var d = locals[cdt][cdn];
if (d.item_code) { get_server_fields('get_item_detail',d.item_code,'lead_item_detail',doc,cdt,cdn,1);}
}
// Create New Customer
// ===============================================================
cur_frm.cscript['Create Customer'] = function(){
var doc = cur_frm.doc;
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is already converted to customer");
}
else{
n = createLocal("Customer");
$c('dt_map', args={
'docs':compress_doclist([locals["Customer"][n]]),
'from_doctype':'Lead',
'to_doctype':'Customer',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Customer']]"
},
function(r,rt) {
loaddoc("Customer", n);
}
);
}
}
);
}
// send email
// ===============================================================
cur_frm.cscript['Send Email'] = function(doc,cdt,cdn){
if(doc.__islocal != 1){
$c_obj(make_doclist(doc.doctype, doc.name),'send_mail','',function(r,rt){});
}else{
msgprint("Please save lead first before sending email")
}
}
// Create New Enquiry
// ===============================================================
cur_frm.cscript['Create Enquiry'] = function(){
var doc = cur_frm.doc;
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist([doc])},
function(r,rt){
if(r.message == 'Converted'){
msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer");
}
else{
n = createLocal("Enquiry");
$c('dt_map', args={
'docs':compress_doclist([locals["Enquiry"][n]]),
'from_doctype':'Lead',
'to_doctype':'Enquiry',
'from_docname':doc.name,
'from_to_list':"[['Lead', 'Enquiry']]"
}
, function(r,rt) {
loaddoc("Enquiry", n);
}
);
}
}
);
}
//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';
}

212
crm/doctype/lead/lead.py Normal file
View File

@@ -0,0 +1,212 @@
# 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
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
#check status of lead
#------------------------
def check_status(self):
chk = sql("select status from `tabLead` where name=%s", self.doc.name)
chk = chk and chk[0][0] or ''
return cstr(chk)
# Gets states belonging cto country selected
# =====================================================================
#def check_state(self):
# return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
# Get item detail (will be removed later)
#=======================================
def get_item_detail(self,item_code):
it=sql("select item_name,brand,item_group,description,stock_uom from `tabItem` where name='%s'"%item_code)
if it:
ret = {
'item_name' : it and it[0][0] or '',
'brand' : it and it[0][1] or '',
'item_group' : it and it[0][2] or '',
'description': it and it[0][3] or '',
'uom' : it and it[0][4] or ''
}
return cstr(ret)
def validate(self):
import string
# Get Address
# ======================================================================
#if (self.doc.address_line1) or (self.doc.address_line2) or (self.doc.city) or (self.doc.state) or (self.doc.country) or (self.doc.pincode):
# address =["address_line1", "address_line2", "city", "state", "country", "pincode"]
# comp_address=''
# for d in address:
# if self.doc.fields[d]:
# comp_address += self.doc.fields[d] + "\n"
# if self.doc.website:
# comp_address += "Website : "+ self.doc.website
# self.doc.address = comp_address
if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason:
msgprint("Please Enter Order Lost Reason")
raise Exception
if self.doc.source == 'Campaign' and not self.doc.campaign_name and session['user'] != 'Guest':
msgprint("Please specify campaign name")
raise Exception
if self.doc.email_id:
if not validate_email_add(self.doc.email_id):
msgprint('Please enter valid email id.')
raise Exception
if not self.doc.naming_series:
if session['user'] == 'Guest':
so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
#so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
if so:
sr = so[0][0].split("\n")
set(self.doc, 'naming_series', sr[0])
else:
msgprint("Please specify naming series")
raise Exception
def on_update(self):
# Add to calendar
# ========================================================================
if self.doc.contact_by:
self.add_calendar_event()
if session['user'] == 'Guest':
if self.doc.email_id:
self.send_email_notification()
if not self.doc.naming_series:
if session['user'] == 'Guest':
#so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
if so:
sr = so[0][0].split("\n")
set(self.doc, 'naming_series', sr[0])
else:
msgprint("Please specify naming series")
raise Exception
def send_email_notification(self):
if not validate_email_add(self.doc.email_id.strip(' ')):
msgprint('error:%s is not a valid email id' % self.doc.email_id.strip(' '))
raise Exception
else:
subject = 'Thank you for interest in erpnext'
sendmail([self.doc.email_id.strip(' ')], sender = sender_email[0][0], subject = subject , parts = [['text/html', self.get_notification_msg()]])
#sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
msgprint("Mail Sent")
def get_notification_msg(self):
t = """
<html>
<body>
Dear %s,<br><br>
Thank you for contacting us.<br><br>
You have left following message for us,<br>
%s
<br><br>
You will receive reply on this shortly.<br><br>
Cheers!
</body>
</html>
""" % (self.doc.lead_name, self.doc.remark)
return t
# Add to Calendar
# ===========================================================================
def add_calendar_event(self):
# delete any earlier event by this lead
sql("delete from tabEvent where ref_type='Lead' and ref_name=%s", self.doc.name)
in_calendar_of = self.doc.lead_owner
# get profile (id) if exists for contact_by
email_id = webnotes.conn.get_value('Sales Person', self.doc.contact_by, 'email_id')
if webnotes.conn.exists('Profile', email_id):
in_calendar_of = email_id
ev = Document('Event')
ev.owner = in_calendar_of
ev.description = 'Contact ' + cstr(self.doc.lead_name) + '.By : ' + cstr(self.doc.contact_by) + '.To Discuss : ' + cstr(self.doc.to_discuss)
ev.event_date = self.doc.contact_date
ev.event_hour = '10:00'
ev.event_type = 'Private'
ev.ref_type = 'Lead'
ev.ref_name = self.doc.name
ev.save(1)
#-----------------Email--------------------------------------------
def send_emails(self, email=[], subject='', message=''):
if email:
sendmail(email, sender = webnotes.user.name, subject = subject , parts = [['text/html', message]])
msgprint("Mail Sent")
self.add_in_follow_up(message,'Email')
#-------------------------Checking Sent Mails Details----------------------------------------------
def send_mail(self):
if not self.doc.subject or not self.doc.message:
msgprint("Please enter subject & message in their respective fields.")
elif not self.doc.email_id:
msgprint("Recipient not specified. Please add email id of lead in 'Email id' field provided in 'Contact Info' section.")
raise Exception
else :
self.send_emails([self.doc.email_id.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
#---------------------- Add details in follow up table----------------
def add_in_follow_up(self,message,type):
import datetime
child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
child.notes = message
child.follow_up_type = type
child.save()
#-------------------SMS----------------------------------------------
def send_sms(self):
if not self.doc.sms_message or not self.doc.mobile_no:
msgprint("Please enter mobile number in Basic Info Section and message in SMS Section ")
raise Exception
else:
receiver_list = []
if self.doc.mobile_no:
receiver_list.append(self.doc.mobile_no)
for d in getlist(self.doclist,'lead_sms_detail'):
if d.other_mobile_no:
receiver_list.append(d.other_mobile_no)
if receiver_list:
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
self.add_in_follow_up(self.doc.sms_message,'SMS')

1840
crm/doctype/lead/lead.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-10-06 12:12:21', 'search_fields': None, 'module': 'CRM', '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': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Lead Attachment Detail', '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}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-10-06 12:12:21', 'doctype': 'DocField', 'oldfieldname': 'select_file', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Select File For Attachment', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Lead Attachment Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03137', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-10-06 12:35:51', 'parenttype': 'DocType', 'fieldname': 'select_file', 'fieldtype': 'Link', 'options': 'File', 'report_hide': None, 'parentfield': 'fields'}]

View File

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-10-06 12:10:26', 'search_fields': None, 'module': 'CRM', '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': 0, 'max_attachments': None, 'version': 2, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'Lead SMS Detail', '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}, {'no_copy': None, 'oldfieldtype': 'Data', 'creation': '2009-10-06 12:10:26', 'doctype': 'DocField', 'oldfieldname': 'other_mobile_no', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Mobile No', 'width': '200px', 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'Lead SMS Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03136', 'idx': 1, 'default': None, 'colour': None, 'modified': '2009-10-06 17:26:45', 'parenttype': 'DocType', 'fieldname': 'other_mobile_no', 'fieldtype': 'Data', 'options': None, 'report_hide': None, 'parentfield': 'fields'}]

View File

View File

@@ -0,0 +1,229 @@
# 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
#============================get monthly sales====================================================
def get_monthwise_amount(self,lst):
lst = lst.split(',')
if not lst[1]:
ret = convert_to_lists(sql("SELECT SUM(grand_total) AMOUNT,CASE MONTH(due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME FROM `tabReceivable Voucher` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY MONTH(due_date) ORDER BY MONTH(due_date)"%lst[0]))
else:
ret = convert_to_lists(sql("select sum(t2.amount) AMOUNT ,CASE MONTH(t1.due_date) WHEN 1 THEN 'JAN' WHEN 2 THEN 'FEB' WHEN 3 THEN 'MAR' WHEN 4 THEN 'APR' WHEN 5 THEN 'MAY' WHEN 6 THEN 'JUN' WHEN 7 THEN 'JUL' WHEN 8 THEN 'AUG' WHEN 9 THEN 'SEP' WHEN 10 THEN 'OCT' WHEN 11 THEN 'NOV' WHEN 12 THEN 'DEC' END MONTHNAME from `tabReceivable Voucher` t1,`tabRV Detail` t2 WHERE t1.name = t2.parent and t1.docstatus = 1 and t2.item_group = '%s' AND t1.fiscal_year = '%s' GROUP BY MONTH(t1.due_date) ORDER BY MONTH(t1.due_date)"%(lst[1],lst[0])))
m =cint(sql("select month('%s')"%(get_defaults()['year_start_date']))[0][0])
lst1 = [[1,'JAN'],[2 ,'FEB'], [3,'MAR'],[4,'APR'],[5,'MAY'],[6,'JUN'],[7,'JUL'],[8,'AUG'],[9,'SEP'],[10,'OCT'],[11,'NOV'],[12,'DEC']]
lst2=[]
k=1
for i in range(1,13):
for j in lst1:
if j[0]==m:
lst2.append([k,j[1]])
m +=1
if m==13: m=1
k +=1
return {'msg_data':ret,'x_axis':lst2}
#===============================get weekly sales=================================================
def get_weekwise_amount(self,lst):
lst = lst.split(',')
cases = self.get_week_cases(lst[0],lst[1])
if not lst[2]:
query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+ cases +"END Weekly FROM `tabReceivable Voucher` WHERE MONTH(due_date) = %d AND docstatus = 1 AND fiscal_year = '%s' GROUP BY Weekly ORDER BY Weekly"
ret = convert_to_lists(sql(query%(cint(lst[0]),lst[1])))
else:
query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly FROM `tabReceivable Voucher` t1, `tabRV Detail` t2 WHERE MONTH(t1.due_date) = %d AND t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly"
ret =convert_to_lists(sql(query%(cint(lst[0]),lst[1],lst[2])))
return ret and ret or ''
#================================================================================
def get_week_cases(self,m1,fy):
d1 = self.make_date("%s,%s"%(cstr(m1),fy))
w = sql("select week('%s'),week(last_day('%s'))"%(d1,d1))
w1 = cint(w[0][0])
w2 = cint(w[0][1])
w3 = []
str1 = " "
for i in range(1,7):
if(w1 <= w2):
w3.append(w1)
str1 += "WHEN "+ cstr(w1) +" THEN 'Week"+cstr(i) +"' "
w1 += 1
return str1
#===============================get yearly weekwise sales=================================================
def get_year_weekwise_amount(self,lst):
lst = lst.split(',')
yr_st = get_defaults()['year_start_date']
fy = lst[0]
m1 = cint(yr_st.split('-')[1])
cases = ' '
for i in range(1,13):
cases += self.get_week_cases(m1,fy)
m1 +=1
if(m1 == 13): m1 = 1
if not lst[1]:
query = "SELECT SUM(grand_total) AMOUNT,CASE WEEK(due_date)"+cases+"END Weekly, month(due_date) month FROM `tabReceivable Voucher` WHERE docstatus = 1 AND fiscal_year = '%s' GROUP BY `month`,weekly ORDER BY `month`,weekly"
ret = convert_to_lists(sql(query%lst[0]))
else:
query = "SELECT SUM(t2.amount) AMOUNT,CASE WEEK(t1.due_date)" + cases + "END Weekly, month(due_date) month FROM `tabReceivable Voucher` t1, `tabRV Detail` t2 WHERE t1.docstatus = 1 AND t1.fiscal_year = '%s' AND t1.name = t2.parent AND t2.item_group ='%s' GROUP BY Weekly ORDER BY Weekly"
ret = convert_to_lists(sql(query%(lst[0],lst[1])))
return ret and ret or ''
#====================================make yearly weekwise dates================================================
def yr_wk_dates(self,fy):
from datetime import date
yr_st = get_defaults()['year_start_date']
yr_en = get_defaults()['year_end_date']
fy = fy.split('-')
y1 = yr_st.split('-')
date1 = date(cint(fy[0]),cint(y1[1]),cint(y1[2]))
y2 = yr_en.split('-')
date2 = date(cint(fy[1]),cint(y2[1]),cint(y2[2]))
date_lst = [[1,self.get_months(cint(y1[1]))]]
m1=cint(y1[1])+1
x_axis_lst = [[1,'Week1',cint(y1[1])]]
from datetime import date, timedelta
d =dt= date1
week=k=1
for i in range(0,53):
if dt <= date2:
if(d.weekday()>3):
d = d+timedelta(7-d.weekday())
else:
d = d - timedelta(d.weekday())
dlt = timedelta(days = (week-1)*7)
dt = d + dlt + timedelta(days=6)
m2 = cint(sql("Select month('%s')"%dt)[0][0])
if(m1 == m2):
date_lst.append([i+2,self.get_months(m2)])
x_axis_lst.append([i+2,'Week1',m2])
k=1
m1 += 1
if(m1==13): m1 =1
else:
date_lst.append([i+2,' '])
x_axis_lst.append([i+2,'Week%d'%k,m2])
week += 1
k +=1
return [date_lst,x_axis_lst]
#===================================================================================
def get_months(self,m):
m_lst = {1:'JAN',2:'FEB',3:'MAR',4:'APR',5:'MAY',6:'JUN',7:'JUL',8:'AUG',9:'SEP',10:'OCT',11:'NOV',12:'DEC'}
return m_lst[m]
def get_weekdates(self,lst):
from datetime import date, timedelta
d = dt = self.make_date(lst)
date_lst = [[1,cstr(d.strftime("%d/%m/%y"))]]
week=flag =1
j=1
last_day = sql("select last_day('%s')"%d)[0][0]
lst_m = cint(lst.split(',')[0])
for i in range(2,8):
f=0
if(dt < last_day):
#if(d.weekday()>4):
#d = d+timedelta(7-d.weekday())
#else:
d = d - timedelta(d.weekday()-1)
dlt = timedelta(days = (week-1)*7)
dt = d + dlt + timedelta(days=6)
if(cint(sql("select month('%s')"%dt)[0][0]) == lst_m and dt!=last_day):
for k in date_lst:
if(cstr(dt.strftime("%d/%m/%y")) == k[1]):
f = 1
if f == 0:
date_lst.append([i,cstr(dt.strftime("%d/%m/%y"))])
elif(dt==last_day and flag ==1):
date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
flag = 0
elif(flag == 1):
date_lst.append([i,cstr(last_day.strftime("%d/%m/%y"))])
week += 1
return date_lst and date_lst or ''
def make_date(self,lst):
from datetime import date, timedelta
lst = lst.split(',')
year = lst[1].split('-')
if(len(lst[0])==1): month = '0'+lst[0]
else: month = lst[0]
if(1<=cint(month)<=3): year = year[1]
elif(4<=cint(month)<=12): year = year[0]
d = date(cint(year),cint(month),1)
return d
def get_item_groups(self):
ret = convert_to_lists(sql("select name from `tabItem Group` where docstatus != 2 and is_group = 'No'"))
#ret = convert_to_lists(sql("select item_group from `tabItem` where is_sales_item='Yes' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and item_group !=''"))
return ret and ret or ''
def get_fiscal_year(self):
ret = convert_to_lists(sql("select name from `tabFiscal Year` where docstatus =0"))
return ret and ret or ''

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-05-17 10:36:31', 'search_fields': None, 'module': 'CRM', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'harshada@webnotestech.com', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': None, 'max_attachments': None, 'version': 215, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': None, 'name': 'Plot Control', '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}]

View File

View File

@@ -0,0 +1,40 @@
cur_frm.cscript.tname="Quotation Detail";cur_frm.cscript.fname="quotation_details";cur_frm.cscript.other_fname="other_charges";cur_frm.cscript.sales_team_fname="sales_team";$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
cur_frm.cscript.onload=function(doc,cdt,cdn){if(!doc.quotation_to)hide_field(['customer','customer_address','contact_person','customer_name','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);if(!doc.price_list_name)set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});if(!doc.status)set_multiple(cdt,cdn,{status:'Draft'});if(!doc.transaction_date)set_multiple(cdt,cdn,{transaction_date:get_today()});if(!doc.conversion_rate)set_multiple(cdt,cdn,{conversion_rate:'1.00'});if(!doc.currency&&sys_defaults.currency)set_multiple(cdt,cdn,{currency:sys_defaults.currency});if(!doc.company&&sys_defaults.company)set_multiple(cdt,cdn,{company:sys_defaults.company});if(!doc.fiscal_year&&sys_defaults.fiscal_year)set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});if(doc.__islocal&&!getchildren('RV Tax Detail',doc.name,'other_charges',doc.doctype).length)cur_frm.cscript.load_taxes(doc,cdt,cdn);if(doc.__islocal==1){cur_frm.cscript.price_list_name(doc,cdt,cdn);}
if(doc.quotation_to){if(doc.quotation_to=='Customer'){hide_field(['lead','lead_name']);}
else if(doc.quotation_to=='Lead'){hide_field(['customer','customer_address','contact_person','customer_name','contact_display','customer_group']);}}}
cur_frm.cscript.lead_cust_show=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){unhide_field(['lead']);hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}
else if(doc.quotation_to=='Customer'){unhide_field(['customer']);hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);doc.lead=doc.lead_name=doc.customer=doc.customer_address=doc.contact_person=doc.address_display=doc.contact_display=doc.contact_mobile=doc.contact_email=doc.territory=doc.customer_group="";}}
cur_frm.cscript.quotation_to=function(doc,cdt,cdn){cur_frm.cscript.lead_cust_show(doc,cdt,cdn);}
cur_frm.cscript.refresh=function(doc,cdt,cdn){cur_frm.clear_custom_buttons();if(doc.docstatus==1&&doc.status!='Order Lost'){cur_frm.add_custom_button('Make Sales Order',cur_frm.cscript['Make Sales Order']);cur_frm.add_custom_button('Set as Lost',cur_frm.cscript['Declare Order Lost']);cur_frm.add_custom_button('Send SMS',cur_frm.cscript['Send SMS']);}
if(!doc.docstatus)hide_field(['Update Follow up']);else unhide_field(['Update Follow up']);}
cur_frm.cscript.customer=function(doc,dt,dn){if(doc.customer)get_server_fields('get_default_customer_address',JSON.stringify({customer:doc.customer}),'',doc,dt,dn,1);if(doc.customer)unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
cur_frm.cscript.customer_address=cur_frm.cscript.contact_person=function(doc,dt,dn){if(doc.customer)get_server_fields('get_customer_address',JSON.stringify({customer:doc.customer,address:doc.customer_address,contact:doc.contact_person}),'',doc,dt,dn,1);}
cur_frm.fields_dict.customer_address.on_new=function(dn){locals['Address'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Address'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
cur_frm.fields_dict.contact_person.on_new=function(dn){locals['Contact'][dn].customer=locals[cur_frm.doctype][cur_frm.docname].customer;locals['Contact'][dn].customer_name=locals[cur_frm.doctype][cur_frm.docname].customer_name;}
cur_frm.fields_dict['customer_address'].get_query=function(doc,cdt,cdn){return'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
cur_frm.fields_dict['contact_person'].get_query=function(doc,cdt,cdn){return'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+doc.customer+'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';}
cur_frm.fields_dict['lead'].get_query=function(doc,cdt,cdn){return'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';}
cur_frm.cscript.lead=function(doc,cdt,cdn){if(doc.lead)get_server_fields('get_lead_details',doc.lead,'',doc,cdt,cdn,1);if(doc.lead)unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);}
cur_frm.fields_dict['enq_no'].get_query=function(doc,cdt,cdn){var cond='';var cond1='';if(doc.order_type)cond='ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';if(doc.customer)cond1='`tabEnquiry`.customer = "'+doc.customer+'" AND';else if(doc.lead)cond1='`tabEnquiry`.lead = "'+doc.lead+'" AND';return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50',{cond:cond,cond1:cond1});}
cur_frm.cscript['Make Sales Order']=function(){var doc=cur_frm.doc;if(doc.docstatus==1){var n=createLocal("Sales Order");$c('dt_map',args={'docs':compress_doclist([locals["Sales Order"][n]]),'from_doctype':'Quotation','to_doctype':'Sales Order','from_docname':doc.name,'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"},function(r,rt){loaddoc("Sales Order",n);});}}
cur_frm.cscript['Pull Enquiry Detail']=function(doc,cdt,cdn){var callback=function(r,rt){if(r.message){doc.quotation_to=r.message;if(doc.quotation_to=='Lead'){unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);}
else if(doc.quotation_to=='Customer'){unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);}
refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);}}
$c_obj(make_doclist(doc.doctype,doc.name),'pull_enq_details','',callback);}
cur_frm.cscript['Update Follow up']=function(doc){$c_obj(make_doclist(doc.doctype,doc.name),'update_followup_details','',function(r,rt){refresh_field('follow_up');doc.__unsaved=0;cur_frm.refresh_header();});}
cur_frm.cscript['Declare Order Lost']=function(){var qtn_lost_dialog;set_qtn_lost_dialog=function(doc,cdt,cdn){qtn_lost_dialog=new Dialog(400,400,'Add Quotation Lost Reason');qtn_lost_dialog.make_body([['HTML','Message','<div class="comment">Please add quotation lost reason</div>'],['Text','Quotation Lost Reason'],['HTML','Response','<div class = "comment" id="update_quotation_dialog_response"></div>'],['HTML','Add Reason','<div></div>']]);var add_reason_btn1=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn1.innerHTML='Add';add_reason_btn1.onclick=function(){qtn_lost_dialog.add();}
var add_reason_btn2=$a($i(qtn_lost_dialog.widgets['Add Reason']),'button','button');add_reason_btn2.innerHTML='Cancel';$y(add_reason_btn2,{marginLeft:'4px'});add_reason_btn2.onclick=function(){qtn_lost_dialog.hide();}
qtn_lost_dialog.onshow=function(){qtn_lost_dialog.widgets['Quotation Lost Reason'].value='';$i('update_quotation_dialog_response').innerHTML='';}
qtn_lost_dialog.add=function(){$i('update_quotation_dialog_response').innerHTML='Processing...';var arg=strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);var call_back=function(r,rt){if(r.message=='true'){$i('update_quotation_dialog_response').innerHTML='Done';qtn_lost_dialog.hide();}}
if(arg)$c_obj(make_doclist(cur_frm.doc.doctype,cur_frm.doc.name),'declare_order_lost',arg,call_back);else msgprint("Please add Quotation lost reason");}}
if(!qtn_lost_dialog){set_qtn_lost_dialog(doc,cdt,cdn);}
qtn_lost_dialog.show();}
cur_frm.cscript['Get Report']=function(doc,cdt,cdn){var callback=function(report){report.set_filter('Sales Order Detail','Quotation No.',doc.name)
report.dt.run();}
loadreport('Sales Order Detail','Itemwise Sales Details',callback);}
cur_frm.cscript.quot_to_validate=function(doc,cdt,cdn){if(doc.quotation_to=='Lead'){if(!doc.lead){alert("Lead is mandatory.");validated=false;}}
else if(doc.quotation_to=='Customer'){if(!doc.customer){alert("Customer is mandatory.");validated=false;}}}
cur_frm.cscript.validate=function(doc,cdt,cdn){cur_frm.cscript.quot_to_validate(doc,cdt,cdn);}

View File

@@ -0,0 +1,309 @@
// Module CRM
cur_frm.cscript.tname = "Quotation Detail";
cur_frm.cscript.fname = "quotation_details";
cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
// =====================================================================================
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
// ONLOAD
// ===================================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.quotation_to) hide_field(['customer','customer_address','contact_person','customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
if(!doc.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1.00'});
if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
//if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
// load default charges
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length) cur_frm.cscript.load_taxes(doc, cdt, cdn);
if(doc.__islocal==1){ cur_frm.cscript.price_list_name(doc, cdt, cdn);}
if(doc.quotation_to) {
if(doc.quotation_to == 'Customer') {
hide_field(['lead', 'lead_name']);
}
else if (doc.quotation_to == 'Lead') {
hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']);
}
}
}
// hide - unhide fields based on lead or customer..
// =======================================================================================================================
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
if(doc.quotation_to == 'Lead'){
unhide_field(['lead']);
hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
else if(doc.quotation_to == 'Customer'){
unhide_field(['customer']);
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
//refresh_many(['lead','customer']);
}
//================ hide - unhide fields on basis of quotation to either lead or customer ===============================
cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
//doc.customer_address = doc.territory = doc.contact_no = doc.email_id = "";
//refresh_many(['territory','customer_address','contact_no','email_id']);
//doc.address_display = doc.contact_display = "";
//refresh_many(['address_display','contact_display']);
}
// REFRESH
// ===================================================================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1 && doc.status!='Order Lost') {
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
if (!doc.docstatus) hide_field(['Update Follow up']);
else unhide_field(['Update Follow up']);
//cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
}
// ============== Lead and its Details ============================
/*
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
}
*/
// DOCTYPE TRIGGERS
// ====================================================================================
/*
// ***************** Get Contact Person based on customer selected *****************
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabContact`.contact_name, `tabContact`.email_id FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.docstatus != 2 AND `tabContact`.customer = "'+ doc.customer +'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
}
*/
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
cur_frm.refresh();
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
//lead
cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
return 'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';
}
cur_frm.cscript.lead = function(doc, cdt, cdn) {
if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
}
// =====================================================================================
cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
var cond='';
var cond1='';
if(doc.order_type) cond = 'ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';
if(doc.customer) cond1 = '`tabEnquiry`.customer = "'+doc.customer+'" AND';
else if(doc.lead) cond1 = '`tabEnquiry`.lead = "'+doc.lead+'" AND';
return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50', {cond:cond, cond1:cond1});
}
// Make Sales Order
// =====================================================================================
cur_frm.cscript['Make Sales Order'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
var n = createLocal("Sales Order");
$c('dt_map', args={
'docs':compress_doclist([locals["Sales Order"][n]]),
'from_doctype':'Quotation',
'to_doctype':'Sales Order',
'from_docname':doc.name,
'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"
}, function(r,rt) {
loaddoc("Sales Order", n);
});
}
}
//pull enquiry details
cur_frm.cscript['Pull Enquiry Detail'] = function(doc,cdt,cdn){
var callback = function(r,rt){
if(r.message){
doc.quotation_to = r.message;
if(doc.quotation_to == 'Lead') {
unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);
}
else if(doc.quotation_to == 'Customer') {
unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);
}
}
$c_obj(make_doclist(doc.doctype, doc.name),'pull_enq_details','',callback);
}
//update follow up
//=================================================================================
cur_frm.cscript['Update Follow up'] = function(doc){
$c_obj(make_doclist(doc.doctype, doc.name),'update_followup_details','',function(r, rt){
refresh_field('follow_up');
doc.__unsaved = 0;
cur_frm.refresh_header();
});
}
// declare order lost
//-------------------------
cur_frm.cscript['Declare Order Lost'] = function(){
var qtn_lost_dialog;
set_qtn_lost_dialog = function(doc,cdt,cdn){
qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
qtn_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add quotation lost reason</div>'],
['Text', 'Quotation Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_quotation_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ qtn_lost_dialog.add(); }
var add_reason_btn2 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ qtn_lost_dialog.hide();}
qtn_lost_dialog.onshow = function() {
qtn_lost_dialog.widgets['Quotation Lost Reason'].value = '';
$i('update_quotation_dialog_response').innerHTML = '';
}
qtn_lost_dialog.add = function() {
// sending...
$i('update_quotation_dialog_response').innerHTML = 'Processing...';
var arg = strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_quotation_dialog_response').innerHTML = 'Done';
qtn_lost_dialog.hide();
}
}
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
else msgprint("Please add Quotation lost reason");
}
}
if(!qtn_lost_dialog){
set_qtn_lost_dialog(doc,cdt,cdn);
}
qtn_lost_dialog.show();
}
// GET REPORT
// ========================================================================================
cur_frm.cscript['Get Report'] = function(doc,cdt,cdn) {
var callback = function(report){
report.set_filter('Sales Order Detail', 'Quotation No.',doc.name)
report.dt.run();
}
loadreport('Sales Order Detail','Itemwise Sales Details', callback);
}
/*
//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';}
*/
//===================== Quotation to validation - either customer or lead mandatory ====================
cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
if(doc.quotation_to == 'Lead'){
if(!doc.lead){
alert("Lead is mandatory.");
validated = false;
}
}
else if(doc.quotation_to == 'Customer'){
if(!doc.customer){
alert("Customer is mandatory.");
validated = false;
}
}
}
//===================validation function =================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
}

View File

@@ -0,0 +1,362 @@
# 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, load_json
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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.tname = 'Quotation Detail'
self.fname = 'quotation_details'
# Notification objects
self.notify_obj = get_obj('Notification Control')
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# DOCTYPE TRIGGER FUNCTIONS
# ==============================================================================
# Pull Enquiry Details
# --------------------
def pull_enq_details(self):
self.doc.clear_table(self.doclist, 'quotation_details')
get_obj('DocType Mapper', 'Enquiry-Quotation').dt_map('Enquiry', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Enquiry', 'Quotation'],['Enquiry Detail', 'Quotation Detail']]")
self.get_adj_percent()
return cstr(self.doc.quotation_to)
# Get Customer Details
# --------------------
#def get_customer_details(self):
# return cstr(get_obj('Sales Common').get_customer_details(self))
# Get contact person details based on customer selected
# ------------------------------------------------------
def get_contact_details(self):
return cstr(get_obj('Sales Common').get_contact_details(self,0))
# Clear Quotation Details
# -----------------------
def clear_quotation_details(self):
self.doc.clear_table(self.doclist, 'quotation_details')
# QUOTATION DETAILS TRIGGER FUNCTIONS
# ================================================================================
# Get Item Details
# -----------------
def get_item_details(self, item_code):
return get_obj('Sales Common').get_item_details(item_code, self)
# Re-calculates Basic Rate & amount based on Price List Selected
# --------------------------------------------------------------
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
# OTHER CHARGES TRIGGER FUNCTIONS
# ====================================================================================
# Get Tax rate if account type is TAX
# -----------------------------------
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
# Load Default Charges
# ----------------------------------------------------------
def load_default_taxes(self):
return get_obj('Sales Common').load_default_taxes(self)
# Pull details from other charges master (Get Other Charges)
# ----------------------------------------------------------
def get_other_charges(self):
return get_obj('Sales Common').get_other_charges(self)
# Get Lead Details along with its details
# ==============================================================
def get_lead_details1(self, name):
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, territory, contact_no, mobile_no, email_id from `tabLead` where name = '%s'" %(name), as_dict = 1)
ret = {
'lead_name' : details and details[0]['lead_name'] or '',
'address_display' : (details and details[0]['address_line1']
+ (details[0]['address_line2'] and '\n' + details[0]['address_line2'] or '') + '\n'
+ details[0]['city']
+ (details[0]['pincode'] and ', ' + details[0]['pincode'] or '') + '\n'
+ (details[0]['state'] and details[0]['state']+', ' or '')
+ details[0]['country'] + '\nTel: ' + details[0]['contact_no'] + '\n' or '-'),
'territory' : details and details[0]['territory'] or '',
'contact_mobile' : details and details[0]['mobile_no'] or '-',
'contact_email' : details and details[0]['email_id'] or '-'
}
return cstr(ret)
# GET TERMS AND CONDITIONS
# ====================================================================================
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
# VALIDATE
# ==============================================================================================
# Amendment date is necessary if document is amended
# --------------------------------------------------
def validate_mandatory(self):
if self.doc.amended_from and not self.doc.amendment_date:
msgprint("Please Enter Amendment Date")
raise Exception
# Fiscal Year Validation
# ----------------------
def validate_fiscal_year(self):
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Quotation Date')
# Does not allow same item code to be entered twice
# -------------------------------------------------
def validate_for_items(self):
check_list=[]
chk_dupl_itm = []
for d in getlist(self.doclist,'quotation_details'):
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0]=='Yes':
if cstr(d.item_code) in check_list:
msgprint("Item %s has been entered twice." % d.item_code)
raise Exception
else:
check_list.append(cstr(d.item_code))
if ch and ch[0][0]=='No':
f = [cstr(d.item_code),cstr(d.description)]
if f in chk_dupl_itm:
msgprint("Item %s has been entered twice." % d.item_code)
raise Exception
else:
chk_dupl_itm.append(f)
#do not allow sales item in maintenance quotation and service item in sales quotation
#-----------------------------------------------------------------------------------------------
def validate_order_type(self):
if self.doc.order_type == 'Maintenance':
for d in getlist(self.doclist, 'quotation_details'):
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
is_service_item = is_service_item and is_service_item[0][0] or 'No'
if is_service_item == 'No':
msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation")
raise Exception
else:
for d in getlist(self.doclist, 'quotation_details'):
is_sales_item = sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
if is_sales_item == 'No':
msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation")
raise Exception
#--------------Validation For Last Contact Date-----------------
# ====================================================================================================================
def set_last_contact_date(self):
#if not self.doc.contact_date_ref:
#self.doc.contact_date_ref=self.doc.contact_date
#self.doc.last_contact_date=self.doc.contact_date_ref
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
self.doc.last_contact_date=self.doc.contact_date_ref
else:
msgprint("Contact Date Cannot be before Last Contact Date")
raise Exception
#set(self.doc, 'contact_date_ref',self.doc.contact_date)
# Validate
# --------
def validate(self):
self.validate_fiscal_year()
self.validate_mandatory()
self.set_last_contact_date()
self.validate_order_type()
self.validate_for_items()
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.validate_max_discount(self,'quotation_details') #verify whether rate is not greater than max_discount
sales_com_obj.check_conversion_rate(self)
# Get total in words
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
def on_update(self):
# Add to calendar
#if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
if self.doc.contact_by:
self.add_calendar_event()
set(self.doc, 'contact_date_ref',self.doc.contact_date)
# Set Quotation Status
set(self.doc, 'status', 'Draft')
# subject for follow
self.doc.subject = '[%(status)s] To %(customer)s worth %(currency)s %(grand_total)s' % self.doc.fields
# Add to Calendar
# ====================================================================================================================
def add_calendar_event(self):
desc=''
user_lst =[]
if self.doc.customer:
if self.doc.contact_person:
desc = 'Contact '+cstr(self.doc.contact_person)
else:
desc = 'Contact customer '+cstr(self.doc.customer)
elif self.doc.lead:
if self.doc.lead_name:
desc = 'Contact '+cstr(self.doc.lead_name)
else:
desc = 'Contact lead '+cstr(self.doc.lead)
desc = desc+ '.By : ' + cstr(self.doc.contact_by)
if self.doc.to_discuss:
desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
ev = Document('Event')
ev.description = desc
ev.event_date = self.doc.contact_date
ev.event_hour = '10:00'
ev.event_type = 'Private'
ev.ref_type = 'Enquiry'
ev.ref_name = self.doc.name
ev.save(1)
user_lst.append(self.doc.owner)
chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
if chk:
user_lst.append(chk[0][0])
for d in user_lst:
ch = addchild(ev, 'event_individuals', 'Event User', 0)
ch.person = d
ch.save(1)
#update enquiry
#------------------
def update_enquiry(self, flag):
prevdoc=''
for d in getlist(self.doclist, 'quotation_details'):
if d.prevdoc_docname:
prevdoc = d.prevdoc_docname
if prevdoc:
if flag == 'submit': #on submit
sql("update `tabEnquiry` set status = 'Quotation Sent' where name = %s", prevdoc)
elif flag == 'cancel': #on cancel
sql("update `tabEnquiry` set status = 'Open' where name = %s", prevdoc)
elif flag == 'order lost': #order lost
sql("update `tabEnquiry` set status = 'Enquiry Lost' where name=%s", prevdoc)
elif flag == 'order confirm': #order confirm
sql("update `tabEnquiry` set status='Order Confirmed' where name=%s", prevdoc)
# declare as order lost
#-------------------------
def declare_order_lost(self,arg):
chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Sales Order No. "+cstr(chk[0][0])+" is submitted against this Quotation. Thus 'Order Lost' can not be declared against it.")
raise Exception
else:
set(self.doc, 'status', 'Order Lost')
set(self.doc, 'order_lost_reason', arg)
self.update_enquiry('order lost')
return cstr('true')
#check if value entered in item table
#--------------------------------------
def check_item_table(self):
if not getlist(self.doclist, 'quotation_details'):
msgprint("Please enter item details")
raise Exception
# ON SUBMIT
# =========================================================================
def on_submit(self):
self.check_item_table()
if not self.doc.amended_from:
set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been sent')
else:
set(self.doc, 'message', 'Quotation has been amended. New Quotation no:'+self.doc.name)
# Check for Approving Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
# Set Quotation Status
set(self.doc, 'status', 'Submitted')
#update enquiry status
self.update_enquiry('submit')
# on submit notification
self.notify_obj.notify_contact('Quotation', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.contact_person)
# ON CANCEL
# ==========================================================================
def on_cancel(self):
set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been cancelled')
#update enquiry status
self.update_enquiry('cancel')
set(self.doc,'status','Cancelled')
# SEND SMS
# =============================================================================
def send_sms(self):
if not self.doc.customer_mobile_no:
msgprint("Please enter customer mobile no")
elif not self.doc.message:
msgprint("Please enter the message you want to send")
else:
msgprint(get_obj("SMS Control", "SMS Control").send_sms([self.doc.contact_mobile,], self.doc.message))
# Print other charges
# ===========================================================================
def print_other_charges(self,docname):
print_lst = []
for d in getlist(self.doclist,'other_charges'):
lst1 = []
lst1.append(d.description)
lst1.append(d.total)
print_lst.append(lst1)
return print_lst
def update_followup_details(self):
sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name)
for d in getlist(self.doclist, 'follow_up'):
d.save()

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,370 @@
[
{
'allow_attach': None,
'allow_copy': None,
'allow_email': None,
'allow_print': None,
'allow_rename': None,
'allow_trash': None,
'autoname': None,
'change_log': None,
'client_script': None,
'client_script_core': None,
'client_string': None,
'colour': 'White:FFF',
'creation': '2010-08-08 17:09:19',
'description': None,
'docstatus': 0,
'doctype': 'DocType',
'document_type': None,
'dt_template': None,
'hide_heading': None,
'hide_toolbar': None,
'idx': None,
'in_create': None,
'in_dialog': None,
'is_transaction_doc': None,
'issingle': None,
'istable': 1,
'max_attachments': None,
'menu_index': None,
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'Return Detail',
'name_case': None,
'owner': 'wasim@webnotestech.com',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'print_outline': None,
'read_only': None,
'read_only_onload': None,
'search_fields': None,
'section_style': 'Simple',
'server_code': None,
'server_code_compiled': None,
'server_code_core': None,
'server_code_error': ' ',
'show_in_menu': 0,
'smallicon': None,
'use_template': None,
'version': 12
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:19',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'item_code',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 1,
'in_filter': None,
'label': 'Item Code',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02844',
'no_copy': None,
'oldfieldname': 'item_code',
'oldfieldtype': 'Link',
'options': 'Item',
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:19',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 2,
'in_filter': None,
'label': 'Description',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02845',
'no_copy': None,
'oldfieldname': 'description',
'oldfieldtype': 'Data',
'options': None,
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:20',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'uom',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 3,
'in_filter': None,
'label': 'UOM',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02848',
'no_copy': None,
'oldfieldname': 'uom',
'oldfieldtype': 'Link',
'options': 'UOM',
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:20',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'rate',
'fieldtype': 'Currency',
'hidden': None,
'icon': None,
'idx': 4,
'in_filter': None,
'label': 'Rate',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02849',
'no_copy': None,
'oldfieldname': 'rate',
'oldfieldtype': 'Currency',
'options': None,
'owner': 'Administrator',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:19',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'qty',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 5,
'in_filter': None,
'label': 'Qty',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02846',
'no_copy': None,
'oldfieldname': 'qty',
'oldfieldtype': 'Data',
'options': None,
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:19',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'returned_qty',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 6,
'in_filter': None,
'label': 'Returned Qty',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02847',
'no_copy': None,
'oldfieldname': 'returned_qty',
'oldfieldtype': 'Data',
'options': None,
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-01-21 12:06:04',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'serial_no',
'fieldtype': 'Small Text',
'hidden': None,
'icon': None,
'idx': 7,
'in_filter': None,
'label': 'Serial No',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL04415',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-01-21 12:06:04',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'batch_no',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 8,
'in_filter': None,
'label': 'Batch No',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL04416',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:19',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'detail_name',
'fieldtype': 'Data',
'hidden': 1,
'icon': None,
'idx': 9,
'in_filter': None,
'label': 'Detail Name',
'modified': '2011-02-23 19:09:05',
'modified_by': 'Administrator',
'name': 'FL02843',
'no_copy': None,
'oldfieldname': 'detail_name',
'oldfieldtype': 'Data',
'options': None,
'owner': 'wasim@webnotestech.com',
'parent': 'Return Detail',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
}
]

View File

View File

@@ -0,0 +1,74 @@
cur_frm.cscript.load_taxes=function(doc,cdt,cdn){if(doc.customer)return;$c_obj([doc],'load_default_taxes','',function(r,rt){refresh_field('other_charges');});}
cur_frm.add_fetch('company','default_currency','currency');cur_frm.cscript.customer=function(doc,cdt,cdn){if(doc.customer){if(!doc.company){msgprint("Please select company to proceed");doc.customer='';refresh_field('customer');}else{var callback=function(r,rt){cur_frm.refresh();}
$c_obj(make_doclist(doc.doctype,doc.name),'get_customer_details','',callback);}}}
cur_frm.cscript.TerritoryHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Territory');}
loadpage('Sales Browser',call_back);}
cur_frm.cscript.CGHelp=function(doc,dt,dn){var call_back=function(){var sb_obj=new SalesBrowser();sb_obj.set_val('Customer Group');}
loadpage('Sales Browser',call_back);}
cur_frm.cscript.currency=function(doc,cdt,cdn){cur_frm.cscript.price_list_name(doc,cdt,cdn);}
cur_frm.cscript.price_list_name=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;if(doc.price_list_name&&doc.currency){$c_obj(make_doclist(doc.doctype,doc.name),'get_adj_percent','',function(r,rt){refresh_field(fname);var doc=locals[cdt][cdn];cur_frm.cscript.recalc(doc,3);});}}
cur_frm.cscript.conversion_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);}
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query=function(doc,cdt,cdn){if(doc.order_type=='Maintenance')
return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';else
return'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';}
cur_frm.cscript.item_code=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];if(d.item_code){if(!doc.company){msgprint("Please select company to proceed");d.item_code='';refresh_field('item_code',d.name,fname);}else{var callback=function(r,rt){cur_frm.cscript.recalc(doc,1);}
get_server_fields('get_item_details',d.item_code,fname,doc,cdt,cdn,1,callback);}}
if(cur_frm.cscript.custom_item_code){cur_frm.cscript.custom_item_code(doc,cdt,cdn);}}
cur_frm.cscript.qty=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);}
cur_frm.cscript.adj_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,1);}
cur_frm.cscript.ref_rate=function(doc,cdt,cdn){var d=locals[cdt][cdn];set_multiple(cur_frm.cscript.tname,d.name,{'export_rate':flt(d.ref_rate)*(100-flt(d.adj_rate))/100},cur_frm.cscript.fname);cur_frm.cscript.recalc(doc,3);}
cur_frm.cscript.basic_rate=function(doc,cdt,cdn){var fname=cur_frm.cscript.fname;var d=locals[cdt][cdn];;if(!d.qty)
{d.qty=1;refresh_field('qty',d.name,fname);}
cur_frm.cscript.recalc(doc,2);}
cur_frm.cscript.export_rate=function(doc,cdt,cdn){cur_frm.cscript.recalc(doc,3);}
cur_frm.fields_dict.charge.get_query=function(doc){return'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';}
cur_frm.cscript['Get Charges']=function(doc,cdt,cdn){$c_obj(make_doclist(doc.doctype,doc.name),'get_other_charges','',function(r,rt){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);});}
cur_frm.cscript.recalc=function(doc,n){if(!n)n=0;doc=locals[doc.doctype][doc.name];var tname=cur_frm.cscript.tname;var fname=cur_frm.cscript.fname;var sales_team=cur_frm.cscript.sales_team_fname;var other_fname=cur_frm.cscript.other_fname;if(!flt(doc.conversion_rate)){doc.conversion_rate=1;refresh_field('conversion_rate');}
if(n>0)cur_frm.cscript.update_fname_table(doc,tname,fname,n);if(flt(doc.net_total)>0){var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i<cl.length;i++){cl[i].total_tax_amount=0;cl[i].total_amount=0;cl[i].tax_amount=0;cl[i].total=0;cl[i].item_wise_tax_detail="";if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type)&&!cl[i].row_id){alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);validated=false;}}
cur_frm.cscript.calc_other_charges(doc,tname,fname,other_fname);}
cur_frm.cscript.calc_doc_values(doc,cdt,cdn,tname,fname,other_fname);cl=getchildren('Sales Team',doc.name,sales_team);for(var i=0;i<cl.length;i++){if(cl[i].allocated_percentage){cl[i].allocated_amount=flt(flt(doc.net_total)*flt(cl[i].allocated_percentage)/100);refresh_field('allocated_amount',cl[i].name,sales_team);}}
doc.in_words='';doc.in_words_export='';refresh_many(['total_discount_rate','total_discount','net_total','total_commission','grand_total','rounded_total','grand_total_export','rounded_total_export','in_words','in_words_export','other_charges','other_charges_total']);if(cur_frm.cscript.custom_recalc)cur_frm.cscript.custom_recalc(doc);}
cur_frm.cscript.calc_doc_values=function(doc,cdt,cdn,tname,fname,other_fname){doc=locals[doc.doctype][doc.name];var net_total=0;var other_charges_total=0;var cl=getchildren(tname,doc.name,fname);for(var i=0;i<cl.length;i++){net_total+=flt(cl[i].amount);}
var d=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var j=0;j<d.length;j++){other_charges_total+=flt(d[j].amount);}
doc.net_total=flt(net_total);doc.other_charges_total=flt(other_charges_total);doc.grand_total=flt(flt(net_total)+flt(other_charges_total));doc.rounded_total=Math.round(doc.grand_total);doc.grand_total_export=flt(flt(doc.grand_total)/flt(doc.conversion_rate));doc.rounded_total_export=Math.round(doc.grand_total_export);doc.total_commission=flt(flt(net_total)*flt(doc.commission_rate)/100);}
cur_frm.cscript.calc_other_charges=function(doc,tname,fname,other_fname){doc=locals[doc.doctype][doc.name];cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML='<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';var cl=getchildren(tname,doc.name,fname);var tax=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);var otc=make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area,cl.length+1,tax.length+1,'90%',[],{border:'1px solid #AAA',padding:'2px'});$y(otc,{marginTop:'8px'});var tax_desc={};var tax_desc_rates=[];var net_total=0;for(var i=0;i<cl.length;i++){net_total+=flt(flt(cl[i].qty)*flt(cl[i].basic_rate));var prev_total=flt(cl[i].amount);if(cl[i].item_tax_rate)
var check_tax=eval('var a='+cl[i].item_tax_rate+';a');$td(otc,i+1,0).innerHTML=cl[i].item_code?cl[i].item_code:cl[i].description;var tax=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);var total=net_total;for(var t=0;t<tax.length;t++){var account=tax[t].account_head;$td(otc,0,t+1).innerHTML=account?account:'';if(cl[i].item_tax_rate&&check_tax[account]!=null){rate=flt(check_tax[account]);}
else
rate=flt(tax[t].rate);var tax_amount=cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t,cl[i],rate);item_wise_tax_detail=cur_frm.cscript.get_item_wise_tax_detail(doc,rate,cl,i,tax,t);if(tax[t].charge_type!="Actual")tax[t].item_wise_tax_detail+=item_wise_tax_detail;tax[t].total_amount=flt(tax_amount.toFixed(2));tax[t].total_tax_amount=flt(prev_total.toFixed(2));tax[t].tax_amount+=flt(tax_amount.toFixed(2));var total_amount=flt(tax[t].tax_amount);total_tax_amount=flt(tax[t].total_tax_amount)+flt(total_amount);set_multiple('RV Tax Detail',tax[t].name,{'item_wise_tax_detail':tax[t].item_wise_tax_detail,'amount':total_amount,'total':flt(total)+flt(tax[t].tax_amount)},other_fname);prev_total+=flt(tax[t].total_amount);total+=flt(tax[t].tax_amount);if(tax[t].charge_type=='Actual')
$td(otc,i+1,t+1).innerHTML=fmt_money(tax[t].total_amount);else
$td(otc,i+1,t+1).innerHTML='('+fmt_money(rate)+'%) '+fmt_money(tax[t].total_amount);}}}
cur_frm.cscript.check_charge_type_and_get_tax_amount=function(doc,tax,t,cl,rate,print_amt){doc=locals[doc.doctype][doc.name];if(!print_amt)print_amt=0;var tax_amount=0;if(tax[t].charge_type=='Actual'){var value=flt(tax[t].rate)/flt(doc.net_total);return tax_amount=flt(value)*flt(cl.amount);}
else if(tax[t].charge_type=='On Net Total'){if(flt(print_amt)==1){doc.excise_rate=flt(rate);doc.total_excise_rate+=flt(rate);refresh_field('excise_rate');refresh_field('total_excise_rate');return}
return tax_amount=(flt(rate)*flt(cl.amount)/100);}
else if(tax[t].charge_type=='On Previous Row Amount'){if(flt(print_amt)==1){doc.total_excise_rate+=flt(flt(doc.excise_rate)*0.01*flt(rate));refresh_field('total_excise_rate');return}
var row_no=(tax[t].row_id).toString();var row=(row_no).split("+");for(var r=0;r<row.length;r++){var id=cint(row[r].replace(/^\s+|\s+$/g,""));tax_amount+=(flt(rate)*flt(tax[id-1].total_amount)/100);}
var row_id=row_no.indexOf("/");if(row_id!=-1){rate='';var row=(row_no).split("/");if(row.length>2)alert("You cannot enter more than 2 nos. for division");var id1=cint(row[0].replace(/^\s+|\s+$/g,""));var id2=cint(row[1].replace(/^\s+|\s+$/g,""));tax_amount=flt(tax[id1-1].total_amount)/flt(tax[id2-1].total_amount);}
return tax_amount}
else if(tax[t].charge_type=='On Previous Row Total'){if(flt(print_amt)==1){doc.sales_tax_rate+=flt(rate);refresh_field('sales_tax_rate');return}
var row=cint(tax[t].row_id);return tax_amount=flt(rate)*(flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount))/100;}}
cur_frm.cscript.update_fname_table=function(doc,tname,fname,n){doc=locals[doc.doctype][doc.name]
var net_total=0
var cl=getchildren(tname,doc.name,fname);for(var i=0;i<cl.length;i++){if(n==1){if(flt(cl[i].ref_rate)>0)
set_multiple(tname,cl[i].name,{'export_rate':flt(flt(cl[i].ref_rate)*(100-flt(cl[i].adj_rate))/100)},fname);set_multiple(tname,cl[i].name,{'export_amount':flt(flt(cl[i].qty)*flt(cl[i].export_rate)),'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate)),'amount':flt((flt(cl[i].export_rate)*flt(doc.conversion_rate))*flt(cl[i].qty))},fname);}
else if(n==2){if(flt(cl[i].ref_rate)>0)
set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].basic_rate)*100/(flt(cl[i].ref_rate)*flt(doc.conversion_rate)))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].qty)*flt(cl[i].basic_rate)),'export_rate':flt(flt(cl[i].basic_rate)/flt(doc.conversion_rate)),'export_amount':flt((flt(cl[i].basic_rate)/flt(doc.conversion_rate))*flt(cl[i].qty))},fname);}
else if(n==3){set_multiple(tname,cl[i].name,{'basic_rate':flt(flt(cl[i].export_rate)*flt(doc.conversion_rate))},fname);set_multiple(tname,cl[i].name,{'amount':flt(flt(cl[i].basic_rate)*flt(cl[i].qty)),'export_amount':flt(flt(cl[i].export_rate)*flt(cl[i].qty))},fname);if(cl[i].ref_rate>0)
set_multiple(tname,cl[i].name,{'adj_rate':100-flt(flt(cl[i].export_rate)*100/flt(cl[i].ref_rate)),'base_ref_rate':flt(flt(cl[i].ref_rate)*flt(doc.conversion_rate))},fname);}
net_total+=flt(flt(cl[i].qty)*flt(cl[i].basic_rate));}
doc.net_total=net_total;refresh_field('net_total');}
cur_frm.cscript.get_item_wise_tax_detail=function(doc,rate,cl,i,tax,t){doc=locals[doc.doctype][doc.name];var detail='';detail=cl[i].item_code+" : "+cstr(rate)+NEWLINE;return detail;}
cur_frm.cscript['Re-Calculate Values']=function(doc,cdt,cdn){cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);}
cur_frm.cscript['Calculate Charges']=function(doc,cdt,cdn){var other_fname=cur_frm.cscript.other_fname;var cl=getchildren('RV Tax Detail',doc.name,other_fname,doc.doctype);for(var i=0;i<cl.length;i++){cl[i].total_tax_amount=0;cl[i].total_amount=0;cl[i].tax_amount=0;cl[i].total=0;if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type)&&!cl[i].row_id){alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);validated=false;}}
cur_frm.cscript.recalc(doc,1);}
cur_frm.cscript.sales_partner=function(doc,cdt,cdn){if(doc.sales_partner){get_server_fields('get_comm_rate',doc.sales_partner,'',doc,cdt,cdn,1);}}
cur_frm.cscript.commission_rate=function(doc,cdt,cdn){if(doc.commission_rate>100){alert("Commision rate cannot be greater than 100.");doc.total_commission=0;doc.commission_rate=0;}
else
doc.total_commission=doc.net_total*doc.commission_rate/100;refresh_many(['total_commission','commission_rate']);}
cur_frm.cscript.total_commission=function(doc,cdt,cdn){if(doc.net_total){if(doc.net_total<doc.total_commission){alert("Total commission cannot be greater than net total.");doc.total_commission=0;doc.commission_rate=0;}
else
doc.commission_rate=doc.total_commission*100/doc.net_total;refresh_many(['total_commission','commission_rate']);}}
cur_frm.cscript.allocated_percentage=function(doc,cdt,cdn){var fname=cur_frm.cscript.sales_team_fname;var d=locals[cdt][cdn];if(d.allocated_percentage){d.allocated_amount=flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);refresh_field('allocated_amount',d.name,fname);}}
cur_frm.cscript.validate=function(doc,cdt,cdn){cur_frm.cscript.validate_items(doc);var cl=getchildren('Other Charges',doc.name,'other_charges');for(var i=0;i<cl.length;i++){if(!cl[i].amount){alert("Please Enter Amount in Row no. "+cl[i].idx+" in Other Charges table");validated=false;}}
cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);if(cur_frm.cscript.calc_adjustment_amount)cur_frm.cscript.calc_adjustment_amount(doc);}
cur_frm.cscript.validate_items=function(doc){var cl=getchildren(cur_frm.cscript.tname,doc.name,cur_frm.cscript.fname);if(!cl.length){alert("Please enter Items for "+doc.doctype);validated=false;}}

View File

@@ -0,0 +1,479 @@
// Preset
// ------
// cur_frm.cscript.tname - Details table name
// cur_frm.cscript.fname - Details fieldname
// cur_frm.cscript.other_fname - Other Charges fieldname
// cur_frm.cscript.sales_team_fname - Sales Team fieldname
// ============== Load Default Taxes ===================
cur_frm.cscript.load_taxes = function(doc, cdt, cdn) {
// run if this is not executed from dt_map...
if(doc.customer) return;
$c_obj([doc],'load_default_taxes','',function(r,rt){
refresh_field('other_charges');
});
}
// -----------------
// Shipping Address
// -----------------
//cur_frm.add_fetch('ship_det_no', 'shipping_address', 'shipping_address');
//cur_frm.add_fetch('ship_det_no', 'ship_to', 'ship_to');
cur_frm.add_fetch('company', 'default_currency', 'currency');
// ============== Customer and its primary contact Details ============================
cur_frm.cscript.customer = function(doc, cdt, cdn) {
if(doc.customer){
if (!doc.company) {
msgprint("Please select company to proceed");
doc.customer = '';
refresh_field('customer');
} else {
var callback = function(r, rt){
cur_frm.refresh();
}
$c_obj(make_doclist(doc.doctype, doc.name), 'get_customer_details', '',callback);
}
}
}
//====================opens territory tree page ==================
cur_frm.cscript.TerritoryHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Territory');
}
loadpage('Sales Browser',call_back);
}
//====================opens customer group tree page ==================
cur_frm.cscript.CGHelp = function(doc,dt,dn){
var call_back = function(){
var sb_obj = new SalesBrowser();
sb_obj.set_val('Customer Group');
}
loadpage('Sales Browser',call_back);
}
/*
// ============= Customer's Contact Person Details =====================================
cur_frm.cscript.contact_person = function(doc, cdt, cdn) {
var callback = function(){
refresh_many(['contact_no','email_id','customer_mobile_no','customer_address']);
}
get_server_fields('get_contact_details','','',doc, cdt, cdn, 1, callback);
}
*/
// TRIGGERS FOR CALCULATIONS
// =====================================================================================================
// ********************* CURRENCY ******************************
cur_frm.cscript.currency = function(doc, cdt, cdn) {
cur_frm.cscript.price_list_name(doc, cdt, cdn);
}
// ******************** PRICE LIST ******************************
cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
var fname = cur_frm.cscript.fname;
if(doc.price_list_name && doc.currency) {
$c_obj(make_doclist(doc.doctype, doc.name), 'get_adj_percent', '',
function(r, rt) {
refresh_field(fname);
var doc = locals[cdt][cdn];
cur_frm.cscript.recalc(doc,3); //this is to re-calculate BASIC RATE and AMOUNT on basis of changed REF RATE
}
);
}
}
// ******************* CONVERSION RATE ***************************
cur_frm.cscript.conversion_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 3);/*cur_frm.cscript.price_list_name(doc, cdt, cdn);*/ }
// ******************** ITEM CODE ********************************
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
if (doc.order_type == 'Maintenance')
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
else
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND tabItem.docstatus != 2 AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
}
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var fname = cur_frm.cscript.fname;
var d = locals[cdt][cdn];
if (d.item_code) {
if (!doc.company) {
msgprint("Please select company to proceed");
d.item_code = '';
refresh_field('item_code', d.name, fname);
} else {
var callback = function(r, rt){
cur_frm.cscript.recalc(doc, 1);
}
get_server_fields('get_item_details',d.item_code, fname,doc,cdt,cdn,1,callback);
}
}
if(cur_frm.cscript.custom_item_code){
cur_frm.cscript.custom_item_code(doc, cdt, cdn);
}
}
// *********************** QUANTITY ***************************
cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
// ************************ DISCOUNT (%) ***********************
cur_frm.cscript.adj_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
// ************************ REF RATE ****************************
cur_frm.cscript.ref_rate = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
set_multiple(cur_frm.cscript.tname, d.name, {'export_rate': flt(d.ref_rate) * (100 - flt(d.adj_rate)) / 100}, cur_frm.cscript.fname);
cur_frm.cscript.recalc(doc, 3);
}
// *********************** BASIC RATE **************************
cur_frm.cscript.basic_rate = function(doc, cdt, cdn) {
var fname = cur_frm.cscript.fname;
var d = locals[cdt][cdn];;
if(!d.qty)
{
d.qty = 1;
refresh_field('qty', d.name, fname);
}
cur_frm.cscript.recalc(doc, 2);
}
// ************************ EXPORT RATE *************************
cur_frm.cscript.export_rate = function(doc,cdt,cdn) { cur_frm.cscript.recalc(doc, 3);}
// ************* GET OTHER CHARGES BASED ON COMPANY *************
cur_frm.fields_dict.charge.get_query = function(doc) {
return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
}
// ********************* Get Charges ****************************
cur_frm.cscript['Get Charges'] = function(doc, cdt, cdn) {
$c_obj(make_doclist(doc.doctype,doc.name),'get_other_charges','', function(r, rt) { cur_frm.cscript['Calculate Charges'](doc, cdt, cdn);});
}
// CALCULATION OF TOTAL AMOUNTS
// ========================================================================================================
cur_frm.cscript.recalc = function(doc, n) {
if(!n)n=0;
doc = locals[doc.doctype][doc.name];
var tname = cur_frm.cscript.tname;
var fname = cur_frm.cscript.fname;
var sales_team = cur_frm.cscript.sales_team_fname;
var other_fname = cur_frm.cscript.other_fname;
if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n); // updates all values in table (i.e. amount, export amount, net total etc.)
if(flt(doc.net_total) > 0) {
var cl = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
for(var i = 0; i<cl.length; i++){
cl[i].total_tax_amount = 0;
cl[i].total_amount = 0;
cl[i].tax_amount = 0; // this is done to calculate other charges
cl[i].total = 0;
cl[i].item_wise_tax_detail = "";
if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
validated = false;
}
}
cur_frm.cscript.calc_other_charges(doc , tname , fname , other_fname); // calculate other charges
}
cur_frm.cscript.calc_doc_values(doc, cdt, cdn, tname, fname, other_fname); // calculates total amounts
// ******************* calculate allocated amount of sales person ************************
cl = getchildren('Sales Team', doc.name, sales_team);
for(var i=0;i<cl.length;i++) {
if (cl[i].allocated_percentage) {
cl[i].allocated_amount = flt(flt(doc.net_total)*flt(cl[i].allocated_percentage)/100);
refresh_field('allocated_amount', cl[i].name, sales_team);
}
}
doc.in_words = '';
doc.in_words_export = '';
refresh_many(['total_discount_rate','total_discount','net_total','total_commission','grand_total','rounded_total','grand_total_export','rounded_total_export','in_words','in_words_export','other_charges','other_charges_total']);
if(cur_frm.cscript.custom_recalc)cur_frm.cscript.custom_recalc(doc);
}
// ******* Calculation of total amounts of document (item amount + other charges)****************
cur_frm.cscript.calc_doc_values = function(doc, cdt, cdn, tname, fname, other_fname) {
doc = locals[doc.doctype][doc.name];
var net_total = 0; var other_charges_total = 0;
var cl = getchildren(tname, doc.name, fname);
for(var i = 0; i<cl.length; i++){
net_total += flt(cl[i].amount);
}
var d = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
for(var j = 0; j<d.length; j++){
other_charges_total += flt(d[j].amount);
}
doc.net_total = flt(net_total);
doc.other_charges_total = flt(other_charges_total);
doc.grand_total = flt(flt(net_total) + flt(other_charges_total));
doc.rounded_total = Math.round(doc.grand_total);
doc.grand_total_export = flt(flt(doc.grand_total) / flt(doc.conversion_rate));
doc.rounded_total_export = Math.round(doc.grand_total_export);
doc.total_commission = flt(flt(net_total) * flt(doc.commission_rate) / 100);
}
// ******************************* OTHER CHARGES *************************************
cur_frm.cscript.calc_other_charges = function(doc , tname , fname , other_fname) {
doc = locals[doc.doctype][doc.name];
// make display area
// ------------------
cur_frm.fields_dict['Other Charges Calculation'].disp_area.innerHTML = '<b style="padding: 8px 0px;">Calculation Details for Other Charges:</b>';
var cl = getchildren(tname, doc.name, fname);
var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
// make display table
// ------------------
var otc = make_table(cur_frm.fields_dict['Other Charges Calculation'].disp_area, cl.length + 1, tax.length + 1, '90%',[],{border:'1px solid #AAA',padding:'2px'});
$y(otc,{marginTop:'8px'});
var tax_desc = {}; var tax_desc_rates = []; var net_total = 0;
for(var i=0;i<cl.length;i++) {
net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
var prev_total = flt(cl[i].amount);
if(cl[i].item_tax_rate)
var check_tax = eval('var a='+cl[i].item_tax_rate+';a'); //to get in dictionary
// Add Item Code in new Row
//--------------------------
$td(otc,i+1,0).innerHTML = cl[i].item_code ? cl[i].item_code : cl[i].description;
var tax = getchildren('RV Tax Detail', doc.name, other_fname,doc.doctype);
var total = net_total;
for(var t=0;t<tax.length;t++){
var account = tax[t].account_head;
$td(otc,0,t+1).innerHTML = account?account:'';
//Check For Rate
if(cl[i].item_tax_rate && check_tax[account]!=null) {rate = flt(check_tax[account]);}
else // if particular item doesn't have particular rate it will take other charges rate
rate = flt(tax[t].rate);
//Check For Rate and get tax amount
var tax_amount = cur_frm.cscript.check_charge_type_and_get_tax_amount(doc,tax,t, cl[i], rate);
//enter item_wise_tax_detail i.e. tax rate on each item
item_wise_tax_detail = cur_frm.cscript.get_item_wise_tax_detail( doc, rate, cl, i, tax, t);
// this is calculation part for all types
if(tax[t].charge_type != "Actual") tax[t].item_wise_tax_detail += item_wise_tax_detail;
tax[t].total_amount = flt(tax_amount.toFixed(2)); //stores actual tax amount in virtual field
tax[t].total_tax_amount = flt(prev_total.toFixed(2)); //stores total amount in virtual field
tax[t].tax_amount += flt(tax_amount.toFixed(2));
var total_amount = flt(tax[t].tax_amount);
total_tax_amount = flt(tax[t].total_tax_amount) + flt(total_amount);
set_multiple('RV Tax Detail', tax[t].name, { 'item_wise_tax_detail':tax[t].item_wise_tax_detail, 'amount':total_amount, 'total':flt(total)+flt(tax[t].tax_amount)/*_tax_amount)*/}, other_fname);
prev_total += flt(tax[t].total_amount); // for previous row total
total += flt(tax[t].tax_amount); // for adding total to previous amount
if(tax[t].charge_type == 'Actual')
$td(otc,i+1,t+1).innerHTML = fmt_money(tax[t].total_amount);
else
$td(otc,i+1,t+1).innerHTML = '('+fmt_money(rate) + '%) ' +fmt_money(tax[t].total_amount);
}
}
}
cur_frm.cscript.check_charge_type_and_get_tax_amount = function( doc, tax, t, cl, rate, print_amt) {
doc = locals[doc.doctype][doc.name];
if (! print_amt) print_amt = 0;
var tax_amount = 0;
if(tax[t].charge_type == 'Actual') {
var value = flt(tax[t].rate) / flt(doc.net_total); // this give the ratio in which all items are divided
return tax_amount = flt(value) * flt(cl.amount);
}
else if(tax[t].charge_type == 'On Net Total') {
if (flt(print_amt) == 1) {
doc.excise_rate = flt(rate);
doc.total_excise_rate += flt(rate);
refresh_field('excise_rate');
refresh_field('total_excise_rate');
return
}
return tax_amount = (flt(rate) * flt(cl.amount) / 100);
}
else if(tax[t].charge_type == 'On Previous Row Amount'){
if(flt(print_amt) == 1) {
doc.total_excise_rate += flt(flt(doc.excise_rate) * 0.01 * flt(rate));
refresh_field('total_excise_rate');
return
}
var row_no = (tax[t].row_id).toString();
var row = (row_no).split("+"); // splits the values and stores in an array
for(var r = 0;r<row.length;r++){
var id = cint(row[r].replace(/^\s+|\s+$/g,""));
tax_amount += (flt(rate) * flt(tax[id-1].total_amount) / 100);
}
var row_id = row_no.indexOf("/");
if(row_id != -1) {
rate = '';
var row = (row_no).split("/"); // splits the values and stores in an array
if(row.length>2) alert("You cannot enter more than 2 nos. for division");
var id1 = cint(row[0].replace(/^\s+|\s+$/g,""));
var id2 = cint(row[1].replace(/^\s+|\s+$/g,""));
tax_amount = flt(tax[id1-1].total_amount) / flt(tax[id2-1].total_amount);
}
return tax_amount
}
else if(tax[t].charge_type == 'On Previous Row Total') {
if(flt(print_amt) == 1) {
doc.sales_tax_rate += flt(rate);
refresh_field('sales_tax_rate');
return
}
var row = cint(tax[t].row_id);
return tax_amount = flt(rate) * (flt(tax[row-1].total_tax_amount)+flt(tax[row-1].total_amount)) / 100;
}
}
// ********************** Update values in table ******************************
cur_frm.cscript.update_fname_table = function(doc , tname , fname , n) {
doc = locals[doc.doctype][doc.name]
var net_total = 0
var cl = getchildren(tname, doc.name, fname);
for(var i=0;i<cl.length;i++) {
if(n == 1){
if(flt(cl[i].ref_rate) > 0)
set_multiple(tname, cl[i].name, {'export_rate': flt(flt(cl[i].ref_rate) * (100 - flt(cl[i].adj_rate)) / 100)}, fname);
set_multiple(tname, cl[i].name, {'export_amount': flt(flt(cl[i].qty) * flt(cl[i].export_rate)), 'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate)), 'amount': flt((flt(cl[i].export_rate) * flt(doc.conversion_rate)) * flt(cl[i].qty)) }, fname);
}
else if(n == 2){
if(flt(cl[i].ref_rate) > 0)
set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].basic_rate) * 100 / (flt(cl[i].ref_rate) * flt(doc.conversion_rate)))}, fname);
set_multiple(tname, cl[i].name, {'amount': flt(flt(cl[i].qty) * flt(cl[i].basic_rate)), 'export_rate': flt(flt(cl[i].basic_rate) / flt(doc.conversion_rate)), 'export_amount': flt((flt(cl[i].basic_rate) / flt(doc.conversion_rate)) * flt(cl[i].qty)) }, fname);
}
else if(n == 3){
set_multiple(tname, cl[i].name, {'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate))}, fname);
set_multiple(tname, cl[i].name, {'amount' : flt(flt(cl[i].basic_rate) * flt(cl[i].qty)), 'export_amount': flt(flt(cl[i].export_rate) * flt(cl[i].qty))}, fname);
if(cl[i].ref_rate > 0)
set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].export_rate) * 100 / flt(cl[i].ref_rate)), 'base_ref_rate': flt(flt(cl[i].ref_rate) * flt(doc.conversion_rate)) }, fname);
}
net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
}
doc.net_total = net_total;
refresh_field('net_total');
}
cur_frm.cscript.get_item_wise_tax_detail = function( doc, rate, cl, i, tax, t) {
doc = locals[doc.doctype][doc.name];
var detail = '';
detail = cl[i].item_code + " : " + cstr(rate) + NEWLINE;
return detail;
}
// **************** RE-CALCULATE VALUES ***************************
cur_frm.cscript['Re-Calculate Values'] = function(doc, cdt, cdn) {
cur_frm.cscript['Calculate Charges'](doc,cdt,cdn);
}
cur_frm.cscript['Calculate Charges'] = function(doc, cdt, cdn) {
var other_fname = cur_frm.cscript.other_fname;
var cl = getchildren('RV Tax Detail', doc.name, other_fname, doc.doctype);
for(var i = 0; i<cl.length; i++){
cl[i].total_tax_amount = 0;
cl[i].total_amount = 0;
cl[i].tax_amount = 0; // this is done to calculate other charges
cl[i].total = 0;
if(in_list(['On Previous Row Amount','On Previous Row Total'],cl[i].charge_type) && !cl[i].row_id){
alert("Please Enter Row on which amount needs to be calculated for row : "+cl[i].idx);
validated = false;
}
}
cur_frm.cscript.recalc(doc, 1);
}
// Get Sales Partner Commission
// =================================================================================
cur_frm.cscript.sales_partner = function(doc, cdt, cdn){
if(doc.sales_partner){
get_server_fields('get_comm_rate', doc.sales_partner, '', doc, cdt, cdn, 1);
}
}
// *******Commission Rate Trigger (calculates total commission amount)*********
cur_frm.cscript.commission_rate = function(doc, cdt, cdn) {
if(doc.commission_rate > 100){
alert("Commision rate cannot be greater than 100.");
doc.total_commission = 0;
doc.commission_rate = 0;
}
else
doc.total_commission = doc.net_total * doc.commission_rate / 100;
refresh_many(['total_commission','commission_rate']);
}
// *******Total Commission Trigger (calculates commission rate)*********
cur_frm.cscript.total_commission = function(doc, cdt, cdn) {
if(doc.net_total){
if(doc.net_total < doc.total_commission){
alert("Total commission cannot be greater than net total.");
doc.total_commission = 0;
doc.commission_rate = 0;
}
else
doc.commission_rate = doc.total_commission * 100 / doc.net_total;
refresh_many(['total_commission','commission_rate']);
}
}
// Sales Person Allocated % trigger
// ==============================================================================
cur_frm.cscript.allocated_percentage = function(doc, cdt, cdn) {
var fname = cur_frm.cscript.sales_team_fname;
var d = locals[cdt][cdn];
if (d.allocated_percentage) {
d.allocated_amount = flt(flt(doc.net_total)*flt(d.allocated_percentage)/100);
refresh_field('allocated_amount', d.name, fname);
}
}
// Client Side Validation
// =================================================================================
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_items(doc);
var cl = getchildren('Other Charges', doc.name, 'other_charges');
for(var i =0;i<cl.length;i++) {
if(!cl[i].amount) {
alert("Please Enter Amount in Row no. "+cl[i].idx+" in Other Charges table");
validated = false;
}
}
cur_frm.cscript['Calculate Charges'] (doc, cdt, cdn);
if (cur_frm.cscript.calc_adjustment_amount) cur_frm.cscript.calc_adjustment_amount(doc);
}
// ************** Atleast one item in document ****************
cur_frm.cscript.validate_items = function(doc) {
var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
if(!cl.length){
alert("Please enter Items for " + doc.doctype);
validated = false;
}
}

View File

@@ -0,0 +1,759 @@
# 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
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.doctype_dict = {
'Sales Order' : 'Sales Order Detail',
'Delivery Note' : 'Delivery Note Detail',
'Receivable Voucher':'RV Detail',
'Installation Note' : 'Installed Item Details'
}
self.ref_doctype_dict= {}
self.next_dt_detail = {
'delivered_qty' : 'Delivery Note Detail',
'billed_qty' : 'RV Detail',
'installed_qty' : 'Installed Item Details'}
self.msg = []
# Get Sales Person Details
# ==========================
def get_sales_person_details(self, obj):
if obj.doc.doctype != 'Quotation':
obj.doc.clear_table(obj.doclist,'sales_team')
idx = 0
for d in sql("select sales_person, allocated_percentage, allocated_amount, incentives from `tabSales Team` where parent = '%s'" % obj.doc.customer):
ch = addchild(obj.doc, 'sales_team', 'Sales Team', 1, obj.doclist)
ch.sales_person = d and cstr(d[0]) or ''
ch.allocated_percentage = d and flt(d[1]) or 0
ch.allocated_amount = d and flt(d[2]) or 0
ch.incentives = d and flt(d[3]) or 0
ch.idx = idx
idx += 1
# Get customer's contact person details
# ==============================================================
def get_contact_details(self, obj = '', primary = 0):
cond = " and contact_name = '"+cstr(obj.doc.contact_person)+"'"
if primary: cond = " and is_primary_contact = 'Yes'"
contact = sql("select contact_name, contact_no, email_id, contact_address from `tabContact` where customer = '%s' and docstatus != 2 %s" %(obj.doc.customer, cond), as_dict = 1)
if not contact:
return
c = contact[0]
obj.doc.contact_person = c['contact_name'] or ''
obj.doc.contact_no = c['contact_no'] or ''
obj.doc.email_id = c['email_id'] or ''
obj.doc.customer_mobile_no = c['contact_no'] or ''
if c['contact_address']:
obj.doc.customer_address = c['contact_address']
# Get customer's primary shipping details
# ==============================================================
def get_shipping_details(self, obj = ''):
det = sql("select name, ship_to, shipping_address from `tabShipping Address` where customer = '%s' and docstatus != 2 and ifnull(is_primary_address, 'Yes') = 'Yes'" %(obj.doc.customer), as_dict = 1)
obj.doc.ship_det_no = det and det[0]['name'] or ''
obj.doc.ship_to = det and det[0]['ship_to'] or ''
obj.doc.shipping_address = det and det[0]['shipping_address'] or ''
# get invoice details
# ====================
def get_invoice_details(self, obj = ''):
if obj.doc.company:
acc_head = sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + get_value('Company', obj.doc.company, 'abbr')))
obj.doc.debit_to = acc_head and acc_head[0][0] or ''
# Get Customer Details along with its primary contact details
# ==============================================================
def get_customer_details(self, obj = '', inv_det_reqd = 1):
details = sql("select customer_name,address, territory, customer_group, default_sales_partner, default_commission_rate from `tabCustomer` where name = '%s' and docstatus != 2" %(obj.doc.customer), as_dict = 1)
obj.doc.customer_name = details and details[0]['customer_name'] or ''
obj.doc.customer_address = details and details[0]['address'] or ''
obj.doc.territory = details and details[0]['territory'] or ''
obj.doc.customer_group = details and details[0]['customer_group'] or ''
obj.doc.sales_partner = details and details[0]['default_sales_partner'] or ''
obj.doc.commission_rate = details and flt(details[0]['default_commission_rate']) or ''
if obj.doc.doctype != 'Receivable Voucher':
obj.doc.delivery_address = details and details[0]['address'] or ''
self.get_contact_details(obj,primary = 1) # get primary contact details
self.get_sales_person_details(obj) # get default sales person details
if obj.doc.doctype == 'Receivable Voucher' and inv_det_reqd:
self.get_invoice_details(obj) # get invoice details
# Get Item Details
# ===============================================================
def get_item_details(self, item_code, obj):
if not obj.doc.price_list_name:
msgprint("Please Select Price List before selecting Items")
raise Exception
item = sql("select description, item_name, brand, item_group, stock_uom, default_warehouse, default_income_account, default_sales_cost_center, description_html from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life > now() or end_of_life = '0000-00-00') and (is_sales_item = 'Yes' or is_service_item = 'Yes')" %(item_code), as_dict=1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
t = {}
for x in tax: t[x[0]] = flt(x[1])
ret = {
'description' : item and item[0]['description_html'] or item[0]['description'],
'item_group' : item and item[0]['item_group'] or '',
'item_name' : item and item[0]['item_name'] or '',
'brand' : item and item[0]['brand'] or '',
'stock_uom' : item and item[0]['stock_uom'] or '',
'reserved_warehouse' : item and item[0]['default_warehouse'] or '',
'warehouse' : item and item[0]['default_warehouse'] or '',
'income_account' : item and item[0]['default_income_account'] or '',
'cost_center' : item and item[0]['default_sales_cost_center'] or '',
'qty' : 1.00, # this is done coz if item once fetched is fetched again thn its qty shld be reset to 1
'adj_rate' : 0,
'amount' : 0,
'export_amount' : 0,
'item_tax_rate' : str(t),
'batch_no' : ''
}
if(obj.doc.price_list_name and item): #this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST
ref_rate = self.get_ref_rate(item_code, obj.doc.price_list_name, obj.doc.currency)
ret['ref_rate'] = flt(ref_rate)
ret['export_rate'] = flt(ref_rate)
ret['base_ref_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
ret['basic_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
if obj.doc.doctype == 'Receivable Voucher':
return ret
return str(ret)
# ***************** Get Ref rate as entered in Item Master ********************
def get_ref_rate(self, item_code, price_list_name, currency):
ref_rate = sql("select ref_rate from `tabRef Rate Detail` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, currency))
return ref_rate and ref_rate[0][0] or 0
# ****** Re-calculates Basic Rate & amount based on Price List Selected ******
def get_adj_percent(self, obj):
for d in getlist(obj.doclist, obj.fname):
ref_rate = self.get_ref_rate(d.item_code,obj.doc.price_list_name,obj.doc.currency)
d.adj_rate = 0
d.ref_rate = flt(ref_rate)
d.basic_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
d.base_ref_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
d.export_rate = flt(ref_rate)
# Load Default Taxes
# ====================
def load_default_taxes(self, obj):
self.get_other_charges(obj,1)
# Get other charges from Master
# =================================================================================
def get_other_charges(self,obj,default = 0):
obj.doc.clear_table(obj.doclist,'other_charges')
if not getlist(obj.doclist, 'other_charges'):
if default: add_cond = 'ifnull(t2.is_default,0) = 1'
else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
idx = 0
other_charge = sql("select t1.charge_type,t1.row_id,t1.description,t1.account_head,t1.rate,t1.tax_amount from `tabRV Tax Detail` t1, `tabOther Charges` t2 where t1.parent = t2.name and t2.company = '%s' and %s order by t1.idx" % (obj.doc.company, add_cond), as_dict = 1)
for other in other_charge:
d = addchild(obj.doc, 'other_charges', 'RV Tax Detail', 1, obj.doclist)
d.charge_type = other['charge_type']
d.row_id = other['row_id']
d.description = other['description']
d.account_head = other['account_head']
d.rate = flt(other['rate'])
d.tax_amount = flt(other['tax_amount'])
d.idx = idx
idx += 1
# Get TERMS AND CONDITIONS
# =======================================================================================
def get_tc_details(self,obj):
r = sql("select terms from `tabTerm` where name = %s", obj.doc.tc_name)
if r: obj.doc.terms = r[0][0]
#---------------------------------------- Get Tax Details -------------------------------#
def get_tax_details(self, item_code, obj):
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item_code)
t = {}
for x in tax: t[x[0]] = flt(x[1])
ret = {
'item_tax_rate' : tax and str(t) or ''
}
return str(ret)
# Get Serial No Details
# ==========================================================================
def get_serial_details(self, serial_no, obj):
item = sql("select item_code, make, label,brand, description from `tabSerial No` where name = '%s' and docstatus != 2" %(serial_no), as_dict=1)
tax = sql("select tax_type, tax_rate from `tabItem Tax` where parent = %s" , item[0]['item_code'])
t = {}
for x in tax: t[x[0]] = flt(x[1])
ret = {
'item_code' : item and item[0]['item_code'] or '',
'make' : item and item[0]['make'] or '',
'label' : item and item[0]['label'] or '',
'brand' : item and item[0]['brand'] or '',
'description' : item and item[0]['description'] or '',
'item_tax_rate' : str(t)
}
return str(ret)
# Get Commission rate
# =======================================================================
def get_comm_rate(self, sales_partner, obj):
comm_rate = sql("select commission_rate from `tabSales Partner` where name = '%s' and docstatus != 2" %(sales_partner), as_dict=1)
if comm_rate:
total_comm = flt(comm_rate[0]['commission_rate']) * flt(obj.doc.net_total) / 100
ret = {
'commission_rate' : comm_rate and flt(comm_rate[0]['commission_rate']) or 0,
'total_commission' : flt(total_comm)
}
return str(ret)
else:
msgprint("Business Associate : %s does not exist in the system." % (sales_partner))
raise Exception
# To verify whether rate entered in details table does not exceed max discount %
# =======================================================================================
def validate_max_discount(self,obj, detail_table):
for d in getlist(obj.doclist, detail_table):
discount = sql("select max_discount from tabItem where name = '%s'" %(d.item_code),as_dict = 1)
if discount and discount[0]['max_discount'] and (flt(d.adj_rate)>flt(discount[0]['max_discount'])):
msgprint("You cannot give more than " + cstr(discount[0]['max_discount']) + " % discount on Item Code : "+cstr(d.item_code))
raise Exception
# Get sum of allocated % of sales person (it should be 100%)
# ========================================================================
# it indicates % contribution of sales person in sales
def get_allocated_sum(self,obj):
sum = 0
for d in getlist(obj.doclist,'sales_team'):
sum += flt(d.allocated_percentage)
if (flt(sum) != 100) and getlist(obj.doclist,'sales_team'):
msgprint("Total Allocated % of Sales Persons should be 100%")
raise Exception
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
# ===========================================================================
def check_conversion_rate(self, obj):
default_currency = get_obj('Manage Account').doc.default_currency
company_currency = sql("select default_currency from `tabCompany` where name = '%s'" % obj.doc.company)
curr = company_currency and cstr(company_currency[0][0]) or default_currency
if (obj.doc.currency == curr and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != curr and flt(obj.doc.conversion_rate) == 1.00):
msgprint("Please Enter Appropriate Conversion Rate.")
raise Exception
# Get Tax rate if account type is TAX
# =========================================================================
def get_rate(self, arg):
arg = eval(arg)
rate = sql("select account_type, tax_rate from `tabAccount` where name = '%s' and docstatus != 2" %(arg['account_head']), as_dict=1)
ret = {'rate' : 0}
if arg['charge_type'] == 'Actual' and rate[0]['account_type'] == 'Tax':
msgprint("You cannot select ACCOUNT HEAD of type TAX as your CHARGE TYPE is 'ACTUAL'")
ret = {
'account_head' : ''
}
elif rate[0]['account_type'] in ['Tax', 'Chargeable'] and not arg['charge_type'] == 'Actual':
ret = {
'rate' : rate and flt(rate[0]['tax_rate']) or 0
}
return cstr(ret)
# Make Packing List from Sales BOM
# =======================================================================
def has_sales_bom(self, item_code):
return sql("select name from `tabSales BOM` where name=%s and docstatus != 2", item_code)
def get_sales_bom_items(self, item_code):
return sql("select item_code, qty, uom from `tabSales BOM Detail` where parent=%s", item_code)
# --------------
# get item list
# --------------
def get_item_list(self, obj, is_stopped):
il = []
for d in getlist(obj.doclist,obj.fname):
reserved_qty = 0 # used for delivery note
qty = flt(d.qty)
if is_stopped:
qty = flt(d.qty) > flt(d.delivered_qty) and flt(flt(d.qty) - flt(d.delivered_qty)) or 0
if d.prevdoc_doctype == 'Sales Order': # used in delivery note to reduce reserved_qty
# Eg.: if SO qty is 10 and there is tolerance of 20%, then it will allow DN of 12.
# But in this case reserved qty should only be reduced by 10 and not 12.
tot_qty, max_qty, tot_amt, max_amt = self.get_curr_and_ref_doc_details(d.doctype, 'prevdoc_detail_docname', d.prevdoc_detail_docname, 'Sales Order Detail', obj.doc.name, obj.doc.doctype)
if((flt(tot_qty) + flt(qty) > flt(max_qty))):
reserved_qty = -(flt(max_qty)-flt(tot_qty))
else:
reserved_qty = - flt(qty)
warehouse = (obj.fname == "sales_order_details") and d.reserved_warehouse or d.warehouse
if self.has_sales_bom(d.item_code):
for i in self.get_sales_bom_items(d.item_code):
il.append([warehouse, i[0], flt(flt(i[1])* qty), reserved_qty, i[2], d.batch_no, d.serial_no])
else:
il.append([warehouse, d.item_code, qty, reserved_qty, d.stock_uom, d.batch_no, d.serial_no])
return il
# -----------------------
# add packing list items
# -----------------------
def get_packing_item_details(self, item):
return sql("select item_name, description, stock_uom from `tabItem` where name = %s", item, as_dict = 1)[0]
def get_bin_qty(self, item, warehouse):
det = sql("select actual_qty, projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (item, warehouse), as_dict = 1)
return det and det[0] or ''
def add_packing_list_item(self,obj, item_code, qty, warehouse, line):
bin = self.get_bin_qty(item_code, warehouse)
item = self.get_packing_item_details(item_code)
pi = addchild(obj.doc, 'packing_details', 'Delivery Note Packing Detail', 1, obj.doclist)
pi.parent_item = item_code
pi.item_code = item_code
pi.item_name = item['item_name']
pi.parent_detail_docname = line.name
pi.description = item['description']
pi.uom = item['stock_uom']
pi.qty = flt(qty)
pi.actual_qty = bin and flt(bin['actual_qty']) or 0
pi.projected_qty = bin and flt(bin['projected_qty']) or 0
pi.warehouse = warehouse
pi.prevdoc_doctype = line.prevdoc_doctype
pi.serial_no = cstr(line.serial_no)
pi.idx = self.packing_list_idx
self.packing_list_idx += 1
# ------------------
# make packing list from sales bom if exists or directly copy item with balance
# ------------------
def make_packing_list(self, obj, fname):
obj.doc.clear_table(obj.doclist, 'packing_details')
self.packing_list_idx = 0
for d in getlist(obj.doclist, fname):
warehouse = fname == "sales_order_details" and d.reserved_warehouse or d.warehouse
if self.has_sales_bom(d.item_code):
for i in self.get_sales_bom_items(d.item_code):
self.add_packing_list_item(obj, i[0], flt(i[1])*flt(d.qty), warehouse, d)
else:
self.add_packing_list_item(obj, d.item_code, d.qty, warehouse, d)
# Get total in words
# ==================================================================
def get_total_in_words(self, currency, amount):
from webnotes.utils import money_in_words
return money_in_words(amount, currency)
# Get month based on date (required in sales person and sales partner)
# ========================================================================
def get_month(self,date):
month_list = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
month_idx = cint(cstr(date).split('-')[1])-1
return month_list[month_idx]
# **** Check for Stop SO as no transactions can be made against Stopped SO. Need to unstop it. ***
def check_stop_sales_order(self,obj):
for d in getlist(obj.doclist,obj.fname):
ref_doc_name = ''
if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_doctype == 'Sales Order':
ref_doc_name = d.prevdoc_docname
elif d.fields.has_key('sales_order') and d.sales_order and not d.delivery_note:
ref_doc_name = d.sales_order
if ref_doc_name:
so_status = sql("select status from `tabSales Order` where name = %s",ref_doc_name)
so_status = so_status and so_status[0][0] or ''
if so_status == 'Stopped':
msgprint("You cannot do any transaction against Sales Order : '%s' as it is Stopped." %(ref_doc_name))
raise Exception
# ****** Check for Item.is_sales_item = 'Yes' and Item.docstatus != 2 *******
def check_active_sales_items(self,obj):
for d in getlist(obj.doclist, obj.fname):
if d.item_code: # extra condn coz item_code is not mandatory in RV
valid_item = sql("select docstatus,is_sales_item, is_service_item from tabItem where name = %s",d.item_code)
if valid_item and valid_item[0][0] == 2:
msgprint("Item : '%s' does not exist in system." %(d.item_code))
raise Exception
sales_item = valid_item and valid_item[0][1] or 'No'
service_item = valid_item and valid_item[0][2] or 'No'
if sales_item == 'No' and service_item == 'No':
msgprint("Item : '%s' is neither Sales nor Service Item"%(d.item_code))
raise Exception
# **************************************************************************************************************************************************
def check_credit(self,obj,grand_total):
acc_head = sql("select name from `tabAccount` where company = '%s' and master_name = '%s'"%(obj.doc.company, obj.doc.customer))
if acc_head:
tot_outstanding = 0
dbcr = sql("select sum(debit), sum(credit) from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No')='No'" % acc_head[0][0])
if dbcr:
tot_outstanding = flt(dbcr[0][0])-flt(dbcr[0][1])
exact_outstanding = flt(tot_outstanding) + flt(grand_total)
get_obj('Account',acc_head[0][0]).check_credit_limit(acc_head[0][0], obj.doc.company, exact_outstanding)
def validate_fiscal_year(self,fiscal_year,transaction_date,dn):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%fiscal_year)
ysd=fy and fy[0][0] or ""
yed=add_days(str(ysd),365)
if str(transaction_date) < str(ysd) or str(transaction_date) > str(yed):
msgprint("%s not within the fiscal year"%(dn))
raise Exception
# Check Approving Authority
# -------------------------
def check_approving_authority(self, doctype_name, grand_total):
det = sql("select amount from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount <= '%s'" % (doctype_name, grand_total))
amt_list, auth_users = [], []
if det:
for x in det:
amt_list.append(flt(x[0]))
max_amount = max(amt_list)
# Get names of all approving authority with max amount
for d in sql("select approving_authority from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount = '%s'" % (doctype_name, flt(max_amount))): auth_users.append(d[0])
for x in sql("select approving_authority from `tabApproval Structure` where doctype_name = '%s' and parent = 'Authorization Rules' and amount > '%s'" % (doctype_name, grand_total)): auth_users.append(x[0])
if not has_common(auth_users, session['data']['profile']['roles']):
msgprint("You do not have an authority to submit this %s. Only %s can submit since amount exceeds %s. %s" % (doctype_name, auth_users, get_defaults()['currency'], flt(max_amount)))
raise Exception
# get against document date self.prevdoc_date_field
#-----------------------------
def get_prevdoc_date(self, obj):
import datetime
for d in getlist(obj.doclist, obj.fname):
if d.prevdoc_doctype and d.prevdoc_docname:
if d.prevdoc_doctype == 'Receivable Voucher':
dt = sql("select posting_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
else:
dt = sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname))
d.prevdoc_date = dt and dt[0][0].strftime('%Y-%m-%d') or ''
def update_prevdoc_detail(self, is_submit, obj):
StatusUpdater(obj, is_submit).update()
# ---------------------------------------------------------------------------------------------
# get qty, amount already billed or delivered against curr line item for current doctype
# For Eg: SO-RV get total qty, amount from SO and also total qty, amount against that SO in RV
# ---------------------------------------------------------------------------------------------
def get_curr_and_ref_doc_details(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, curr_parent_name, curr_parent_doctype):
# Get total qty, amt of current doctype (eg RV) except for qty, amt of this transaction
if curr_parent_doctype == 'Installation Note':
curr_det = sql("select sum(qty) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, 0
else:
curr_det = sql("select sum(qty), sum(amount) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% (curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name))
qty, amt = curr_det and flt(curr_det[0][0]) or 0, curr_det and flt(curr_det[0][1]) or 0
# get total qty of ref doctype
ref_det = sql("select qty, amount from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn))
max_qty, max_amt = ref_det and flt(ref_det[0][0]) or 0, ref_det and flt(ref_det[0][1]) or 0
return qty, max_qty, amt, max_amt
#
# make item code readonly if (detail no is set)
#
class StatusUpdater:
"""
Updates the status of the calling records
From Delivery Note
- Update Delivered Qty
- Update Percent
- Validate over delivery
From Receivable Voucher
- Update Billed Qty
- Update Percent
- Validate over billing
From Installation Note
- Update Installed Qty
- Update Percent Qty
- Validate over installation
"""
def __init__(self, obj, is_submit):
self.obj = obj # caller object
self.is_submit = is_submit
self.tolerance = {}
self.global_tolerance = None
def update(self):
self.update_all_qty()
self.validate_all_qty()
def validate_all_qty(self):
"""
Validates over-billing / delivery / installation in Delivery Note, Receivable Voucher, Installation Note
To called after update_all_qty
"""
if self.obj.doc.doctype=='Delivery Note':
self.validate_qty({
'source_dt' :'Delivery Note Detail',
'compare_field' :'delivered_qty',
'target_dt' :'Sales Order Detail',
'join_field' :'prevdoc_detail_docname'
})
elif self.obj.doc.doctype=='Receivable Voucher':
self.validate_qty({
'source_dt' :'RV Detail',
'compare_field' :'billed_qty',
'target_dt' :'Sales Order Detail',
'join_field' :'so_detail'
})
elif self.obj.doc.doctype=='Installation Note':
self.validate_qty({
'source_dt' :'Installation Item Details',
'compare_field' :'installed_qty',
'target_dt' :'Delivery Note Detail',
'join_field' :'dn_detail'
}, no_tolerance =1);
def get_tolerance_for(self, item_code):
"""
Returns the tolerance for the item, if not set, returns global tolerance
"""
if self.tolerance.get(item_code):
return self.tolerance[item_code]
tolerance = flt(get_value('Item',item_code,'tolerance') or 0)
if not(tolerance):
if self.global_tolerance == None:
self.global_tolerance = flt(get_value('Manage Account',None,'tolerance') or 0)
tolerance = self.global_tolerance
self.tolerance[item_code] = tolerance
return tolerance
def check_overflow_with_tolerance(self, item, args):
"""
Checks if there is overflow condering a relaxation tolerance
"""
# check if overflow is within tolerance
tolerance = self.get_tolerance_for(item['item_code'])
overflow_percent = ((item[args['compare_field']] - item['qty']) / item['qty'] * 100)
if overflow_percent - tolerance > 0.0001:
item['max_allowed'] = flt(item['qty'] * (100+tolerance)/100)
item['reduce_by'] = cint(item[args['compare_field']] - item['max_allowed'])
msgprint("""
Row #%(idx)s: Max qty allowed for <b>Item %(item_code)s</b> against <b>%(parenttype)s %(parent)s</b> is <b>%(max_allowed)s</b>.
If you want to increase your overflow tolerance, please increase tolerance %% in Global Defaults or Item master.
Or, you must reduce the qty by %(reduce_by)s""" % item, raise_exception=1)
def validate_qty(self, args, no_tolerance=None):
"""
Updates qty at row level
"""
# get unique transactions to update
for d in self.obj.doclist:
if d.doctype == args['source_dt']:
args['name'] = d.fields[args['join_field']]
# get all qty where qty > compare_field
item = sql("""
select item_code, qty, `%(compare_field)s`, parenttype, parent from `tab%(target_dt)s`
where qty < `%(compare_field)s` and name="%(name)s" and docstatus=1
""" % args, as_dict=1)
if item:
item = item[0]
item['idx'] = d.idx
if no_tolerance:
item['reduce_by'] = item[args['compare_field']] - item['qty']
msgprint("""
Row #%(idx)s: Max qty allowed for <b>Item %(item_code)s</b> against
<b>%(parenttype)s %(parent)s</b> is <b>%(qty)s</b>.
You must reduce the qty by %(reduce_by)s""" % item, raise_exception=1)
else:
self.check_overflow_with_tolerance(item, args)
def update_all_qty(self):
"""
Updates delivered / billed / installed qty in Sales Order & Delivery Note
"""
if self.obj.doc.doctype=='Delivery Note':
self.update_qty({
'target_field' :'delivered_qty',
'target_dt' :'Sales Order Detail',
'target_parent_dt' :'Sales Order',
'target_parent_field' :'per_delivered',
'source_dt' :'Delivery Note Detail',
'source_field' :'qty',
'join_field' :'prevdoc_detail_docname',
'percent_join_field' :'prevdoc_docname',
'status_field' :'delivery_status',
'keyword' :'Delivered'
})
elif self.obj.doc.doctype=='Receivable Voucher':
self.update_qty({
'target_field' :'billed_qty',
'target_dt' :'Sales Order Detail',
'target_parent_dt' :'Sales Order',
'target_parent_field' :'per_billed',
'source_dt' :'RV Detail',
'source_field' :'qty',
'join_field' :'so_detail',
'percent_join_field' :'sales_order',
'status_field' :'billing_status',
'keyword' :'Billed'
})
self.update_qty({
'target_field' :'billed_qty',
'target_dt' :'Delivery Note Detail',
'target_parent_dt' :'Delivery Note',
'target_parent_field' :'per_billed',
'source_dt' :'RV Detail',
'source_field' :'qty',
'join_field' :'dn_detail',
'percent_join_field' :'delivery_note',
'status_field' :'billing_status',
'keyword' :'Billed'
})
if self.obj.doc.doctype=='Installation Note':
self.update_qty({
'target_field' :'installed_qty',
'target_dt' :'Delivery Note Detail',
'target_parent_dt' :'Delivery Note',
'target_parent_field' :'per_installed',
'source_dt' :'Installed Item Details',
'source_field' :'qty',
'join_field' :'prevdoc_detail_docname',
'percent_join_field' :'prevdoc_docname',
'status_field' :'installation_status',
'keyword' :'Installed'
})
def update_qty(self, args):
"""
Updates qty at row level
"""
# condition to include current record (if submit or no if cancel)
if self.is_submit:
args['cond'] = ' or parent="%s"' % self.obj.doc.name
else:
args['cond'] = ' and parent!="%s"' % self.obj.doc.name
# update quantities in child table
for d in self.obj.doclist:
if d.doctype == args['source_dt']:
# updates qty in the child table
args['detail_id'] = d.fields.get(args['join_field'])
if args['detail_id']:
sql("""
update
`tab%(target_dt)s`
set
%(target_field)s = (select sum(qty) from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" and (docstatus=1 %(cond)s))
where
name="%(detail_id)s"
""" % args)
# get unique transactions to update
for name in set([d.fields.get(args['percent_join_field']) for d in self.obj.doclist if d.doctype == args['source_dt']]):
if name:
args['name'] = name
# update percent complete in the parent table
if args.get('source_dt')!='Installed Item Details':
sql("""
update
`tab%(target_parent_dt)s`
set
%(target_parent_field)s = (
(select sum(amount) from `tab%(source_dt)s` where `%(percent_join_field)s`="%(name)s" and (docstatus=1 %(cond)s))
/ net_total
* 100
)
where
name="%(name)s"
""" % args)
else:
sql("""
update
`tab%(target_parent_dt)s`
set
%(target_parent_field)s = (
(select sum(qty) from `tab%(source_dt)s` where `%(percent_join_field)s`="%(name)s" and (docstatus=1 %(cond)s))
/ (select sum(qty) from `tab%(target_dt)s` where parent="%(name)s" and docstatus=1)
* 100
)
where
name="%(name)s"
""" % args)
# update field
if args['status_field']:
sql("""
update
`tab%(target_parent_dt)s`
set
%(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, 'Not %(keyword)s',
if(%(target_parent_field)s>=99.99, 'Fully %(keyword)s', 'Partly %(keyword)s')
)
where
name="%(name)s"
""" % args)

View File

@@ -0,0 +1 @@
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-12-09 15:26:59', 'search_fields': None, 'module': 'CRM', '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': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 342, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': '', 'name': 'Sales Common', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-11-30 22:12:20', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]

View File

View File

@@ -0,0 +1,353 @@
// Module CRM
cur_frm.cscript.tname = "Sales Order Detail";
cur_frm.cscript.fname = "sales_order_details";
cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
// ONLOAD
// ================================================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
// load default charges
if(doc.__islocal){
hide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
}
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.__islocal) {
if(doc.quotation) cur_frm.cscript['Pull Quotation Details'](doc,cdt,cdn);
} else {
cur_frm.cscript.load_taxes(doc, cdt, cdn);
}
}
// REFRESH
// ================================================================================================
cur_frm.cscript.get_open_status = function(doc) {
var open_delivery = 0; var open_invoicing=0;
var ch = getchildren('Sales Order Detail',doc.name,'sales_order_details');
for(var i in ch){
if(ch[i].qty > ch[i].delivered_qty) open_delivery = 1;
if(ch[i].qty > ch[i].billed_qty) open_invoicing = 1;
if(ch[i].amount > ch[i].billed_amt) open_invoicing = 1;
}
return [open_delivery, open_invoicing];
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
var open_status = cur_frm.cscript.get_open_status(doc);
if(doc.docstatus==1) {
if(doc.status != 'Stopped') {
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
// delivery note
if(open_status[0] && doc.order_type!='Maintenance')
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
// maintenance
if(open_status[0] && doc.order_type=='Maintenance') {
cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript['Make Maintenance Visit']);
cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
}
// indent
if(doc.order_type != 'Maintenance')
cur_frm.add_custom_button('Make Indent', cur_frm.cscript['Make Indent']);
// sales invoice
if(open_status[1])
cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
// stop
if(open_status[0] || open_status[1])
cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
} else {
// un-stop
cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
}
unhide_field(['Repair Sales Order', 'Send SMS', 'message', 'customer_mobile_no'])
} else {
hide_field(['Repair Sales Order', 'Send SMS', 'message', 'customer_mobile_no'])
}
}
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0);
cur_frm.refresh();
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.cscript['Pull Quotation Details'] = function(doc,dt,dn) {
var callback = function(r,rt){
var doc = locals[cur_frm.doctype][cur_frm.docname];
if(r.message){
doc.quotation_no = r.message;
if(doc.quotation_no) {
unhide_field(['quotation_date','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','shipping_address']);
if(doc.customer) get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0);
}
cur_frm.refresh();
}
}
$c_obj(make_doclist(doc.doctype, doc.name),'pull_quotation_details','',callback);
}
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
}
// DOCTYPE TRIGGERS
// ================================================================================================
/*
// ***************** get shipping address based on customer selected *****************
cur_frm.fields_dict['ship_det_no'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabShipping Address`.`name`, `tabShipping Address`.`ship_to`, `tabShipping Address`.`shipping_address` FROM `tabShipping Address` WHERE `tabShipping Address`.customer = "'+ doc.customer+'" AND `tabShipping Address`.`docstatus` != 2 AND `tabShipping Address`.`name` LIKE "%s" ORDER BY `tabShipping Address`.name ASC LIMIT 50';
}
*/
// ***************** Get project name *****************
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
var cond = '';
if(doc.customer) cond = '(`tabProject`.customer = "'+doc.customer+'" OR IFNULL(`tabProject`.customer,"")="") AND';
return repl('SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND %(cond)s `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond});
}
//---- get customer details ----------------------------
cur_frm.cscript.project_name = function(doc,cdt,cdn){
$c_obj(make_doclist(doc.doctype, doc.name),'pull_project_customer','', function(r,rt){
refresh_many(['customer','customer_name', 'customer_address', 'contact_person', 'territory', 'contact_no', 'email_id', 'customer_group']);
});
}
// *************** Customized link query for QUOTATION *****************************
cur_frm.fields_dict['quotation_no'].get_query = function(doc) {
var cond='';
if(doc.order_type) cond = ' ifnull(`tabQuotation`.order_type, "") = "'+doc.order_type+'" and';
if(doc.customer) cond += ' ifnull(`tabQuotation`.customer, "") = "'+doc.customer+'" and';
return repl('SELECT DISTINCT name, customer, transaction_date FROM `tabQuotation` WHERE `tabQuotation`.company = "' + doc.company + '" and `tabQuotation`.`docstatus` = 1 and `tabQuotation`.status != "Order Lost" and %(cond)s `tabQuotation`.%(key)s LIKE "%s" ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
}
// SALES ORDER DETAILS TRIGGERS
// ================================================================================================
// ***************** Get available qty in warehouse of item selected ****************
cur_frm.cscript.reserved_warehouse = function(doc, cdt , cdn) {
var d = locals[cdt][cdn];
if (d.reserved_warehouse) {
arg = "{'item_code':'" + d.item_code + "','warehouse':'" + d.reserved_warehouse +"'}";
get_server_fields('get_available_qty',arg,'sales_order_details',doc,cdt,cdn,1);
}
}
//----------- make maintenance schedule----------
cur_frm.cscript['Make Maintenance Schedule'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_schedule','',
function(r,rt){
if(r.message == 'No'){
n = createLocal("Maintenance Schedule");
$c('dt_map', args={
'docs':compress_doclist([locals["Maintenance Schedule"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Maintenance Schedule',
'from_docname':doc.name,
'from_to_list':"[['Sales Order', 'Maintenance Schedule'], ['Sales Order Detail', 'Item Maintenance Detail']]"
}
, function(r,rt) {
loaddoc("Maintenance Schedule", n);
}
);
}
else{
msgprint("You have already created Maintenance Schedule against this Sales Order");
}
}
);
}
}
//------------ make maintenance visit ------------
cur_frm.cscript['Make Maintenance Visit'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_visit','',
function(r,rt){
if(r.message == 'No'){
n = createLocal("Maintenance Visit");
$c('dt_map', args={
'docs':compress_doclist([locals["Maintenance Visit"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Maintenance Visit',
'from_docname':doc.name,
'from_to_list':"[['Sales Order', 'Maintenance Visit'], ['Sales Order Detail', 'Maintenance Visit Detail']]"
}
, function(r,rt) {
loaddoc("Maintenance Visit", n);
}
);
}
else{
msgprint("You have already completed maintenance against this Sales Order");
}
}
);
}
}
// make indent
// ================================================================================================
cur_frm.cscript['Make Indent'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
n = createLocal("Indent");
$c('dt_map', args={
'docs':compress_doclist([locals["Indent"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Indent',
'from_docname':doc.name,
'from_to_list':"[['Sales Order', 'Indent'], ['Sales Order Detail', 'Indent Detail']]"
}
, function(r,rt) {
loaddoc("Indent", n);
}
);
}
}
// MAKE DELIVERY NOTE
// ================================================================================================
cur_frm.cscript['Make Delivery Note'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
n = createLocal("Delivery Note");
$c('dt_map', args={
'docs':compress_doclist([locals["Delivery Note"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Delivery Note',
'from_docname':doc.name,
'from_to_list':"[['Sales Order', 'Delivery Note'], ['Sales Order Detail', 'Delivery Note Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
}
, function(r,rt) {
loaddoc("Delivery Note", n);
}
);
}
}
// MAKE SALES INVOICE
// ================================================================================================
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc;
n = createLocal('Receivable Voucher');
$c('dt_map', args={
'docs':compress_doclist([locals['Receivable Voucher'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Receivable Voucher',
'from_docname':doc.name,
'from_to_list':"[['Sales Order','Receivable Voucher'],['Sales Order Detail','RV Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team']]"
}, function(r,rt) {
loaddoc('Receivable Voucher', n);
}
);
}
// STOP SALES ORDER
// ==================================================================================================
cur_frm.cscript['Stop Sales Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Are you sure you want to STOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'stop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
// UNSTOP SALES ORDER
// ==================================================================================================
cur_frm.cscript['Unstop Sales Order'] = function() {
var doc = cur_frm.doc;
var check = confirm("Are you sure you want to UNSTOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'unstop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
//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';
}

View File

@@ -0,0 +1,487 @@
# 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
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.tname = 'Sales Order Detail'
self.fname = 'sales_order_details'
self.person_tname = 'Target Detail'
self.partner_tname = 'Partner Target Detail'
self.territory_tname = 'Territory Target Detail'
# Autoname
# ===============
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# DOCTYPE TRIGGER FUNCTIONS
# =============================
# Pull Quotation Details
# -----------------------
def pull_quotation_details(self):
self.doc.clear_table(self.doclist, 'other_charges')
self.doc.clear_table(self.doclist, 'sales_order_details')
self.doc.clear_table(self.doclist, 'sales_team')
self.doc.clear_table(self.doclist, 'tc_details')
if self.doc.quotation_no:
get_obj('DocType Mapper', 'Quotation-Sales Order').dt_map('Quotation', 'Sales Order', self.doc.quotation_no, self.doc, self.doclist, "[['Quotation', 'Sales Order'],['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'],['Sales Team','Sales Team'],['TC Detail','TC Detail']]")
else:
msgprint("Please select Quotation whose details need to pull")
return cstr(self.doc.quotation_no)
#pull project customer
#-------------------------
def pull_project_customer(self):
res = sql("select customer from `tabProject` where name = '%s'"%self.doc.project_name)
if res:
get_obj('DocType Mapper', 'Project-Sales Order').dt_map('Project', 'Sales Order', self.doc.project_name, self.doc, self.doclist, "[['Project', 'Sales Order']]")
# Get Customer Details
# ---------------------
#def get_customer_details(self):
# sales_com_obj = get_obj('Sales Common')
# sales_com_obj.get_customer_details(self)
# sales_com_obj.get_shipping_details(self)
# Get contact person details based on customer selected
# ------------------------------------------------------
def get_contact_details(self):
get_obj('Sales Common').get_contact_details(self,0)
# Get Commission rate of Sales Partner
# -------------------------------------
def get_comm_rate(self, sales_partner):
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
# Clear Sales Order Details Table
# --------------------------------
def clear_sales_order_details(self):
self.doc.clear_table(self.doclist, 'sales_order_details')
# SALES ORDER DETAILS TRIGGER FUNCTIONS
# ================================================================================
# Get Item Details
# ----------------
def get_item_details(self, item_code):
return get_obj('Sales Common').get_item_details(item_code, self)
# Re-calculates Basic Rate & amount based on Price List Selected
# --------------------------------------------------------------
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
# Get projected qty of item based on warehouse selected
# -----------------------------------------------------
def get_available_qty(self,args):
args = eval(args)
tot_avail_qty = sql("select projected_qty, actual_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (args['item_code'], args['warehouse']), as_dict=1)
ret = {
'projected_qty' : tot_avail_qty and flt(tot_avail_qty[0]['projected_qty']) or 0,
'actual_qty' : tot_avail_qty and flt(tot_avail_qty[0]['actual_qty']) or 0
}
return cstr(ret)
# OTHER CHARGES TRIGGER FUNCTIONS
# ====================================================================================
# Get Tax rate if account type is TAX
# ------------------------------------
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
# Load Default Charges
# ----------------------------------------------------------
def load_default_taxes(self):
return get_obj('Sales Common').load_default_taxes(self)
# Pull details from other charges master (Get Other Charges)
# ----------------------------------------------------------
def get_other_charges(self):
return get_obj('Sales Common').get_other_charges(self)
# GET TERMS & CONDITIONS
# =====================================================================================
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
#check if maintenance schedule already generated
#============================================
def check_maintenance_schedule(self):
nm = sql("select t1.name from `tabMaintenance Schedule` t1, `tabItem Maintenance Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1", self.doc.name)
nm = nm and nm[0][0] or ''
if not nm:
return cstr('No')
#check if maintenance visit already generated
#============================================
def check_maintenance_visit(self):
nm = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1 and t1.completion_status='Fully Completed'", self.doc.name)
nm = nm and nm[0][0] or ''
if not nm:
return cstr('No')
# VALIDATE
# =====================================================================================
# Fiscal Year Validation
# ----------------------
def validate_fiscal_year(self):
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Sales Order Date')
# Validate values with reference document
#----------------------------------------
def validate_reference_value(self):
get_obj('DocType Mapper', 'Quotation-Sales Order', with_children = 1).validate_reference_value(self, self.doc.name)
# Validate Mandatory
# -------------------
def validate_mandatory(self):
# validate transaction date v/s delivery date
if self.doc.delivery_date:
if getdate(self.doc.transaction_date) > getdate(self.doc.delivery_date):
msgprint("Expected Delivery Date cannot be before Sales Order Date")
raise Exception
# Validate P.O Date
# ------------------
def validate_po_date(self):
# validate p.o date v/s delivery date
if self.doc.po_date and self.doc.delivery_date and getdate(self.doc.po_date) >= getdate(self.doc.delivery_date):
msgprint("Expected Delivery Date cannot be before Purchase Order Date")
raise Exception
# amendment date is necessary if document is amended
if self.doc.amended_from and not self.doc.amendment_date:
msgprint("Please Enter Amendment Date")
raise Exception
# Validations of Details Table
# -----------------------------
def validate_for_items(self):
check_list,flag = [],0
chk_dupl_itm = []
# Sales Order Details Validations
for d in getlist(self.doclist, 'sales_order_details'):
if cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname):
flag = 1
if d.prevdoc_docname:
if self.doc.quotation_date and getdate(self.doc.quotation_date) > getdate(self.doc.transaction_date):
msgprint("Sales Order Date cannot be before Quotation Date")
raise Exception
# validates whether quotation no in doctype and in table is same
if not cstr(d.prevdoc_docname) == cstr(self.doc.quotation_no):
msgprint("Items in table does not belong to the Quotation No mentioned.")
raise Exception
# validates whether item is not entered twice
e = [d.item_code, d.description, d.reserved_warehouse, d.prevdoc_docname or '']
f = [d.item_code, d.description]
#check item is stock item
st_itm = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if st_itm and st_itm[0][0] == 'Yes':
if e in check_list:
msgprint("Item %s has been entered twice." % d.item_code)
else:
check_list.append(e)
elif st_itm and st_itm[0][0]== 'No':
if f in chk_dupl_itm:
msgprint("Item %s has been entered twice." % d.item_code)
else:
chk_dupl_itm.append(f)
# used for production plan
d.transaction_date = self.doc.transaction_date
d.delivery_date = self.doc.delivery_date
# gets total projected qty of item in warehouse selected (this case arises when warehouse is selected b4 item)
tot_avail_qty = sql("select projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
if flag == 0:
msgprint("There are no items of the quotation selected.")
raise Exception
# validate sales/ service item against order type
#----------------------------------------------------
def validate_sales_mntc_item(self):
if self.doc.order_type == 'Maintenance':
item_field = 'is_service_item'
order_type = 'Maintenance Order'
item_type = 'service item'
else :
item_field = 'is_sales_item'
order_type = 'Sales Order'
item_type = 'sales item'
for d in getlist(self.doclist, 'sales_order_details'):
res = sql("select %s from `tabItem` where name='%s'"% (item_field,d.item_code))
res = res and res[0][0] or 'No'
if res == 'No':
msgprint("You can not select non "+item_type+" "+d.item_code+" in "+order_type)
raise Exception
# validate sales/ maintenance quotation against order type
#------------------------------------------------------------------
def validate_sales_mntc_quotation(self):
for d in getlist(self.doclist, 'sales_order_details'):
if d.prevdoc_docname:
res = sql("select order_type from `tabQuotation` where name=%s", (d.prevdoc_docname))
res = res and res[0][0] or ''
if self.doc.order_type== 'Maintenance' and res != 'Maintenance':
msgprint("You can not select non Maintenance Quotation against Maintenance Order")
raise Exception
elif self.doc.order_type != 'Maintenance' and res == 'Maintenance':
msgprint("You can not select non Sales Quotation against Sales Order")
raise Exception
#do not allow sales item/quotation in maintenance order and service item/quotation in sales order
#-----------------------------------------------------------------------------------------------
def validate_order_type(self):
#validate delivery date
if self.doc.order_type != 'Maintenance' and not self.doc.delivery_date:
msgprint("Please enter 'Expected Delivery Date'")
raise Exception
self.validate_sales_mntc_quotation()
self.validate_sales_mntc_item()
#check for does customer belong to same project as entered..
#-------------------------------------------------------------------------------------------------
def validate_proj_cust(self):
if self.doc.project_name and self.doc.customer_name:
res = sql("select name from `tabProject` where name = '%s' and (customer = '%s' or ifnull(customer,'')='')"%(self.doc.project_name, self.doc.customer))
if not res:
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.doc.customer,self.doc.project_name,self.doc.project_name))
raise Exception
# Validate
# ---------
def validate(self):
self.validate_fiscal_year()
self.validate_order_type()
self.validate_mandatory()
self.validate_proj_cust()
self.validate_po_date()
#self.validate_reference_value()
self.validate_for_items()
sales_com_obj = get_obj(dt = 'Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.check_conversion_rate(self)
# verify whether rate is not greater than max_discount
sales_com_obj.validate_max_discount(self,'sales_order_details')
# this is to verify that the allocated % of sales persons is 100%
sales_com_obj.get_allocated_sum(self)
sales_com_obj.make_packing_list(self,'sales_order_details')
# get total in words
self.doc.in_words = sales_com_obj.get_total_in_words(get_defaults()['currency'], self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
# set SO status
self.doc.status='Draft'
if not self.doc.billing_status: self.doc.billing_status = 'Not Billed'
if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered'
# ON SUBMIT
# ===============================================================================================
# Checks Quotation Status
# ------------------------
def check_prev_docstatus(self):
for d in getlist(self.doclist, 'sales_order_details'):
cancel_quo = sql("select name from `tabQuotation` where docstatus = 2 and name = '%s'" % d.prevdoc_docname)
if cancel_quo:
msgprint("Quotation :" + cstr(cancel_quo[0][0]) + " is already cancelled !")
raise Exception , "Validation Error. "
def update_enquiry_status(self, prevdoc, flag):
enq = sql("select t2.prevdoc_docname from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.name=%s", prevdoc)
if enq:
sql("update `tabEnquiry` set status = %s where name=%s",(flag,enq[0][0]))
#update status of quotation, enquiry
#----------------------------------------
def update_prevdoc_status(self, flag):
for d in getlist(self.doclist, 'sales_order_details'):
if d.prevdoc_docname:
if flag=='submit':
sql("update `tabQuotation` set status = 'Order Confirmed' where name=%s",d.prevdoc_docname)
#update enquiry
self.update_enquiry_status(d.prevdoc_docname, 'Order Confirmed')
elif flag == 'cancel':
chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Detail` t2 where t2.parent = t1.name and t2.prevdoc_docname=%s and t1.name!=%s and t1.docstatus=1", (d.prevdoc_docname,self.doc.name))
if not chk:
sql("update `tabQuotation` set status = 'Submitted' where name=%s",d.prevdoc_docname)
#update enquiry
self.update_enquiry_status(d.prevdoc_docname, 'Quotation Sent')
# Submit
# -------
def on_submit(self):
self.check_prev_docstatus()
self.update_stock_ledger(update_stock = 1)
self.set_sms_msg(1)
# update customer's last sales order no.
update_customer = sql("update `tabCustomer` set last_sales_order = '%s', modified = '%s' where name = '%s'" %(self.doc.name, self.doc.modified, self.doc.customer))
get_obj('Sales Common').check_credit(self,self.doc.grand_total)
# Check for Approving Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.grand_total, self)
#update prevdoc status
self.update_prevdoc_status('submit')
# set SO status
set(self.doc, 'status', 'Submitted')
# on submit notification
if self.doc.email_id:
get_obj('Notification Control').notify_contact('Sales Order',self.doc.doctype,self.doc.name, self.doc.email_id, self.doc.contact_person)
# ON CANCEL
# ===============================================================================================
def on_cancel(self):
# Cannot cancel stopped SO
if self.doc.status == 'Stopped':
msgprint("Sales Order : '%s' cannot be cancelled as it is Stopped. Unstop it for any further transactions" %(self.doc.name))
raise Exception
self.check_nextdoc_docstatus()
self.update_stock_ledger(update_stock = -1)
self.set_sms_msg()
#update prevdoc status
self.update_prevdoc_status('cancel')
# ::::::::: SET SO STATUS ::::::::::
set(self.doc, 'status', 'Cancelled')
# CHECK NEXT DOCSTATUS
# does not allow to cancel document if DN or RV made against it is SUBMITTED
# ----------------------------------------------------------------------------
def check_nextdoc_docstatus(self):
# Checks Delivery Note
submit_dn = sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Detail` t2 where t1.name = t2.parent and t2.prevdoc_docname = '%s' and t1.docstatus = 1" % (self.doc.name))
if submit_dn:
msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doc.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
# Checks Receivable Voucher
submit_rv = sql("select t1.name from `tabReceivable Voucher` t1,`tabRV Detail` t2 where t1.name = t2.parent and t2.sales_order = '%s' and t1.docstatus = 1" % (self.doc.name))
if submit_rv:
msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Sales Invoice : "+ cstr(submit_rv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
#check maintenance schedule
submit_ms = sql("select t1.name from `tabMaintenance Schedule` t1, `tabItem Maintenance Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name)
if submit_ms:
msgprint("Maintenance Schedule : " + cstr(submit_ms[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Schedule : "+ cstr(submit_ms[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
submit_mv = sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Detail` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.doc.name)
if submit_mv:
msgprint("Maintenance Visit : " + cstr(submit_mv[0][0]) + " has already been submitted against " +cstr(self.doc.doctype)+ ". Please cancel Maintenance Visit : " + cstr(submit_mv[0][0]) + " first and then cancel "+ cstr(self.doc.doctype), raise_exception = 1)
def check_modified_date(self):
mod_db = sql("select modified from `tabSales Order` where name = '%s'" % self.doc.name)
date_diff = sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
raise Exception
# STOP SALES ORDER
# ==============================================================================================
# Stops Sales Order & no more transactions will be created against this Sales Order
def stop_sales_order(self):
self.check_modified_date()
self.update_stock_ledger(update_stock = -1,clear = 1)
# ::::::::: SET SO STATUS ::::::::::
set(self.doc, 'status', 'Stopped')
msgprint(self.doc.doctype + ": " + self.doc.name + " has been Stopped. To make transactions against this Sales Order you need to Unstop it.")
# UNSTOP SALES ORDER
# ==============================================================================================
# Unstops Sales Order & now transactions can be continued against this Sales Order
def unstop_sales_order(self):
self.check_modified_date()
self.update_stock_ledger(update_stock = 1,clear = 1)
# ::::::::: SET SO STATUS ::::::::::
set(self.doc, 'status', 'Submitted')
msgprint(self.doc.doctype + ": " + self.doc.name + " has been Unstopped.")
# UPDATE STOCK LEDGER
# ===============================================================================================
def update_stock_ledger(self, update_stock, clear = 0):
for d in self.get_item_list(clear):
stock_item = sql("SELECT is_stock_item FROM tabItem where name = '%s'"%(d[1]),as_dict = 1) # stock ledger will be updated only if it is a stock item
if stock_item and stock_item[0]['is_stock_item'] == "Yes":
if not d[0]:
msgprint("Message: Please enter Reserved Warehouse for item %s as it is stock item."% d[1])
raise Exception
bin = get_obj('Warehouse', d[0]).update_bin( 0, flt(update_stock) * flt(d[2]), 0, 0, 0, d[1], self.doc.transaction_date)
# Gets Items from packing list
#=================================
def get_item_list(self, clear):
return get_obj('Sales Common').get_item_list( self, clear)
# SET MESSAGE FOR SMS
#======================
def set_sms_msg(self, is_submitted = 0):
if is_submitted:
if not self.doc.amended_from:
msg = 'Sales Order: '+self.doc.name+' has been made against PO no: '+cstr(self.doc.po_no)
set(self.doc, 'message', msg)
else:
msg = 'Sales Order has been amended. New SO no:'+self.doc.name
set(self.doc, 'message', msg)
else:
msg = 'Sales Order: '+self.doc.name+' has been cancelled.'
set(self.doc, 'message', msg)
# SEND SMS
# =========
def send_sms(self):
if not self.doc.customer_mobile_no:
msgprint("Please enter customer mobile no")
elif not self.doc.message:
msgprint("Please enter the message you want to send")
else:
msgprint(get_obj("SMS Control", "SMS Control").send_sms([self.doc.customer_mobile_no,], self.doc.message))
# on update
def on_update(self):
pass
# Repair Sales Order
# ===========================================
def repair_sales_order(self):
get_obj('Sales Common', 'Sales Common').repair_curr_doctype_details(self)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

File diff suppressed because one or more lines are too long

View File

View File

@@ -0,0 +1,2 @@
cur_frm.add_fetch('customer','customer_name','customer_name');cur_frm.add_fetch('customer','address','customer_address');

View File

@@ -0,0 +1,4 @@
// Get Customer Details
// =====================================================================
cur_frm.add_fetch('customer','customer_name','customer_name');
cur_frm.add_fetch('customer','address','customer_address');

View File

@@ -0,0 +1,25 @@
import webnotes
sql = webnotes.conn.sql
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
# on update
# ----------
def on_update(self):
self.update_primary_shipping_address()
self.get_customer_details()
# set is_primary_address for other shipping addresses belonging to same customer
# -------------------------------------------------------------------------------
def update_primary_shipping_address(self):
if self.doc.is_primary_address == 'Yes':
sql("update `tabShipping Address` set is_primary_address = 'No' where customer = %s and is_primary_address = 'Yes' and name != %s",(self.doc.customer, self.doc.name))
# Get Customer Details
# ---------------------
def get_customer_details(self):
det = sql("select customer_name, address from tabCustomer where name = '%s'" % (self.doc.customer))
self.doc.customer_name = det and det[0][0] or ''
self.doc.customer_address = det and det[0][1] or ''

View File

@@ -0,0 +1,406 @@
[
{
'_last_update': None,
'allow_attach': None,
'allow_copy': None,
'allow_email': None,
'allow_print': None,
'allow_rename': None,
'allow_trash': 1,
'autoname': 'SA.#####',
'change_log': None,
'client_script': None,
'client_script_core': None,
'client_string': None,
'colour': 'White:FFF',
'creation': '2011-05-09 11:01:06',
'description': None,
'docstatus': 0,
'doctype': 'DocType',
'document_type': 'Master',
'dt_template': None,
'hide_heading': None,
'hide_toolbar': None,
'idx': None,
'in_create': None,
'in_dialog': None,
'is_transaction_doc': None,
'issingle': None,
'istable': None,
'max_attachments': None,
'menu_index': None,
'modified': '2011-03-24 10:39:09',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'Shipping Address',
'name_case': None,
'owner': 'Administrator',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'print_outline': None,
'read_only': None,
'read_only_onload': None,
'search_fields': 'customer, ship_to, shipping_address',
'section_style': 'Simple',
'server_code': None,
'server_code_compiled': None,
'server_code_core': None,
'server_code_error': None,
'show_in_menu': 0,
'smallicon': None,
'use_template': None,
'version': 8
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Column Break',
'hidden': None,
'icon': None,
'idx': 1,
'in_filter': None,
'label': None,
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000259',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': '50%'
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'customer',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 2,
'in_filter': None,
'label': 'Customer',
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000260',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'Customer',
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'customer_name',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 3,
'in_filter': None,
'label': 'Customer Name',
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000261',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'customer_address',
'fieldtype': 'Text',
'hidden': None,
'icon': None,
'idx': 4,
'in_filter': None,
'label': 'Customer Address',
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000262',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'ship_to',
'fieldtype': 'Data',
'hidden': None,
'icon': None,
'idx': 5,
'in_filter': None,
'label': 'Ship To',
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000263',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:06',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'shipping_address',
'fieldtype': 'Text',
'hidden': None,
'icon': None,
'idx': 6,
'in_filter': None,
'label': 'Shipping Address',
'modified': '2011-05-09 11:01:06',
'modified_by': 'Administrator',
'name': '000000264',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Column Break',
'hidden': None,
'icon': None,
'idx': 7,
'in_filter': None,
'label': None,
'modified': '2011-05-09 11:01:07',
'modified_by': 'Administrator',
'name': '000000265',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': '50%'
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'is_primary_address',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 8,
'in_filter': None,
'label': 'Is Primary Address',
'modified': '2011-05-09 11:01:07',
'modified_by': 'Administrator',
'name': '000000266',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'Yes\nNo',
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'shipping_details',
'fieldtype': 'Text Editor',
'hidden': None,
'icon': None,
'idx': 9,
'in_filter': None,
'label': 'Shipping Details',
'modified': '2011-05-09 11:01:07',
'modified_by': 'Administrator',
'name': '000000267',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-05-09 11:01:07',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'hidden': None,
'icon': None,
'idx': 10,
'in_filter': None,
'label': 'Trash Reason',
'modified': '2011-05-09 11:01:07',
'modified_by': 'Administrator',
'name': '000000268',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'Shipping Address',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 1,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
}
]

View File

View File

View File

@@ -0,0 +1,67 @@
# 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_list(self):
rec, where_clause = '', ''
if self.doc.send_to == 'All Customer Contact':
where_clause = self.doc.customer and " and customer = '%s'" % self.doc.customer or " and ifnull(is_customer, 0) = 1"
if self.doc.send_to == 'All Supplier Contact':
where_clause = self.doc.supplier and " and ifnull(is_supplier, 0) = 1 and supplier = '%s'" % self.doc.supplier or " and ifnull(is_supplier, 0) = 1"
if self.doc.send_to == 'All Sales Partner Contact':
where_clause = self.doc.sales_partner and " and ifnull(is_sales_partner, 0) = 1 and sales_aprtner = '%s'" % self.doc.sales_partner or " and ifnull(is_sales_partner, 0) = 1"
msgprint(1)
if self.doc.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']:
msgprint("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
rec = sql("select CONCAT(ifnull(first_name,''),'',ifnull(last_name,'')), mobile_no from `tabContact` where ifnull(mobile_no,'')!='' and docstatus != 2 %s" % where_clause)
elif self.doc.send_to == 'All Lead (Open)':
rec = sql("select lead_name, mobile_no from tabLead where ifnull(mobile_no,'')!='' and docstatus != 2 and status = 'Open'")
elif self.doc.send_to == 'All Employee (Active)':
where_clause = self.doc.department and " and t1.department = '%s'" % self.doc.department or ""
where_clause += self.doc.branch and " and t1.branch = '%s'" % self.doc.branch or ""
rec = sql("select t1.employee_name, t2.cell_number from `tabEmployee` t1, `tabEmployee Profile` t2 where t2.employee = t1.name and t1.status = 'Active' and t1.docstatus != 2 and ifnull(t2.cell_number,'')!='' %s" % where_clause)
elif self.doc.send_to == 'All Sales Person':
rec = sql("select sales_person_name, mobile_no from `tabSales Person` where docstatus != 2 and ifnull(mobile_no,'')!=''")
rec_list = ''
for d in rec:
rec_list += d[0] + ' - ' + d[1] + '\n'
self.doc.receiver_list = rec_list
def get_receiver_nos(self):
receiver_nos = []
for d in self.doc.receiver_list.split('\n'):
receiver_no = d
if '-' in d:
receiver_no = receiver_no.split('-')[1]
if receiver_no.strip():
receiver_nos.append(cstr(receiver_no).strip())
return receiver_nos
def send_sms(self):
if not self.doc.message:
msgprint("Please enter message before sending")
else:
receiver_list = self.get_receiver_nos()
if receiver_list:
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, cstr(self.doc.message)))

View File

@@ -0,0 +1,486 @@
[
{
'allow_attach': 0,
'allow_copy': 1,
'allow_email': 1,
'allow_print': 1,
'allow_rename': None,
'allow_trash': None,
'autoname': None,
'change_log': None,
'client_script': None,
'client_script_core': None,
'client_string': None,
'colour': 'White:FFF',
'creation': '2010-08-08 17:09:24',
'description': None,
'docstatus': 0,
'doctype': 'DocType',
'document_type': None,
'dt_template': None,
'hide_heading': 0,
'hide_toolbar': 0,
'idx': None,
'in_create': 0,
'in_dialog': None,
'is_transaction_doc': None,
'issingle': 1,
'istable': None,
'max_attachments': None,
'menu_index': 4,
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'SMS Center',
'name_case': None,
'owner': 'Administrator',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'print_outline': None,
'read_only': 1,
'read_only_onload': None,
'search_fields': None,
'section_style': 'Simple',
'server_code': None,
'server_code_compiled': None,
'server_code_core': None,
'server_code_error': ' ',
'show_in_menu': 1,
'smallicon': None,
'use_template': None,
'version': 36
},
{
'amend': None,
'cancel': None,
'create': 1,
'creation': '2010-08-08 17:09:24',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': 1,
'match': None,
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'PERM00532',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 0,
'read': 1,
'role': 'Administrator',
'submit': None,
'write': 1
},
{
'amend': None,
'cancel': None,
'create': 0,
'creation': '2010-08-08 17:09:24',
'docstatus': 0,
'doctype': 'DocPerm',
'execute': None,
'idx': 2,
'match': None,
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'PERM00533',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'permissions',
'parenttype': 'DocType',
'permlevel': 1,
'read': 1,
'role': 'Administrator',
'submit': None,
'write': 0
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-02-15 16:59:29',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'column_break1',
'fieldtype': 'Column Break',
'hidden': None,
'icon': None,
'idx': 1,
'in_filter': None,
'label': None,
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04772',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': '50%'
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:24',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'send_to',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 2,
'in_filter': None,
'label': 'Send To',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL03352',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': '\nAll Contact\nAll Customer Contact\nAll Supplier Contact\nAll Sales Partner Contact\nAll Lead (Open)\nAll Employee (Active)\nAll Sales Person',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': 'Client',
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2010-08-08 17:09:24',
'default': None,
'depends_on': "eval:doc.send_to=='All Customer Contact'",
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'customer',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 3,
'in_filter': None,
'label': 'Customer',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL03353',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'Customer',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2011-01-11 15:10:58',
'default': None,
'depends_on': "eval:doc.send_to=='All Supplier Contact'",
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'supplier',
'fieldtype': 'Link',
'hidden': None,
'icon': None,
'idx': 4,
'in_filter': None,
'label': 'Supplier',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04407',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'Supplier',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2011-01-11 15:10:58',
'default': None,
'depends_on': "eval:doc.send_to=='All Employee (Active)'",
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'department',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 5,
'in_filter': None,
'label': 'Department',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04409',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'link:Department',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': 'White:FFF',
'creation': '2011-01-11 15:10:58',
'default': None,
'depends_on': "eval:doc.send_to=='All Employee (Active)'",
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'branch',
'fieldtype': 'Select',
'hidden': None,
'icon': None,
'idx': 6,
'in_filter': None,
'label': 'Branch',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04408',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'link:Branch',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-01-11 16:55:50',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Button',
'hidden': None,
'icon': None,
'idx': 7,
'in_filter': None,
'label': 'Create Receiver List',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04411',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'create_receiver_list',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:24',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'receiver_list',
'fieldtype': 'Code',
'hidden': None,
'icon': None,
'idx': 8,
'in_filter': None,
'label': 'Receiver List',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL03359',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2011-02-15 16:59:29',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'column_break2',
'fieldtype': 'Column Break',
'hidden': None,
'icon': None,
'idx': 9,
'in_filter': None,
'label': None,
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL04773',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': '50%'
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:24',
'default': None,
'depends_on': None,
'description': 'Message greater than 160 character will be splitted into multiple mesage',
'docstatus': 0,
'doctype': 'DocField',
'fieldname': 'message',
'fieldtype': 'Text',
'hidden': None,
'icon': None,
'idx': 10,
'in_filter': None,
'label': 'Message',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL03354',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': None,
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': 1,
'search_index': None,
'trigger': None,
'width': None
},
{
'allow_on_submit': None,
'colour': None,
'creation': '2010-08-08 17:09:24',
'default': None,
'depends_on': None,
'description': None,
'docstatus': 0,
'doctype': 'DocField',
'fieldname': None,
'fieldtype': 'Button',
'hidden': None,
'icon': None,
'idx': 11,
'in_filter': None,
'label': 'Send SMS',
'modified': '2011-02-15 17:06:33',
'modified_by': 'Administrator',
'name': 'FL03357',
'no_copy': None,
'oldfieldname': None,
'oldfieldtype': None,
'options': 'send_sms',
'owner': 'Administrator',
'parent': 'SMS Center',
'parentfield': 'fields',
'parenttype': 'DocType',
'permlevel': 0,
'print_hide': None,
'report_hide': None,
'reqd': None,
'search_index': None,
'trigger': None,
'width': None
}
]

0
crm/page/__init__.py Normal file
View File

View File

View File

@@ -0,0 +1,3 @@
pscript.onload_customers=function(){make_customer_tab($i('dcv_customers'));}
function make_customer_tab(parent){pscript.dcv_customers=new wn.widgets.DocColumnView('Customers',parent,['Customer Group','Customer','Contact'],{'Customer Group':{show_fields:['name'],create_fields:['name'],search_fields:['name'],next_col:'Customer'},'Customer':{show_fields:['name','customer_name'],create_fields:['name','customer_name'],search_fields:['customer_name'],filter_by:['Customer Group','customer_group'],next_col:'Contact'},'Contact':{show_fields:['name','first_name','last_name'],create_fields:['name','first_name','last_name'],search_fields:['first_name','last_name'],conditions:['is_customer=1'],set_values:{'is_customer':1},filter_by:['Customer','customer']},})}

View File

@@ -0,0 +1 @@
<div id="dcv_customers"></div>

View File

@@ -0,0 +1,34 @@
//make tabs
pscript.onload_customers = function() {
make_customer_tab($i('dcv_customers'));
}
function make_customer_tab(parent) {
pscript.dcv_customers = new wn.widgets.DocColumnView('Customers', parent,
['Customer Group', 'Customer', 'Contact'], {
'Customer Group': {
show_fields : ['name'],
create_fields : ['name'],
search_fields : ['name'],
next_col: 'Customer'
},
'Customer': {
show_fields : ['name', 'customer_name'],
create_fields : ['name', 'customer_name'],
search_fields : ['customer_name'],
filter_by : ['Customer Group', 'customer_group'],
next_col: 'Contact'
},
'Contact': {
show_fields : ['name', 'first_name', 'last_name'],
create_fields : ['name','first_name', 'last_name'],
search_fields : ['first_name', 'last_name'],
conditions: ['is_customer=1'],
set_values: {'is_customer': 1 },
filter_by : ['Customer', 'customer']
},
})
}

View File

@@ -0,0 +1,26 @@
[
{
'content': None,
'creation': '2011-03-25 13:48:50',
'docstatus': 0,
'doctype': 'Page',
'icon': None,
'idx': None,
'menu_index': None,
'modified': '2011-03-25 13:48:50',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'customers',
'owner': 'Administrator',
'page_name': 'Customers',
'parent': None,
'parent_node': None,
'parentfield': None,
'parenttype': None,
'script': None,
'show_in_menu': None,
'standard': 'Yes',
'static_content': None,
'style': None
}
]

View File

View File

@@ -0,0 +1,4 @@
<div class="layout_wrapper">
<div id="tr_header"></div>
<div id="tr_body" style="margin: 16px"></div>
</div>

View File

@@ -0,0 +1,421 @@
pscript['onload_Sales Browser'] = function(){
var parent = $i('tr_body');
parent.innerHTML = 'Please select your chart: '
var sel = $a(parent,'select');
add_sel_options(sel, ['Territory', 'Customer Group', 'Item Group', 'Sales Person'], 'Territory');
var btn = $btn(parent, 'Go', function() { new SalesBrowser().set_val(sel_val(sel)) }, {marginTop:'8px'});
}
//================================= SalesBrowser Class ======================================
SalesBrowser = function(){
this.make_body = function(){
$i('tr_header').innerHTML = '';
$i('tr_body').innerHTML = '';
//make header
var desc = this.sel;
var me = this;
var h = new PageHeader($i('tr_header'),desc);
h.add_button('New '+this.sel, function() { me.set_dialog(1); }, 0, 'ui-icon-plus', 1);
h.add_button('Refresh', function() { me.refresh_tree(); }, 0, 'ui-icon-refresh');
var div_body = $a($i('tr_body'),'div');
var tr_main_grid = make_table(div_body,1,2,'100%',['60%','40%'],{width: "100%", tableLayout: "fixed", borderCollapse: "collapse", border:"0px", padding:"4px 4px 4px 4px"});
$y($td(tr_main_grid,0,0),{border: "1px solid #dddddd", padding: "8px", width: "60%"});
this.tree_area = $a($td(tr_main_grid,0,0),'div');
$y($td(tr_main_grid,0,1),{border: "1px solid #DDD"});
this.detail_area = $a($td(tr_main_grid,0,1),'div');
this.make_tree_body(this.tree_area);
this.refresh_tree();
}
this.set_val = function(b){
var me = this;
me.sel = b;
me.make_body();
}
}
//=================================================================================================================================
SalesBrowser.prototype.make_tree_body = function(parent){
//this.tab2 =make_table(this.wrapper,1,2,'100%',['60%','40%']);
this.make_tree();
this.make_rgt_sect();
}
//=================================================================================================================================
SalesBrowser.prototype.make_rgt_sect=function(){
//var d = $a($td(this.tab2,0,1),'div','',{border:'1px solid #000'});
this.rgt_tab =make_table(this.detail_area,4,1,'','',{padding:"4px",spacing:"4px"});
this.dtl = $a($td(this.rgt_tab,0,0),'div');
this.btn = $a($td(this.rgt_tab,1,0),'div','span');
this.help = $a($td(this.rgt_tab,2,0),'div');
this.help.innerHTML = "Note: Explore and click on the tree node to see details."
this.set_btn();
}
//=================================================================================================================================
SalesBrowser.prototype.set_btn = function(){
var me = this;
this.edit_btn = $btn(this.btn,'Edit',function(){ me.set_dialog(2); });
this.trash_btn = $btn(this.btn,'Trash',null);
this.trash_btn.onclick = function(){
var check = confirm("Are you sure you want to trash "+me.cur_node.rec.name+" node?");
if(check){
var arg = [me.cur_node.rec.name, me.sel];
$c_obj('Sales Browser Control','trash_record',arg.join(','),function(r,rt){ me.refresh_tree();});
}
}
}
//=====================================================
SalesBrowser.prototype.set_dialog = function(f){
if(this.sel == 'Territory')
new MakeDialog('Territory','territory',f,this); //Territory Dialog
if(this.sel == 'Customer Group')
new MakeDialog('Customer Group','customer_group',f,this); //Customer Group Dialog
if(this.sel == 'Item Group')
new MakeDialog('Item Group','item_group',f,this); //Item Group Dialog
if(this.sel == 'Sales Person')
new MakeDialog('Sales Person','sales_person',f,this);//Sales Person Dialog
}
//=====================================================Make Tree============================================================================
SalesBrowser.prototype.make_tree = function() {
var me = this;
this.tree = new Tree(this.tree_area, '100%');
//---------------------------------------------------------------------------------------------------------------------------------
// on click
this.tree.std_onclick = function(node) {
me.cur_node = node;
if(node.rec.name =='All Customer Groups' || node.rec.name =='All Sales Persons' || node.rec.name =='All Item Groups' || node.rec.name =='All Territories'){
//$di(me.add_btn);
$dh(me.edit_btn);
$dh(me.trash_btn);
}
else{
//$di(me.add_btn);
//if(node.has_children == false)
//$dh(me.add_btn);
$di(me.edit_btn);
$di(me.trash_btn);
}
me.make_details();
}
//---------------------------------------------------------------------------------------------------------------------------------
// on expand
this.tree.std_onexp = function(node) {
if(node.expanded_once)return;
$di(node.loading_div);
var callback = function(r,rt) {
$dh(node.loading_div);
var n = me.tree.allnodes[r.message.parent];
var cl = r.message.cl;
for(var i=0;i<cl.length;i++) {
var imgsrc=null;
var has_children = true;
if(cl[i].is_group=='No') {
var imgsrc = 'images/icons/page.gif';
has_children = false;
}
var t = me.tree.addNode(n, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
t.rec = cl[i];
t.parent_account = r.message.parent;
t.has_children = has_children;
}
}
var arg = [node.rec.name, me.sel];
$c_obj('Sales Browser Control','get_record_list',arg.join(','),callback);
}
}
//=================================================================================================================================
SalesBrowser.prototype.make_details = function(){
var me = this;
var callback = function(r,rt){
me.dtl.innerHTML = "";
//me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse'})
var h = $a(me.dtl,'h3','',{padding:'4px', margin:'0px',backgroundColor:'#EEEEEE',borderBottom:'1px solid #AAAAAA'});
$(h).html(r.message.name);
var d = $a(me.dtl,'div');
me.dtl_tab = make_table(me.dtl,3,2,'','',{tableLayout:'fixed',borderCollapse: 'collapse',padding:'4px'})
$td(me.dtl_tab,0,0).innerHTML="Parent";
if(r.message.parent != '')
$td(me.dtl_tab,0,1).innerHTML=": "+r.message.parent;
else
$td(me.dtl_tab,0,1).innerHTML=": ----";
$td(me.dtl_tab,1,0).innerHTML="Has Child Node";
$td(me.dtl_tab,1,1).innerHTML=": "+r.message.is_group;
me.open_doc = $a(me.dtl,'div','link_type',{paddingTop:'14px'});
me.open_doc.innerHTML = "Click here to open "+r.message.name;
me.open_doc.onclick = function(){
loaddoc(me.sel,r.message.name );
}
}
var arg = [this.cur_node.rec.name, this.sel];
$c_obj('Sales Browser Control','get_record',arg.join(','),callback);
}
//=================================================================================================================================
SalesBrowser.prototype.refresh_tree=function(){
this.tree_area.innerHTML = '';
this.dtl.innerHTML = '';
this.first_level_node(); //set root
//hide add, edit, trash buttons
//$dh(this.add_btn);
$dh(this.edit_btn);
$dh(this.trash_btn);
}
//=============================== make first level node ================================================
SalesBrowser.prototype.first_level_node = function(){
var me = this;
var callback = function(r,rt) {
var cl = r.message.cl;
for(var i=0;i<cl.length;i++) {
var imgsrc=null;
var has_children = true;
if(cl[i].is_group=='No') {
var imgsrc = 'images/icons/page.gif';
has_children = false;
}
me.tree_area.innerHTML = '';
if(me.tree) {
me.tree.innerHTML = '';
me.tree.body.innerHTML = '';
me.make_tree();
}
var t = me.tree.addNode(null, cl[i].name, imgsrc,me.tree.std_onclick, has_children ? me.tree.std_onexp : null);
t.rec ={};
t.rec.name = cl[i].name;
t.has_children = has_children;
}
}
$c_obj('Sales Browser Control','get_fl_node',this.sel,callback);
}
//========================================= Dialog Section ===================================================================
//--------------------------------------------------------------------------------------------------------------------------------
//========================================================================
MakeDialog=function(label,field_name,n,cls_obj){
var new_head = 'Create A New '+label;
this.label = label;
this.lbl_rec = label+' Name';
this.field_name = field_name;
this.n = n;
this.cls_obj=cls_obj;
//-----------------------------------------------
this.main_dialog = new Dialog(400,300,new_head);
this.set_dg_fields();
this.set_dg_values();
//-----------------------------------------------
this.new_main_dialog = this.main_dialog;
this.new_main_dialog.show();
}
//=================================================================================================================================
MakeDialog.prototype.set_dg_fields = function(){
var bd_lst = [];
bd_lst.push(['HTML','Heading'],['Data',this.lbl_rec],['Select','Parent'],['Select','Has Child Node']);
if(this.cls_obj.sel == 'Sales Person')
bd_lst.push(['HTML','','All nodes are allowed in transaction.']);
else
bd_lst.push(['HTML','','Only leaf nodes are allowed in transaction.']);
if(this.n==1)
bd_lst.push(['Button','Create']);
if(this.n==2){
bd_lst.push(['Button','Update']);
this.set_edit_fields();
}
this.main_dialog.make_body(bd_lst);
//-----------------------------------------------
}
//====================================================================================================================================
MakeDialog.prototype.set_edit_fields=function(){
var me = this;
var callback = function(r,rt){
me.main_dialog.widgets[me.lbl_rec].value = r.message.name;
add_sel_options(me.main_dialog.widgets['Parent'], r.message.parent_lst,r.message.parent);
me.main_dialog.widgets['Has Child Node'].value = r.message.is_group;
}
var arg = [this.cls_obj.cur_node.rec.name, this.cls_obj.sel];
$c_obj('Sales Browser Control','get_record',arg.join(','),callback);
}
//======================================= Validation - fields entered or not =================================================
MakeDialog.prototype.validate = function(){
if(!this.main_dialog.widgets[this.lbl_rec].value) {
err_msg1 ='Please enter '+this.label +' Name'
alert(err_msg1);
return 1;
}
if(!this.main_dialog.widgets['Parent'].value){
alert('Please enter Parent Name' );
return 1;
}
}
//====================================================================================================================================
MakeDialog.prototype.set_dg_values = function(){
if(this.n==1){
var me = this;
var callback = function(r,rt){
me.main_dialog.widgets[me.lbl_rec].disabled = 0;
me.main_dialog.widgets['Parent'].disabled = 0;
add_sel_options(me.main_dialog.widgets['Parent'],r.message);
//add_sel_options(this.main_dialog.widgets['Parent'], [this.cls_obj.cur_node.rec.name]);
me.btn_onclick('Create',me.cls_obj);
}
$c_obj('Sales Browser Control','get_parent_lst',this.cls_obj.sel,callback);
}
if(this.n == 2){
this.main_dialog.widgets[this.lbl_rec].disabled = 1;
this.main_dialog.widgets['Parent'].disabled = 0;
this.btn_onclick('Update');
this.old_value = sel_val(this.main_dialog.widgets['Parent']);
}
add_sel_options(this.main_dialog.widgets['Has Child Node'], ['Yes','No'], 'No');
}
//=================================================================================================================================
//-----------------------------------------Dialog button onclick event----------------------------------------------
MakeDialog.prototype.btn_onclick=function(btn_name){
var me = this;
this.btn_name = btn_name;
this.main_dialog.widgets[this.btn_name].onclick = function() {
var callback=function(r,rt){
if(r.message == 'true'){
me.main_dialog.hide();
}
else{
flag = me.validate();
if(flag == 1) return;
//---------------------------------------------------------
var arg2 = me.make_args();
//create Sales Person -- server to Sales Browser Control
if(me.btn_name == "Create")
method_name = "add_node";
else
method_name = "edit_node";
$c_obj('Sales Browser Control',method_name, docstring(arg2), function(r,rt) {
me.main_dialog.widgets[me.lbl_rec].value='';
me.main_dialog.hide();
/*if(me.btn_name == "Create"){
me.cls_obj.cur_node.clear_child_nodes();
me.cls_obj.dtl.innerHTML = '';
me.cls_obj.cur_node.expand();
}
else{
me.cls_obj.refresh_tree();
}*/
me.cls_obj.refresh_tree();
});
}
}
var arg1 = {'node_title':me.cls_obj.sel,'is_group':sel_val(me.main_dialog.widgets['Has Child Node']),'lft':0,'rgt':0,'nm':me.main_dialog.widgets[me.lbl_rec].value,'parent_nm':sel_val(me.main_dialog.widgets['Parent']),'action':me.btn_name};
$c_obj('Sales Browser Control','mvalidate',docstring(arg1),callback);
}
}
//=================================================================================================================================
MakeDialog.prototype.make_args = function(){
var args ={}; //args making
var nt = this.cls_obj.sel;
var nm = this.main_dialog.widgets[this.lbl_rec].value;
var pnm = sel_val(this.main_dialog.widgets['Parent']);
var grp = sel_val(this.main_dialog.widgets['Has Child Node']);
if(this.n==1)
var old_prt ='';
else if(this.n==2){
if(this.old_value == sel_val(this.main_dialog.widgets['Parent']))
var old_prt = '';
else
var old_prt = this.old_value;
}
if(this.cls_obj.sel == 'Territory')
return {'node_title':nt,'territory_name':nm,'parent_territory':pnm,'is_group':grp,'old_parent':old_prt}
else if(this.cls_obj.sel == 'Customer Group')
return {'node_title':nt,'customer_group_name':nm,'parent_customer_group':pnm,'is_group':grp,'old_parent':old_prt}
else if(this.cls_obj.sel == 'Item Group')
return {'node_title':nt,'item_group_name':nm,'parent_item_group':pnm,'is_group':grp,'old_parent':old_prt}
else if(this.cls_obj.sel == 'Sales Person')
return {'node_title':nt,'sales_person_name':nm,'parent_sales_person':pnm,'is_group':grp,'old_parent':old_prt}
}

View File

@@ -0,0 +1 @@
[{'creation': '2010-06-16 11:44:38', 'module': 'CRM', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Browser', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Browser', 'idx': None, 'static_content': None, 'modified': '2010-11-10 19:21:50', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000140', 'parent': 'Sales Browser', 'creation': '2010-06-16 12:08:31', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Master Manager', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'Administrator', 'name': 'PR000149', 'parent': 'Sales Browser', 'creation': '2010-07-14 15:57:09', 'modified': '2010-11-10 19:21:50', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Material Master Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]

View File

View File

@@ -0,0 +1,6 @@
<div class="layout_wrapper">
<div id="pt_header"></div>
<div id="pt_filters"></div>
<p>&nbsp;</p>
<div id="plot_test"></div>
</div>

View File

@@ -0,0 +1,301 @@
pscript['onload_Sales Dashboard'] = function() {
var h = new PageHeader('pt_header','Sales Dashboard');
pscript.make_filters();
$dh(pscript.mnt_div);
$dh(pscript.mnt_div1);
//pscript.dx_axis = [];
if($.jqplot) pscript.all_onchnge();
else
// import the library
$c_js('jquery/jquery.jqplot.min.js', pscript.all_onchnge);
}
//=======================================================================
pscript.make_filters = function(){
this.tab = make_table('pt_filters', 2, 4, '800px', ['200px','200px','200px','200px'], {padding: '2px'});
pscript.fiscal_year();
pscript.report_type();
pscript.item_grp();
pscript.month_lst();
}
//=======================================================================
pscript.fiscal_year=function(){
var me = this;
$td(this.tab,0,0).innerHTML = "Select Year";
this.sel_fy = $a($td(this.tab,1,0), 'select', null, {width:'120px'});
$c_obj('Plot Control', 'get_fiscal_year', '', function(r,rt){
if(r.message) fy_lst = r.message;
else fy_lst = [];
empty_select(me.sel_fy);
add_sel_options(me.sel_fy,fy_lst);
me.sel_fy.value = sys_defaults.fiscal_year;
});
}
//=======================================================================
pscript.report_type=function(){
$td(this.tab,0,1).innerHTML = "Select Report";
this.sel_rpt = $a($td(this.tab,1,1), 'select', null, {width:'120px'});
rpt_lst = ['Monthly','Weekly'];
add_sel_options(this.sel_rpt,rpt_lst);
}
//=======================================================================
pscript.item_grp=function(){
var me = this;
$td(this.tab,0,2).innerHTML = "Select Item Group";
this.sel_grp = $a($td(this.tab,1,2), 'select', null, {width:'120px'});
$c_obj('Plot Control', 'get_item_groups', '', function(r,rt){
itg_lst = r.message;
itg_lst.push('All');
empty_select(me.sel_grp);
add_sel_options(me.sel_grp, itg_lst.reverse());
});
}
//=======================================================================
pscript.month_lst=function(){
pscript.mnt_div1 = $a($td(this.tab,0,3));
pscript.mnt_div1.innerHTML = "Select Month";
pscript.mnt_div = $a($td(this.tab,1,3));
this.sel_mnt = $a(pscript.mnt_div, 'select', null, {width:'120px'});
mnt_lst = ['All','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
add_sel_options(this.sel_mnt,mnt_lst);
}
//=======================================================================
pscript.all_onchnge = function(){
pscript.report_change();
pscript.fiscal_year_onchnage();
pscript.month_onchange();
pscript.item_grp_onchange();
pscript.monthly();
}
//=======================================================================
pscript.report_change = function(){
var me = this;
this.sel_rpt.onchange = function(){
$dh(pscript.mnt_div);
$dh(pscript.mnt_div1);
if(me.sel_rpt.value == 'Monthly'){
pscript.monthly();
}
else if(me.sel_rpt.value == 'Weekly'){
$ds(pscript.mnt_div);
$ds(pscript.mnt_div1);
me.sel_mnt.value = 'All';
pscript.get_x_dates();
}
else{
me.sel_mnt.value = 'All';
$i('plot_test').innerHTML = '';
}
}
}
//=======================================================================
pscript.fiscal_year_onchnage = function(){
var me = this;
this.sel_fy.onchange = function(){
if(me.sel_rpt.value == 'Monthly'){
me.sel_mnt.value = 'All';
$dh(pscript.mnt_div);
$dh(pscript.mnt_div1);
pscript.monthly();
}
else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
pscript.get_x_dates();
}
else{
me.sel_mnt.value = 'All';
me.sel_rpt.value == '';
$i('plot_test').innerHTML = '';
}
}
}
//=======================================================================
pscript.month_onchange = function(){
this.sel_mnt.onchange = function(){
pscript.get_x_dates();
}
}
//=======================================================================
pscript.item_grp_onchange=function(){
var me = this;
this.sel_grp.onchange = function(){
if(me.sel_rpt.value == 'Monthly'){
me.sel_mnt.value = 'All';
$dh(pscript.mnt_div);
$dh(pscript.mnt_div1);
pscript.monthly();
}
else if(me.sel_rpt.value == 'Weekly' && me.sel_mnt.value){
pscript.get_x_dates();
}
else{
me.sel_mnt.value = 'All';
me.sel_rpt.value == '';
$i('plot_test').innerHTML = '';
}
}
}
//=======================================================================
pscript.get_x_dates=function(){
if(this.sel_mnt.value !='All'){
pscript.weekly();
}
else{
$c_obj('Plot Control','yr_wk_dates',this.sel_fy.value,
function(r,rt){
pscript.dx_axis = r.message[0];
pscript.x_axis = r.message[1];
pscript.yearly();
}
);
}
}
//=======================================================================
pscript.draw_graph1 = function(x_axis,line1,t) {
t = t + " ("+sys_defaults.currency +")";
$i('plot_test').innerHTML = '';
// div plot_test contains the container div
$.jqplot('plot_test', [line1],{
title:t,
axesDefaults: {
min:0
},
axes:{
xaxis:{ticks:x_axis}
}
});
}
//=======================================================================
pscript.monthly = function(){
var callback = function(r,rt){
x_axis = r.message.x_axis;
msg_data = r.message.msg_data;
var line1 = [];
for(var i=0; i<x_axis.length;i++){
var f =0
for(var j=0; j<msg_data.length;j++){
if(msg_data[j] && x_axis[i]){
if(x_axis[i][1] == msg_data[j][1])
{
line1.push([i+1,flt(msg_data[j][0])]);
f = 1
}
}
}
if(f == 0){
line1.push([i+1,0]);
}
}
pscript.draw_graph1(x_axis,line1,'Monthly Sales');
}
var val2 = '';
if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
$c_obj('Plot Control','get_monthwise_amount',[this.sel_fy.value,val2],callback);
}
//=======================================================================
pscript.weekly = function(){
var callback = function(r,rt){
x_axis =[[1,'Week1'],[2,'Week2'],[3,'Week3'],[4,'Week4'],[5,'Week5'],[6,'Week6']];
var line1 = [];
for(var i=0; i<x_axis.length;i++){
var f = 0;
for(var j=0; j<r.message.length;j++){
if(r.message[j]){
if(r.message[j][1] == x_axis[i][1]){ line1.push([i+1,flt(r.message[j][0])]); f=1;}}
}
if(f == 0){
line1.push([i+1,0]);
}
}
pscript.draw_graph1(x_axis,line1,'Weekly Sales');
}
dict_mnt={'Jan':1,'Feb':2,'Mar':3,'Apr':4,'May':5,'Jun':6,'Jul':7,'Aug':8,'Sep':9,'Oct':10,'Nov':11,'Dec':12};
var val3 = '';
if(this.sel_grp.value != 'All') val3 = this.sel_grp.value;
$c_obj('Plot Control','get_weekwise_amount',[dict_mnt[this.sel_mnt.value],this.sel_fy.value,val3],callback);
}
//=======================================================================
pscript.yearly = function(){
var callback = function(r,rt){
var line1 = [];
for(var i=0; i<pscript.x_axis.length;i++){
var f = 0
for(var j=0; j<r.message.length;j++){
if(r.message[j]){
if((r.message[j][1] == pscript.x_axis[i][1]) && (r.message[j][2] == pscript.x_axis[i][2])){ line1.push([pscript.x_axis[i][0],r.message[j][0]]); break; f =1;}
}
}
if(f == 0){
line1.push([pscript.x_axis[i][0],0]);
}
}
pscript.draw_graph1(pscript.dx_axis,line1,'Year-Weekly Sales');
}
var val2 = '';
if(this.sel_grp.value != 'All') val2 = this.sel_grp.value;
$c_obj('Plot Control','get_year_weekwise_amount',[this.sel_fy.value,val2],callback);
}

View File

@@ -0,0 +1 @@
[{'creation': '2010-05-21 13:56:25', 'module': 'CRM', 'doctype': 'Page', 'owner': 'harshada@webnotestech.com', 'style': None, 'modified_by': 'saumil@webnotestech.com', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Sales Dashboard', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Sales Dashboard', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000136', 'parent': 'Sales Dashboard', 'creation': '2010-05-21 13:56:25', 'modified': '2010-08-08 00:01:08', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Sales Manager', 'owner': 'harshada@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]

View File

View File

@@ -0,0 +1,4 @@
report.customize_filters = function() {
this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
this.filter_fields_dict['Delivery Note'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
}

View File

@@ -0,0 +1,37 @@
[
{
'add_col': "(`tabDelivery Note Detail`.`qty`- ifnull(`tabDelivery Note Detail`.`installed_qty`, 0)) AS 'Pending to Install'",
'add_cond': '`tabDelivery Note Detail`.`qty` > ifnull(`tabDelivery Note Detail`.`installed_qty`, 0)',
'add_tab': None,
'columns': 'Delivery Note\x01ID,Delivery Note\x01Status,Delivery Note\x01Customer,Delivery Note\x01Customer Name,Delivery Note\x01Contact Person,Delivery Note\x01Voucher Date,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Item Name,Delivery Note Detail\x01Quantity,Delivery Note Detail\x01Installed Qty,Delivery Note\x01% Installed',
'creation': '2011-05-09 11:04:19',
'criteria_name': 'Delivered Items to be Install',
'custom_query': '',
'description': 'Delivered Items to be Install',
'dis_filters': None,
'disabled': None,
'doc_type': 'Delivery Note Detail',
'docstatus': 0,
'doctype': 'Search Criteria',
'filters': "{'Delivery Note\x01Saved':1,'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Fiscal Year':''}",
'graph_series': None,
'graph_values': None,
'group_by': None,
'idx': None,
'modified': '2011-03-29 14:08:46',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'delivered_items_to_be_install',
'owner': 'Administrator',
'page_len': 50,
'parent': None,
'parent_doc_type': 'Delivery Note',
'parentfield': None,
'parenttype': None,
'report_script': None,
'server_script': None,
'sort_by': '`tabDelivery Note`.`name`',
'sort_order': 'DESC',
'standard': 'Yes'
}
]

View File

@@ -0,0 +1,37 @@
[
{
'add_col': "SUM(`tabDelivery Note Detail`.`qty` - `tabDelivery Note Detail`.`billed_qty`) AS 'Pending Qty'\nSUM((`tabDelivery Note Detail`.`qty` - `tabDelivery Note Detail`.`billed_qty`) * `tabDelivery Note Detail`.`basic_rate`) AS 'Pending Amount'",
'add_cond': "`tabDelivery Note`.status != 'Stopped'\nCASE WHEN `tabDelivery Note`.`per_billed` IS NULL OR `tabDelivery Note`.per_billed = '' THEN 0 < 100 ELSE `tabDelivery Note`.per_billed <100 END",
'add_tab': None,
'columns': 'Delivery Note\x01ID,Delivery Note\x01Owner,Delivery Note\x01Status,Delivery Note\x01Customer Name,Delivery Note\x01Voucher Date,Delivery Note\x01% Billed,Delivery Note\x01Posting Date,Delivery Note\x01Company Name,Delivery Note\x01Fiscal Year,Delivery Note Detail\x01Item Code,Delivery Note Detail\x01Against Document No,Delivery Note Detail\x01Document Type,Delivery Note Detail\x01Against Document Detail No',
'creation': '2010-08-08 17:09:31',
'criteria_name': 'Delivery Note Itemwise Pending To Bill',
'custom_query': '',
'description': None,
'dis_filters': None,
'disabled': None,
'doc_type': 'Delivery Note Detail',
'docstatus': 0,
'doctype': 'Search Criteria',
'filters': "{'Delivery Note\x01Saved':1,'Delivery Note\x01Submitted':1,'Delivery Note\x01Status':'','Delivery Note\x01Company Name':'','Delivery Note\x01Fiscal Year':''}",
'graph_series': None,
'graph_values': None,
'group_by': '`tabDelivery Note Detail`.item_code, `tabDelivery Note`.`name`',
'idx': None,
'modified': '2010-04-06 17:22:13',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'delivery_note_itemwise_pending_to_bill',
'owner': 'jai@webnotestech.com',
'page_len': 50,
'parent': None,
'parent_doc_type': 'Delivery Note',
'parentfield': None,
'parenttype': None,
'report_script': '',
'server_script': None,
'sort_by': '`tabDelivery Note`.`name`',
'sort_order': 'DESC',
'standard': 'Yes'
}
]

View File

@@ -0,0 +1,6 @@
report.customize_filters = function() {
this.filter_fields_dict['Sales Order'+FILTER_SEP +'From Sales Order Date'].df['report_default'] = sys_defaults.year_start_date;
this.filter_fields_dict['Sales Order'+FILTER_SEP +'To Sales Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
}

View File

@@ -0,0 +1,37 @@
[
{
'add_col': None,
'add_cond': None,
'add_tab': None,
'columns': 'Sales Order\x01ID,Sales Order\x01Status,Sales Order\x01Sales Order Date,Sales Order\x01Customer,Sales Order\x01P.O. No,Sales Order\x01Grand Total',
'creation': '2010-08-08 17:09:31',
'criteria_name': 'Draft Sales Orders',
'custom_query': '',
'description': 'List of Open Sales orders filtered by period, customer and other details',
'dis_filters': None,
'disabled': None,
'doc_type': 'Sales Order',
'docstatus': 0,
'doctype': 'Search Criteria',
'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Status':'Draft','Sales Order\x01Fiscal Year':''}",
'graph_series': None,
'graph_values': None,
'group_by': None,
'idx': None,
'modified': '2010-06-01 15:19:41',
'modified_by': 'Administrator',
'module': 'CRM',
'name': 'draft_sales_orders',
'owner': 'Administrator',
'page_len': 50,
'parent': None,
'parent_doc_type': None,
'parentfield': None,
'parenttype': None,
'report_script': None,
'server_script': None,
'sort_by': '`tabSales Order`.`name`',
'sort_order': 'DESC',
'standard': 'Yes'
}
]

Some files were not shown because too many files have changed in this diff Show More