Merge branch 'webshop' of github.com:webnotes/erpnext into responsive

Conflicts:
	selling/doctype/quotation/quotation.js
This commit is contained in:
Anand Doshi
2013-05-28 17:46:50 +05:30
71 changed files with 3239 additions and 3453 deletions

View File

@@ -21,108 +21,52 @@ cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
// =====================================================================================
wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
wn.require('app/selling/doctype/sales_common/sales_common.js');
// ONLOAD
// ===================================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.manage_rounded_total();
if(!doc.quotation_to)
hide_field(['customer','customer_address','contact_person','customer_name','lead',
'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_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
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.quotation_to) {
if(doc.quotation_to == 'Customer') {
hide_field('lead');
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
refresh: function(doc, dt, dn) {
this._super();
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);
}
else if (doc.quotation_to == 'Lead') {
hide_field(['customer', 'customer_address', 'contact_person', 'customer_group']);
if (!doc.__islocal) {
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"quotation": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
recipients: doc.contact_email
});
}
}
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
var callback = function(doc, dt, dn) {
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, dt, dn);
}
cur_frm.cscript.hide_price_list_currency(doc, dt, dn, callback);
}
// hide - unhide fields based on lead or customer..
// =======================================================================================================================
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
hide_field(['lead', 'customer','customer_address','contact_person',
'customer_name','address_display','contact_display','contact_mobile','contact_email',
'territory','customer_group']);
if(doc.quotation_to == 'Lead') unhide_field(['lead']);
else if(doc.quotation_to == 'Customer') unhide_field(['customer']);
this.quotation_to();
},
doc.lead = doc.customer = doc.customer_name = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
//================ 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);
}
// REFRESH
// ===================================================================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
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);
}
erpnext.hide_naming_series();
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
quotation_to: function() {
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
},
if (!doc.__islocal) {
cur_frm.communication_view = new wn.views.CommunicationList({
list: wn.model.get("Communication", {"quotation": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
recipients: doc.contact_email
});
}
}
validate_company_and_party: function(party_field) {
if(this.frm.doc.quotation_to == "Lead") {
return true;
} else if(!this.frm.doc.quotation_to) {
msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
"quotation_to", this.frm.doc.name)));
return false;
} else {
return this._super(party_field);
}
},
});
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
var pl = doc.price_list_name;
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
cur_frm.refresh();
if (pl != doc.price_list_name) cur_frm.cscript.price_list_name(doc, dt, dn);
}
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','territory', 'customer_group']);
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
}
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.selling.QuotationController({frm: cur_frm}));
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({
@@ -135,8 +79,6 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
cur_frm.fields_dict.lead.get_query = erpnext.utils.lead_query;
cur_frm.cscript.lead = function(doc, cdt, cdn) {
cur_frm.toggle_display("contact_section", doc.customer || doc.lead);
if(doc.lead) {
get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
unhide_field('territory');
@@ -247,31 +189,6 @@ cur_frm.cscript['Declare Order Lost'] = function(){
qtn_lost_dialog.show();
}
//===================== 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.recalculate_values(doc, cdt, cdn);
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
}
//================ Last Quoted Price and Last Sold Price suggestion ======================
cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
var d = locals[cdt][cdn];

View File

@@ -95,17 +95,6 @@ class DocType(SellingController):
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
# Load Default Charges
# ----------------------------------------------------------
def load_default_taxes(self):
self.doclist = get_obj('Sales Common').load_default_taxes(self)
# Pull details from other charges master (Get Sales Taxes and Charges Master)
# ----------------------------------------------------------
def get_other_charges(self):
self.doclist = get_obj('Sales Common').get_other_charges(self)
# GET TERMS AND CONDITIONS
# ====================================================================================
def get_tc_details(self):
@@ -142,6 +131,8 @@ class DocType(SellingController):
#do not allow sales item in maintenance quotation and service item in sales quotation
#-----------------------------------------------------------------------------------------------
def validate_order_type(self):
super(DocType, self).validate_order_type()
if self.doc.order_type in ['Maintenance', 'Service']:
for d in getlist(self.doclist, 'quotation_details'):
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-05-22 12:10:46",
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-05-22 16:54:07",
"modified": "2013-05-28 14:50:59",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -78,6 +78,7 @@
"reqd": 1
},
{
"depends_on": "eval:doc.quotation_to == \"Customer\"",
"doctype": "DocField",
"fieldname": "customer",
"fieldtype": "Link",
@@ -92,6 +93,7 @@
"search_index": 1
},
{
"depends_on": "eval:doc.quotation_to == \"Lead\"",
"doctype": "DocField",
"fieldname": "lead",
"fieldtype": "Link",
@@ -105,19 +107,21 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"in_list_view": 1,
"label": "Customer Name",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Address",
"oldfieldname": "customer_address",
@@ -128,29 +132,32 @@
"search_index": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"in_filter": 0,
"label": "Contact",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"print_hide": 0,
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -214,6 +221,7 @@
"oldfieldtype": "Table",
"options": "Quotation Item",
"read_only": 0,
"reqd": 1,
"width": "40px"
},
{
@@ -239,11 +247,19 @@
"oldfieldname": "net_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 0,
"print_hide": 1,
"read_only": 1,
"reqd": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "net_total_export",
"fieldtype": "Currency",
"label": "Net Total (Export)",
"options": "currency",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "recalculate_values",
@@ -423,13 +439,22 @@
"doctype": "DocField",
"fieldname": "other_charges_total",
"fieldtype": "Currency",
"label": "Taxes and Charges Total*",
"label": "Taxes and Charges Total",
"oldfieldname": "other_charges_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "other_charges_total_export",
"fieldtype": "Currency",
"label": "Taxes and Charges Total (Export)",
"options": "currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "other_charges_calculation",
@@ -596,6 +621,7 @@
"read_only": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "col_break98",
"fieldtype": "Column Break",
@@ -649,6 +675,7 @@
"search_index": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_group",
"fieldtype": "Link",
@@ -819,19 +846,6 @@
"read_only": 1,
"width": "150px"
},
{
"description": "The date at which current entry is corrected in the system.",
"doctype": "DocField",
"fieldname": "amendment_date",
"fieldtype": "Date",
"label": "Amendment Date",
"no_copy": 1,
"oldfieldname": "amendment_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 0,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "communication_history",
@@ -868,23 +882,28 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales User",
"role": "Sales Manager",
"submit": 1,
"write": 1
},
{
"doctype": "DocPerm",
"role": "Customer"
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"role": "Sales Manager",
"role": "Sales User",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"role": "Customer",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 11:42:57",
"docstatus": 0,
"modified": "2013-05-22 12:08:32",
"modified": "2013-05-22 12:10:32",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -119,7 +119,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"read_only": 1,
"reqd": 0,
"width": "100px"
},
@@ -195,7 +195,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"read_only": 1,
"reqd": 0,
"search_index": 0,
"width": "100px"

File diff suppressed because it is too large Load Diff

View File

@@ -28,23 +28,6 @@ get_value = webnotes.conn.get_value
from utilities.transaction_base import TransactionBase
@webnotes.whitelist()
def get_comp_base_currency(arg=None):
""" get default currency of company"""
res = webnotes.conn.sql("""select default_currency from `tabCompany`
where name = %s""", webnotes.form_dict.get('company'))
return res and res[0][0] or None
@webnotes.whitelist()
def get_price_list_currency(arg=None):
""" Get all currency in which price list is maintained"""
plc = webnotes.conn.sql("select distinct ref_currency from `tabItem Price` where price_list_name = %s", webnotes.form_dict['price_list'])
plc = [d[0] for d in plc]
base_currency = get_comp_base_currency(webnotes.form_dict['company'])
return plc, base_currency
class DocType(TransactionBase):
def __init__(self,d,dl):
self.doc, self.doclist = d,dl
@@ -65,26 +48,6 @@ class DocType(TransactionBase):
self.msg = []
# Get Sales Person Details
# ==========================
# TODO: To be deprecated if not in use
def get_sales_person_details(self, obj):
if obj.doc.doctype != 'Quotation':
obj.doclist = obj.doc.clear_table(obj.doclist,'sales_team')
idx = 0
for d in webnotes.conn.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', 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
return obj.doclist
# Get customer's contact person details
# ==============================================================
def get_contact_details(self, obj = '', primary = 0):
@@ -117,180 +80,6 @@ class DocType(TransactionBase):
if obj.doc.company:
acc_head = webnotes.conn.sql("select name from `tabAccount` where name = '%s' and docstatus != 2" % (cstr(obj.doc.customer) + " - " + webnotes.conn.get_value('Company', obj.doc.company, 'abbr')))
obj.doc.debit_to = acc_head and acc_head[0][0] or ''
# Get Item Details
# ===============================================================
def get_item_details(self, args, obj):
import json
if not obj.doc.price_list_name:
msgprint("Please Select Price List before selecting Items", raise_exception=True)
item = webnotes.conn.sql("""select description, item_name, brand, item_group, stock_uom,
default_warehouse, default_income_account, default_sales_cost_center,
purchase_account, description_html, barcode 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')""", args['item_code'], as_dict=1)
tax = webnotes.conn.sql("""select tax_type, tax_rate from `tabItem Tax`
where parent = %s""", args['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'],
'barcode': item and item[0]['barcode'] or '',
'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 \
args.get('warehouse'),
'income_account': item and item[0]['default_income_account'] or \
args.get('income_account'),
'expense_account': item and item[0]['purchase_account'] or \
args.get('expense_account'),
'cost_center': item and item[0]['default_sales_cost_center'] or \
args.get('cost_center'),
# this is done coz if item once fetched is fetched again than its qty shld be reset to 1
'qty': 1.00,
'adj_rate': 0,
'amount': 0,
'export_amount': 0,
'item_tax_rate': json.dumps(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
base_ref_rate = self.get_ref_rate(args['item_code'], obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
ret['ref_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
ret['base_ref_rate'] = flt(base_ref_rate)
ret['basic_rate'] = flt(base_ref_rate)
if ret['warehouse'] or ret['reserved_warehouse']:
av_qty = self.get_available_qty({'item_code': args['item_code'], 'warehouse': ret['warehouse'] or ret['reserved_warehouse']})
ret.update(av_qty)
# get customer code for given item from Item Customer Detail
customer_item_code_row = webnotes.conn.sql("""\
select ref_code from `tabItem Customer Detail`
where parent = %s and customer_name = %s""",
(args['item_code'], obj.doc.customer))
if customer_item_code_row and customer_item_code_row[0][0]:
ret['customer_item_code'] = customer_item_code_row[0][0]
return ret
def get_item_defaults(self, args):
item = webnotes.conn.sql("""select default_warehouse, default_income_account,
default_sales_cost_center, purchase_account 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') """,
(args['item_code']), as_dict=1)
ret = {
'reserved_warehouse': item and item[0]['default_warehouse'] or '',
'warehouse': item and item[0]['default_warehouse'] or args.get('warehouse'),
'income_account': item and item[0]['default_income_account'] or \
args.get('income_account'),
'expense_account': item and item[0]['purchase_account'] or args.get('expense_account'),
'cost_center': item and item[0]['default_sales_cost_center'] or args.get('cost_center'),
}
return ret
def get_available_qty(self,args):
tot_avail_qty = webnotes.conn.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 ret
# ***************** Get Ref rate as entered in Item Master ********************
def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
ref_rate = webnotes.conn.sql("select ref_rate from `tabItem Price` where parent = %s and price_list_name = %s and ref_currency = %s and selling=1",
(item_code, price_list_name, price_list_currency))
base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
return base_ref_rate
def get_barcode_details(self, barcode):
item = webnotes.conn.sql("select name, end_of_life, is_sales_item, is_service_item \
from `tabItem` where barcode = %s", barcode, as_dict=1)
ret = {}
if not item:
msgprint("""No item found for this barcode: %s.
May be barcode not updated in item master. Please check""" % barcode)
elif item[0]['end_of_life'] and getdate(cstr(item[0]['end_of_life'])) < nowdate():
msgprint("Item: %s has been expired. Please check 'End of Life' field in item master" % item[0]['name'])
elif item[0]['is_sales_item'] == 'No' and item[0]['is_service_item'] == 'No':
msgprint("Item: %s is not a sales or service item" % item[0]['name'])
elif len(item) > 1:
msgprint("There are multiple item for this barcode. \nPlease select item code manually")
else:
ret = {'item_code': item and item[0]['name'] or ''}
return ret
# ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
def get_adj_percent(self, obj):
for d in getlist(obj.doclist, obj.fname):
base_ref_rate = self.get_ref_rate(d.item_code, obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
d.adj_rate = 0
d.ref_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
d.basic_rate = flt(base_ref_rate)
d.base_ref_rate = flt(base_ref_rate)
d.export_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
d.amount = flt(d.qty)*flt(base_ref_rate)
d.export_amount = flt(d.qty)*flt(base_ref_rate)/flt(obj.doc.conversion_rate)
# Load Default Taxes
# ====================
def load_default_taxes(self, obj):
if cstr(obj.doc.charge):
return self.get_other_charges(obj)
else:
return self.get_other_charges(obj, 1)
# Get other charges from Master
# =================================================================================
def get_other_charges(self,obj, default=0):
obj.doclist = 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 = webnotes.conn.sql("""\
select t1.*
from
`tabSales Taxes and Charges` t1,
`tabSales Taxes and Charges Master` t2
where
t1.parent = t2.name and
t2.company = '%s' and
%s
order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
from webnotes.model import default_fields
for other in other_charge:
# remove default fields like parent, parenttype etc.
# from query results
for field in default_fields:
if field in other: del other[field]
d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges',
obj.doclist)
d.fields.update(other)
d.rate = flt(d.rate)
d.tax_amount = flt(d.tax_rate)
d.included_in_print_rate = cint(d.included_in_print_rate)
d.idx = idx
idx += 1
return obj.doclist
# Get TERMS AND CONDITIONS
# =======================================================================================
@@ -327,23 +116,6 @@ class DocType(TransactionBase):
}
return ret
# Get Commission rate
# =======================================================================
def get_comm_rate(self, sales_partner, obj):
comm_rate = webnotes.conn.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 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):
@@ -352,16 +124,6 @@ class DocType(TransactionBase):
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):
sales_team_list = obj.doclist.get({"parentfield": "sales_team"})
total_allocation = sum([flt(d.allocated_percentage) for d in sales_team_list])
if sales_team_list and total_allocation != 100.0:
msgprint("Total Allocated % of Sales Persons should be 100%", raise_exception=True)
# Check Conversion Rate (i.e. it will not allow conversion rate to be 1 for Currency other than default currency set in Global Defaults)
# ===========================================================================

View File

@@ -26,105 +26,54 @@ wn.require('app/selling/doctype/sales_common/sales_common.js');
wn.require('app/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.manage_rounded_total();
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
// load default charges
if(doc.__islocal && !doc.customer){
hide_field(['customer_address','contact_person', 'customer_name',
'address_display', 'contact_display', 'contact_mobile',
'contact_email', 'territory', 'customer_group']);
}
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
var callback = function(doc, cdt, cdn) {
if(doc.__islocal) {
// defined in sales_common.js
cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
}
cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn, callback);
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
erpnext.hide_naming_series();
if (!cur_frm.cscript.is_onload) cur_frm.cscript.hide_price_list_currency(doc, cdt, cdn);
cur_frm.toggle_display("contact_info", doc.customer);
if(doc.docstatus==1) {
if(doc.status != 'Stopped') {
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
// delivery note
if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend({
refresh: function(doc, dt, dn) {
this._super();
if(doc.docstatus==1) {
if(doc.status != 'Stopped') {
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
// delivery note
if(flt(doc.per_delivered, 2) < 100 && doc.order_type=='Sales')
cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
// maintenance
if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
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']);
// maintenance
if(flt(doc.per_delivered, 2) < 100 && (doc.order_type !='Sales')) {
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 || (doc.order_type == 'Sales'))
cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
// sales invoice
if(flt(doc.per_billed, 2) < 100)
cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
// stop
if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
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']);
}
// indent
if(!doc.order_type || (doc.order_type == 'Sales'))
cur_frm.add_custom_button('Make ' + wn._('Material Request'), cur_frm.cscript['Make Material Request']);
// sales invoice
if(flt(doc.per_billed, 2) < 100)
cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Sales Invoice']);
// stop
if(flt(doc.per_delivered, 2) < 100 || doc.per_billed < 100)
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']);
}
}
cur_frm.cscript.order_type(doc);
}
cur_frm.cscript.order_type = function(doc) {
if(doc.order_type == "Sales") {
cur_frm.toggle_reqd("delivery_date", 1);
} else {
cur_frm.toggle_reqd("delivery_date", 0);
}
}
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
cur_frm.toggle_display("contact_info", doc.customer);
this.order_type(doc);
},
var pl = doc.price_list_name;
var callback = function(r,rt) {
var callback2 = function(r, rt) {
if(doc.customer)
unhide_field(['customer_address', 'contact_person', 'territory','customer_group']);
cur_frm.refresh();
if(!onload && (pl != doc.price_list_name)) cur_frm.cscript.price_list_name(doc, dt, dn);
order_type: function() {
this.frm.toggle_reqd("delivery_date", this.frm.doc.order_type == "Sales");
},
reserved_warehouse: function(doc, cdt, cdn) {
this.warehouse(doc, cdt, cdn);
},
});
}
var doc = locals[cur_frm.doctype][cur_frm.docname];
get_server_fields('get_shipping_address',doc.customer,'',doc, dt, dn, 0, callback2);
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name),
'get_default_customer_address', '', callback);
}
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
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);
@@ -180,15 +129,6 @@ cur_frm.fields_dict['quotation_no'].get_query = function(doc) {
ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond});
}
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;

View File

@@ -58,22 +58,6 @@ class DocType(SellingController):
def get_comm_rate(self, sales_partner):
return get_obj('Sales Common').get_comm_rate(sales_partner, self)
def get_item_details(self, args=None):
import json
args = args and json.loads(args) or {}
if args.get('item_code'):
return get_obj('Sales Common').get_item_details(args, self)
else:
obj = get_obj('Sales Common')
for doc in self.doclist:
if doc.fields.get('item_code'):
arg = {'item_code':doc.fields.get('item_code'), 'income_account':doc.fields.get('income_account'),
'cost_center': doc.fields.get('cost_center'), 'warehouse': doc.fields.get('warehouse')};
ret = obj.get_item_defaults(arg)
for r in ret:
if not doc.fields.get(r):
doc.fields[r] = ret[r]
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
@@ -83,12 +67,6 @@ class DocType(SellingController):
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
def load_default_taxes(self):
self.doclist = get_obj('Sales Common').load_default_taxes(self)
def get_other_charges(self):
self.doclist = get_obj('Sales Common').get_other_charges(self)
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
@@ -194,6 +172,8 @@ class DocType(SellingController):
and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
def validate_order_type(self):
super(DocType, self).validate_order_type()
#validate delivery date
if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
msgprint("Please enter 'Expected Delivery Date'")
@@ -226,7 +206,6 @@ class DocType(SellingController):
sales_com_obj.check_conversion_rate(self)
sales_com_obj.validate_max_discount(self,'sales_order_details')
sales_com_obj.get_allocated_sum(self)
self.doclist = sales_com_obj.make_packing_list(self,'sales_order_details')
if not self.doc.status:

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-03-07 14:48:34",
"creation": "2013-05-24 19:29:08",
"docstatus": 0,
"modified": "2013-01-29 17:14:58",
"modified": "2013-05-28 15:05:38",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -76,42 +76,47 @@
"search_index": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "customer_name",
"fieldtype": "Data",
"hidden": 1,
"hidden": 0,
"label": "Name",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "address_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Address",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"hidden": 0,
"label": "Contact",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_mobile",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Mobile No",
"read_only": 1
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_email",
"fieldtype": "Text",
"hidden": 1,
"hidden": 0,
"label": "Contact Email",
"print_hide": 1,
"read_only": 1
@@ -230,7 +235,8 @@
"oldfieldname": "sales_order_details",
"oldfieldtype": "Table",
"options": "Sales Order Item",
"print_hide": 0
"print_hide": 0,
"reqd": 1
},
{
"doctype": "DocField",
@@ -251,11 +257,19 @@
"oldfieldname": "net_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 0,
"print_hide": 1,
"read_only": 1,
"reqd": 0,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "net_total_export",
"fieldtype": "Currency",
"label": "Net Total (Export)",
"options": "currency",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "recalculate_values",
@@ -426,7 +440,7 @@
"doctype": "DocField",
"fieldname": "other_charges_total",
"fieldtype": "Currency",
"label": "Taxes and Charges Total*",
"label": "Taxes and Charges Total",
"oldfieldname": "other_charges_total",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
@@ -434,6 +448,15 @@
"read_only": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "other_charges_total_export",
"fieldtype": "Currency",
"label": "Taxes and Charges Total (Export)",
"options": "currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "other_charges_calculation",
@@ -578,6 +601,7 @@
"print_hide": 0
},
{
"depends_on": "customer",
"doctype": "DocField",
"fieldname": "contact_info",
"fieldtype": "Section Break",
@@ -955,7 +979,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Sales Manager",
@@ -978,7 +1001,6 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"match": "",
"permlevel": 0,
"report": 1,
"role": "Sales User",
@@ -990,7 +1012,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"report": 0,
"role": "Sales User",
@@ -1013,7 +1034,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "Maintenance Manager",
"submit": 0
@@ -1034,7 +1054,6 @@
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"match": "",
"permlevel": 1,
"role": "Maintenance User",
"submit": 0

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 11:42:58",
"docstatus": 0,
"modified": "2013-05-22 12:09:03",
"modified": "2013-05-22 12:10:03",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -113,7 +113,7 @@
"options": "currency",
"print_hide": 1,
"print_width": "70px",
"read_only": 0,
"read_only": 1,
"reqd": 0,
"width": "70px"
},
@@ -183,7 +183,7 @@
"options": "Company:company:default_currency",
"print_hide": 1,
"print_width": "100px",
"read_only": 0,
"read_only": 1,
"reqd": 0,
"width": "100px"
},

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-02-22 01:27:53",
"creation": "2013-04-19 13:30:51",
"docstatus": 0,
"modified": "2013-03-07 07:03:31",
"modified": "2013-05-21 17:04:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -42,6 +42,7 @@
"doctype": "DocField",
"fieldname": "sales_designation",
"fieldtype": "Data",
"hidden": 0,
"label": "Designation",
"oldfieldname": "sales_designation",
"oldfieldtype": "Data",
@@ -63,7 +64,7 @@
"doctype": "DocField",
"fieldname": "allocated_percentage",
"fieldtype": "Float",
"label": "Allocated (%)",
"label": "Contribution (%)",
"oldfieldname": "allocated_percentage",
"oldfieldtype": "Currency",
"print_width": "100px",
@@ -74,11 +75,12 @@
"doctype": "DocField",
"fieldname": "allocated_amount",
"fieldtype": "Currency",
"label": "Allocated Amount",
"label": "Contribution to Net Total",
"oldfieldname": "allocated_amount",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_width": "120px",
"read_only": 1,
"reqd": 0,
"width": "120px"
},