Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait
2012-07-19 09:15:49 +05:30
44 changed files with 106 additions and 45 deletions

View File

@@ -90,8 +90,15 @@ cur_frm.cscript.supplier = function(doc,dt,dn) {
cur_frm.cscript.calc_amount(doc, 1);
}
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1,callback);
if(doc.supplier) unhide_field(['supplier_address','contact_person']);
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function(doc, dt, dn) {
cur_frm.refresh();
callback(doc, dt, dn);
});
unhide_field(['supplier_address','contact_person']);
}
}
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
@@ -113,14 +120,19 @@ cur_frm.fields_dict.contact_person.on_new = function(dn) {
cur_frm.cscript.credit_to = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
if(doc.supplier) unhide_field(['supplier_address','contact_person']);
var callback = function(doc, dt, dn) {
var doc = locals[doc.doctype][doc.name];
if(doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }), '', doc, dt, dn, 1, function() {
cur_frm.refresh();
});
unhide_field(['supplier_address','contact_person']);
}
cur_frm.refresh();
}
get_server_fields('get_cust','','',doc,dt,dn,1,callback);
get_server_fields('get_cust', '', '', doc, dt, dn, 1, callback);
}

View File

@@ -65,9 +65,6 @@ cur_frm.cscript.update_item_details = function(doc, dt, dn, callback) {
}
}
var set_dynamic_label_par = function(doc, cdt, cdn, base_curr) {
//parent flds
par_cols_base = {'net_total': 'Net Total', 'total_tax': 'Total Tax', 'grand_total': 'Grand Total', /*'rounded_total': 'Rounded Total',*/

View File

@@ -68,12 +68,15 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
}
//Supplier
cur_frm.cscript.supplier = function(doc,dt,dn) {
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
if(doc.supplier) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
cur_frm.refresh();
});
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
}
}
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {

View File

@@ -5,7 +5,7 @@
{
'creation': '2012-05-15 12:14:41',
'docstatus': 0,
'modified': '2012-05-31 13:18:29',
'modified': '2012-07-18 17:41:49',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -263,6 +263,19 @@
'search_index': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'This currency will get fetched in Purchase transactions of this supplier',
'doctype': u'DocField',
'fieldname': u'default_currency',
'fieldtype': u'Select',
'label': u'Default Currency',
'no_copy': 1,
'options': u'link:Currency',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',

View File

@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-05-15 12:14:51',
'creation': '2012-07-18 16:07:05',
'docstatus': 0,
'modified': '2012-05-31 11:41:06',
'modified': '2012-07-18 17:11:25',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -368,6 +368,19 @@
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'This currency will get fetched in Sales transactions of this customer',
'doctype': u'DocField',
'fieldname': u'default_currency',
'fieldtype': u'Select',
'label': u'Default Currency',
'no_copy': 1,
'options': u'link:Currency',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',

View File

@@ -34,7 +34,7 @@ wn.doclistviews['Sales Order'] = wn.views.ListView.extend({
if (order_type === 'sales') {
me.render_icon(parent, 'icon-tag', data.order_type);
me.render_bar_graph(parent, data, 'per_billed', 'Delivered');
me.render_bar_graph(parent, data, 'per_delivered', 'Delivered');
} else if (order_type === 'maintenance') {
me.render_icon(parent, 'icon-wrench', data.order_type);
}

View File

@@ -64,11 +64,15 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
}
}
//Supplier
cur_frm.cscript.supplier = function(doc,dt,dn) {
if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1);
if(doc.supplier) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
if (doc.supplier) {
get_server_fields('get_default_supplier_address',
JSON.stringify({ supplier: doc.supplier }),'', doc, dt, dn, 1, function() {
cur_frm.refresh();
});
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
}
}
cur_frm.cscript.supplier_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {

View File

@@ -116,22 +116,32 @@ class TransactionBase:
contact_mobile = details and details[0]['mobile_no'] or ''
return contact_display, contact_name, contact_email, contact_mobile
# Get Customer Details
# -----------------------
def get_customer_details(self, name):
customer_details = webnotes.conn.sql("select customer_name, customer_group, territory, default_sales_partner, default_commission_rate, default_price_list from tabCustomer where name = '%s' and docstatus != 2" %(name), as_dict = 1)
def get_customer_details(self, name):
"""
Get customer details like name, group, territory
and other such defaults
"""
customer_details = webnotes.conn.sql("""\
select
customer_name, customer_group, territory,
default_sales_partner, default_commission_rate, default_currency,
default_price_list
from `tabCustomer`
where name = %s and docstatus < 2""", name, as_dict=1)
if customer_details:
self.doc.customer_name = customer_details[0]['customer_name'] or ''
self.doc.customer_group = customer_details[0]['customer_group'] or ''
self.doc.territory = customer_details[0]['territory'] or ''
self.doc.sales_partner = customer_details[0]['default_sales_partner'] or ''
self.doc.commission_rate = customer_details[0]['default_commission_rate'] or ''
def_price_list = customer_details[0]['default_price_list'] or ''
if not def_price_list:
cg_price_list = webnotes.conn.sql("select default_price_list from `tabCustomer Group` where name = %s", customer_details[0]['customer_group'])
def_price_list = cg_price_list and cg_price_list[0][0] or ''
self.doc.price_list_name = def_price_list or self.doc.price_list_name
for f in ['customer_name', 'customer_group', 'territory']:
self.doc.fields[f] = customer_details[0][f] or self.doc.fields.get(f)
# fields prepended with default in Customer doctype
for f in ['sales_partner', 'commission_rate', 'currency']:
self.doc.fields[f] = customer_details[0]["default_%s" % f] or self.doc.fields.get(f)
# optionally fetch default price list from Customer Group
self.doc.price_list_name = (customer_details[0]['default_price_list']
or webnotes.conn.get_value('Customer Group', self.doc.customer_group,
'default_price_list')
or self.doc.fields.get('price_list_name'))
# Get Customer Shipping Address
# -----------------------
def get_shipping_address(self, name):
@@ -194,7 +204,7 @@ class TransactionBase:
contact_text, contact_name, contact_email, contact_mobile = self.get_contact_text(contact_name=args['contact'])
ret = {
'supplier_address' : address_name,
'address_display' : address_text,
'address_display' : address_text,
'contact_person' : contact_name,
'contact_display' : contact_text,
'contact_email' : contact_email,
@@ -204,12 +214,20 @@ class TransactionBase:
# Get Supplier Details
# -----------------------
def get_supplier_details(self, name):
supplier_details = webnotes.conn.sql("select supplier_name from tabSupplier where name = '%s' and docstatus != 2" %(name), as_dict = 1)
ret = {
'supplier_name' : supplier_details and supplier_details[0]['supplier_name'] or ''
}
return ret
def get_supplier_details(self, name):
supplier_details = webnotes.conn.sql("""\
select supplier_name, default_currency
from `tabSupplier`
where name = %s and docstatus < 2""", name, as_dict=1)
if supplier_details:
return {
'supplier_name': (supplier_details[0]['supplier_name']
or self.doc.fields.get('supplier_name')),
'currency': (supplier_details[0]['default_currency']
or self.doc.fields.get('currency')),
}
else:
return {}
# Get Sales Person Details of Customer
# ------------------------------------