mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 09:54:47 +00:00
merged with master
This commit is contained in:
@@ -35,7 +35,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) {
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
if(!(doc.__islocal && doc.lead_name)) { return; }
|
||||
|
||||
var fields_to_refresh = LocalDB.set_default_values(doc);
|
||||
var fields_to_refresh = wn.model.set_default_values(doc);
|
||||
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ cur_frm.cscript.make_contact = function() {
|
||||
parent: cur_frm.fields_dict['contact_html'].wrapper,
|
||||
page_length: 2,
|
||||
custom_new_doc: function(doctype) {
|
||||
var contact = LocalDB.create('Contact');
|
||||
var contact = wn.model.make_new_doc_and_get_name('Contact');
|
||||
contact = locals['Contact'][contact];
|
||||
contact.customer = cur_frm.doc.name;
|
||||
contact.customer_name = cur_frm.doc.customer_name;
|
||||
|
||||
@@ -71,7 +71,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
list: wn.model.get("Communication", {"lead": doc.name}),
|
||||
parent: cur_frm.fields_dict.communication_html.wrapper,
|
||||
doc: doc,
|
||||
email: doc.email_id
|
||||
recipients: doc.email_id
|
||||
})
|
||||
}
|
||||
|
||||
@@ -83,15 +83,15 @@ cur_frm.cscript.status = function(doc, cdt, cdn){
|
||||
|
||||
cur_frm.cscript['Create Customer'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
function(r,rt){
|
||||
if(r.message == 'Converted'){
|
||||
msgprint("This lead is already converted to customer");
|
||||
}
|
||||
else{
|
||||
n = createLocal("Customer");
|
||||
n = wn.model.make_new_doc_and_get_name("Customer");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Customer"][n]]),
|
||||
'docs':wn.model.compress([locals["Customer"][n]]),
|
||||
'from_doctype':'Lead',
|
||||
'to_doctype':'Customer',
|
||||
'from_docname':doc.name,
|
||||
@@ -110,15 +110,15 @@ cur_frm.cscript['Create Customer'] = function(){
|
||||
// ===============================================================
|
||||
cur_frm.cscript['Create Opportunity'] = function(){
|
||||
var doc = cur_frm.doc;
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
|
||||
$c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
|
||||
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("Opportunity");
|
||||
n = wn.model.make_new_doc_and_get_name("Opportunity");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Opportunity"][n]]),
|
||||
'docs':wn.model.compress([locals["Opportunity"][n]]),
|
||||
'from_doctype':'Lead',
|
||||
'to_doctype':'Opportunity',
|
||||
'from_docname':doc.name,
|
||||
|
||||
@@ -51,7 +51,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
list: wn.model.get("Communication", {"opportunity": doc.name}),
|
||||
parent: cur_frm.fields_dict.communication_html.wrapper,
|
||||
doc: doc,
|
||||
email: doc.contact_email
|
||||
recipients: doc.contact_email
|
||||
});
|
||||
}
|
||||
|
||||
@@ -156,9 +156,9 @@ cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = f
|
||||
|
||||
// Create New Quotation
|
||||
cur_frm.cscript['Create Quotation'] = function(){
|
||||
n = createLocal("Quotation");
|
||||
n = wn.model.make_new_doc_and_get_name("Quotation");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Quotation"][n]]),
|
||||
'docs':wn.model.compress([locals["Quotation"][n]]),
|
||||
'from_doctype':'Opportunity',
|
||||
'to_doctype':'Quotation',
|
||||
'from_docname':cur_frm.docname,
|
||||
@@ -207,6 +207,7 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
|
||||
if(r.message == 'true'){
|
||||
$i('update_enquiry_dialog_response').innerHTML = 'Done';
|
||||
e_lost_dialog.hide();
|
||||
cur_frm.refresh();
|
||||
}
|
||||
}
|
||||
if(arg) {
|
||||
|
||||
@@ -107,7 +107,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
list: wn.model.get("Communication", {"quotation": doc.name}),
|
||||
parent: cur_frm.fields_dict.communication_html.wrapper,
|
||||
doc: doc,
|
||||
email: doc.contact_email
|
||||
recipients: doc.contact_email
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -180,9 +180,9 @@ cur_frm.cscript['Make Sales Order'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
|
||||
if (doc.docstatus == 1) {
|
||||
var n = createLocal("Sales Order");
|
||||
var n = wn.model.make_new_doc_and_get_name("Sales Order");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Sales Order"][n]]),
|
||||
'docs':wn.model.compress([locals["Sales Order"][n]]),
|
||||
'from_doctype':'Quotation',
|
||||
'to_doctype':'Sales Order',
|
||||
'from_docname':doc.name,
|
||||
@@ -250,6 +250,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){
|
||||
if(r.message == 'true'){
|
||||
$i('update_quotation_dialog_response').innerHTML = 'Done';
|
||||
qtn_lost_dialog.hide();
|
||||
cur_frm.refresh();
|
||||
}
|
||||
}
|
||||
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
|
||||
|
||||
@@ -46,14 +46,14 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
|
||||
if(!cur_frm.doc.__islocal) { return; }
|
||||
|
||||
doc = locals[doc.doctype][doc.name];
|
||||
var fields_to_refresh = LocalDB.set_default_values(doc);
|
||||
var fields_to_refresh = wn.model.set_default_values(doc);
|
||||
if(fields_to_refresh) { refresh_many(fields_to_refresh); }
|
||||
|
||||
fields_to_refresh = null;
|
||||
var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
|
||||
if(!children) { return; }
|
||||
for(var i=0; i<children.length; i++) {
|
||||
LocalDB.set_default_values(children[i]);
|
||||
wn.model.set_default_values(children[i]);
|
||||
}
|
||||
refresh_field(cur_frm.cscript.fname);
|
||||
cur_frm.cscript.load_taxes(doc, dt, dn, callback);
|
||||
|
||||
@@ -77,7 +77,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
// indent
|
||||
if(!doc.order_type || (doc.order_type == 'Sales'))
|
||||
cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
|
||||
cur_frm.add_custom_button('Make ' + wn._('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
|
||||
|
||||
// sales invoice
|
||||
if(flt(doc.per_billed, 2) < 100)
|
||||
@@ -147,7 +147,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
|
||||
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){
|
||||
if(!r.exc){
|
||||
doc.quotation_no = r.message;
|
||||
if(doc.quotation_no) {
|
||||
unhide_field(['quotation_date', 'customer_address', 'contact_person', 'territory', 'customer_group']);
|
||||
@@ -163,7 +163,7 @@ cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) {
|
||||
|
||||
//================ create new contact ============================================================================
|
||||
cur_frm.cscript.new_contact = function(){
|
||||
tn = createLocal('Contact');
|
||||
tn = wn.model.make_new_doc_and_get_name('Contact');
|
||||
locals['Contact'][tn].is_customer = 1;
|
||||
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
|
||||
loaddoc('Contact', tn);
|
||||
@@ -222,9 +222,9 @@ cur_frm.cscript['Make Maintenance Schedule'] = function() {
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_schedule','',
|
||||
function(r,rt){
|
||||
if(r.message == 'No'){
|
||||
n = createLocal("Maintenance Schedule");
|
||||
n = wn.model.make_new_doc_and_get_name("Maintenance Schedule");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Maintenance Schedule"][n]]),
|
||||
'docs':wn.model.compress([locals["Maintenance Schedule"][n]]),
|
||||
'from_doctype':'Sales Order',
|
||||
'to_doctype':'Maintenance Schedule',
|
||||
'from_docname':doc.name,
|
||||
@@ -251,9 +251,9 @@ cur_frm.cscript.make_maintenance_visit = function() {
|
||||
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_visit','',
|
||||
function(r,rt){
|
||||
if(r.message == 'No'){
|
||||
n = createLocal("Maintenance Visit");
|
||||
n = wn.model.make_new_doc_and_get_name("Maintenance Visit");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Maintenance Visit"][n]]),
|
||||
'docs':wn.model.compress([locals["Maintenance Visit"][n]]),
|
||||
'from_doctype':'Sales Order',
|
||||
'to_doctype':'Maintenance Visit',
|
||||
'from_docname':doc.name,
|
||||
@@ -277,9 +277,9 @@ cur_frm.cscript.make_maintenance_visit = function() {
|
||||
cur_frm.cscript['Make Purchase Request'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
if (doc.docstatus == 1) {
|
||||
n = createLocal("Purchase Request");
|
||||
n = wn.model.make_new_doc_and_get_name("Purchase Request");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Purchase Request"][n]]),
|
||||
'docs':wn.model.compress([locals["Purchase Request"][n]]),
|
||||
'from_doctype':'Sales Order',
|
||||
'to_doctype':'Purchase Request',
|
||||
'from_docname':doc.name,
|
||||
@@ -298,9 +298,9 @@ cur_frm.cscript['Make Purchase Request'] = function() {
|
||||
cur_frm.cscript['Make Delivery Note'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
if (doc.docstatus == 1) {
|
||||
n = createLocal("Delivery Note");
|
||||
n = wn.model.make_new_doc_and_get_name("Delivery Note");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Delivery Note"][n]]),
|
||||
'docs':wn.model.compress([locals["Delivery Note"][n]]),
|
||||
'from_doctype':'Sales Order',
|
||||
'to_doctype':'Delivery Note',
|
||||
'from_docname':doc.name,
|
||||
@@ -319,9 +319,9 @@ cur_frm.cscript['Make Delivery Note'] = function() {
|
||||
cur_frm.cscript['Make Sales Invoice'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
|
||||
n = createLocal('Sales Invoice');
|
||||
n = wn.model.make_new_doc_and_get_name('Sales Invoice');
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals['Sales Invoice'][n]]),
|
||||
'docs':wn.model.compress([locals['Sales Invoice'][n]]),
|
||||
'from_doctype':doc.doctype,
|
||||
'to_doctype':'Sales Invoice',
|
||||
'from_docname':doc.name,
|
||||
@@ -341,7 +341,7 @@ cur_frm.cscript['Stop Sales Order'] = function() {
|
||||
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) {
|
||||
$c('runserverobj', args={'method':'stop_sales_order', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
@@ -355,7 +355,7 @@ cur_frm.cscript['Unstop Sales Order'] = function() {
|
||||
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) {
|
||||
$c('runserverobj', args={'method':'unstop_sales_order', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -194,11 +194,11 @@ class DocType(TransactionBase):
|
||||
# Validations of Details Table
|
||||
# -----------------------------
|
||||
def validate_for_items(self):
|
||||
check_list,flag = [],0
|
||||
check_list, flag = [], 0
|
||||
chk_dupl_itm = []
|
||||
# Sales Order Items Validations
|
||||
for d in getlist(self.doclist, 'sales_order_details'):
|
||||
if cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname):
|
||||
if self.doc.quotation_no and 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):
|
||||
@@ -229,14 +229,13 @@ class DocType(TransactionBase):
|
||||
|
||||
# used for production plan
|
||||
d.transaction_date = self.doc.transaction_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))
|
||||
|
||||
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
|
||||
if getlist(self.doclist, 'sales_order_details') and self.doc.quotation_no and flag == 0:
|
||||
msgprint("There are no items of the quotation selected", raise_exception=1)
|
||||
|
||||
# validate sales/ maintenance quotation against order type
|
||||
#------------------------------------------------------------------
|
||||
|
||||
@@ -24,7 +24,14 @@ pscript['onload_Sales Browser'] = function(wrapper){
|
||||
|
||||
wrapper.make_tree = function() {
|
||||
var ctype = wn.get_route()[1] || 'Territory';
|
||||
erpnext.sales_chart = new erpnext.SalesChart(ctype, wrapper);
|
||||
wn.call({
|
||||
method: 'selling.page.sales_browser.sales_browser.get_children',
|
||||
args: {ctype: ctype},
|
||||
callback: function(r) {
|
||||
var root = r.message[0]["value"];
|
||||
erpnext.sales_chart = new erpnext.SalesChart(ctype, root, wrapper);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
wrapper.make_tree();
|
||||
@@ -42,20 +49,13 @@ pscript['onshow_Sales Browser'] = function(wrapper){
|
||||
};
|
||||
|
||||
erpnext.SalesChart = Class.extend({
|
||||
init: function(ctype, wrapper) {
|
||||
var root_nodes = {
|
||||
'Territory': 'All Territories',
|
||||
'Item Group': 'All Item Groups',
|
||||
'Customer Group': 'All Customer Groups',
|
||||
'Sales Person': 'All Sales Persons'
|
||||
}
|
||||
|
||||
init: function(ctype, root, wrapper) {
|
||||
$(wrapper).find('.tree-area').empty();
|
||||
var me = this;
|
||||
me.ctype = ctype;
|
||||
this.tree = new wn.ui.Tree({
|
||||
parent: $(wrapper).find('.tree-area'),
|
||||
label: root_nodes[ctype],
|
||||
label: root,
|
||||
args: {ctype: ctype},
|
||||
method: 'selling.page.sales_browser.sales_browser.get_children',
|
||||
click: function(link) {
|
||||
@@ -72,7 +72,7 @@ erpnext.SalesChart = Class.extend({
|
||||
}
|
||||
});
|
||||
this.tree.rootnode.$a
|
||||
.data('node-data', {value: root_nodes[ctype], expandable:1})
|
||||
.data('node-data', {value: root, expandable:1})
|
||||
.click();
|
||||
},
|
||||
make_link_toolbar: function(link) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
|
||||
@webnotes.whitelist()
|
||||
def get_children():
|
||||
ctype = webnotes.form_dict.get('ctype')
|
||||
webnotes.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_')
|
||||
|
||||
if not webnotes.form_dict.get('parent'):
|
||||
webnotes.form_dict['parent'] = ''
|
||||
|
||||
return webnotes.conn.sql("""select name as value,
|
||||
if(is_group='Yes', 1, 0) as expandable
|
||||
from `tab%(ctype)s`
|
||||
|
||||
Reference in New Issue
Block a user