List route for tree browser based doctypes; Fixes to add child in tree browsers
This commit is contained in:
parent
4ef1835bee
commit
3e41fd1fd3
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Accounts Browser/Account";
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
if(doc.__islocal) {
|
if(doc.__islocal) {
|
||||||
msgprint(__("Please create new account from Chart of Accounts."));
|
msgprint(__("Please create new account from Chart of Accounts."));
|
||||||
@ -8,20 +10,20 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.toggle_display('account_name', doc.__islocal);
|
cur_frm.toggle_display('account_name', doc.__islocal);
|
||||||
|
|
||||||
// hide fields if group
|
// hide fields if group
|
||||||
cur_frm.toggle_display(['account_type', 'master_type', 'master_name',
|
cur_frm.toggle_display(['account_type', 'master_type', 'master_name',
|
||||||
'credit_days', 'credit_limit', 'tax_rate'], doc.group_or_ledger=='Ledger')
|
'credit_days', 'credit_limit', 'tax_rate'], doc.group_or_ledger=='Ledger')
|
||||||
|
|
||||||
// disable fields
|
// disable fields
|
||||||
cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false);
|
cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false);
|
||||||
|
|
||||||
if(doc.group_or_ledger=='Ledger') {
|
if(doc.group_or_ledger=='Ledger') {
|
||||||
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
||||||
var accounts_settings = frappe.get_doc("Accounts Settings", name);
|
var accounts_settings = frappe.get_doc("Accounts Settings", name);
|
||||||
var display = accounts_settings["frozen_accounts_modifier"]
|
var display = accounts_settings["frozen_accounts_modifier"]
|
||||||
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
|
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
|
||||||
|
|
||||||
cur_frm.toggle_display('freeze_account', display);
|
cur_frm.toggle_display('freeze_account', display);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -33,9 +35,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
} else {
|
} else {
|
||||||
// credit days and type if customer or supplier
|
// credit days and type if customer or supplier
|
||||||
cur_frm.set_intro(null);
|
cur_frm.set_intro(null);
|
||||||
cur_frm.toggle_display(['credit_days', 'credit_limit'], in_list(['Customer', 'Supplier'],
|
cur_frm.toggle_display(['credit_days', 'credit_limit'], in_list(['Customer', 'Supplier'],
|
||||||
doc.master_type));
|
doc.master_type));
|
||||||
|
|
||||||
cur_frm.cscript.master_type(doc, cdt, cdn);
|
cur_frm.cscript.master_type(doc, cdt, cdn);
|
||||||
cur_frm.cscript.account_type(doc, cdt, cdn);
|
cur_frm.cscript.account_type(doc, cdt, cdn);
|
||||||
|
|
||||||
@ -45,10 +47,10 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.master_type = function(doc, cdt, cdn) {
|
cur_frm.cscript.master_type = function(doc, cdt, cdn) {
|
||||||
cur_frm.toggle_display(['credit_days', 'credit_limit'], in_list(['Customer', 'Supplier'],
|
cur_frm.toggle_display(['credit_days', 'credit_limit'], in_list(['Customer', 'Supplier'],
|
||||||
doc.master_type));
|
doc.master_type));
|
||||||
|
|
||||||
cur_frm.toggle_display('master_name', doc.account_type=='Warehouse' ||
|
cur_frm.toggle_display('master_name', doc.account_type=='Warehouse' ||
|
||||||
in_list(['Customer', 'Supplier'], doc.master_type));
|
in_list(['Customer', 'Supplier'], doc.master_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,22 +60,22 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
|||||||
if(doc.group_or_ledger=='Ledger') {
|
if(doc.group_or_ledger=='Ledger') {
|
||||||
cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax');
|
cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax');
|
||||||
cur_frm.toggle_display('master_type', cstr(doc.account_type)=='');
|
cur_frm.toggle_display('master_type', cstr(doc.account_type)=='');
|
||||||
cur_frm.toggle_display('master_name', doc.account_type=='Warehouse' ||
|
cur_frm.toggle_display('master_name', doc.account_type=='Warehouse' ||
|
||||||
in_list(['Customer', 'Supplier'], doc.master_type));
|
in_list(['Customer', 'Supplier'], doc.master_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||||
cur_frm.appframe.add_button(__('Chart of Accounts'),
|
cur_frm.appframe.add_button(__('Chart of Accounts'),
|
||||||
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
|
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
|
||||||
|
|
||||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||||
cur_frm.add_custom_button(__('Convert to Ledger'),
|
cur_frm.add_custom_button(__('Convert to Ledger'),
|
||||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
||||||
cur_frm.add_custom_button(__('Convert to Group'),
|
cur_frm.add_custom_button(__('Convert to Group'),
|
||||||
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||||
|
|
||||||
cur_frm.appframe.add_button(__('View Ledger'), function() {
|
cur_frm.appframe.add_button(__('View Ledger'), function() {
|
||||||
frappe.route_options = {
|
frappe.route_options = {
|
||||||
"account": doc.name,
|
"account": doc.name,
|
||||||
@ -88,7 +90,7 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
|||||||
|
|
||||||
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
|
||||||
return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) {
|
return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) {
|
||||||
if(r.message == 1) {
|
if(r.message == 1) {
|
||||||
cur_frm.refresh();
|
cur_frm.refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -119,8 +121,8 @@ cur_frm.fields_dict['master_name'].get_query = function(doc) {
|
|||||||
cur_frm.fields_dict['parent_account'].get_query = function(doc) {
|
cur_frm.fields_dict['parent_account'].get_query = function(doc) {
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
"group_or_ledger": "Group",
|
"group_or_ledger": "Group",
|
||||||
"company": doc.company
|
"company": doc.company
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
frappe.provide("erpnext.accounts");
|
frappe.provide("erpnext.accounts");
|
||||||
|
|
||||||
|
cur_frm.list_route = "Accounts Browser/Cost Center";
|
||||||
|
|
||||||
erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
|
erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
|
||||||
onload: function() {
|
onload: function() {
|
||||||
this.setup_queries();
|
this.setup_queries();
|
||||||
},
|
},
|
||||||
|
|
||||||
setup_queries: function() {
|
setup_queries: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.frm.fields_dict["budget_details"].grid.get_field("account")) {
|
if(this.frm.fields_dict["budget_details"].grid.get_field("account")) {
|
||||||
@ -20,10 +23,10 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.frm.set_query("parent_cost_center", function() {
|
this.frm.set_query("parent_cost_center", function() {
|
||||||
return {
|
return {
|
||||||
filters:[
|
filters:[
|
||||||
['Cost Center', 'group_or_ledger', '=', 'Group'],
|
['Cost Center', 'group_or_ledger', '=', 'Group'],
|
||||||
['Cost Center', 'company', '=', me.frm.doc.company],
|
['Cost Center', 'company', '=', me.frm.doc.company],
|
||||||
]
|
]
|
||||||
@ -44,11 +47,11 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||||
|
|
||||||
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
cur_frm.toggle_display('sb1', doc.group_or_ledger=='Ledger')
|
||||||
cur_frm.set_intro(intro_txt);
|
cur_frm.set_intro(intro_txt);
|
||||||
|
|
||||||
cur_frm.appframe.add_button(__('Chart of Cost Centers'),
|
cur_frm.appframe.add_button(__('Chart of Cost Centers'),
|
||||||
function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
|
function() { frappe.set_route("Accounts Browser", "Cost Center"); }, 'icon-sitemap')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,10 +63,10 @@ cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||||
cur_frm.add_custom_button(__('Convert to Ledger'),
|
cur_frm.add_custom_button(__('Convert to Ledger'),
|
||||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||||
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
|
||||||
cur_frm.add_custom_button(__('Convert to Group'),
|
cur_frm.add_custom_button(__('Convert to Group'),
|
||||||
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -784,8 +784,7 @@ def make_delivery_note(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.run_method("onload_post_render")
|
||||||
doc.run_method("onload_post_render")
|
|
||||||
|
|
||||||
def update_item(source_doc, target_doc, source_parent):
|
def update_item(source_doc, target_doc, source_parent):
|
||||||
target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
|
target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
|
||||||
|
@ -12,7 +12,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
single_column: true
|
single_column: true
|
||||||
})
|
})
|
||||||
|
|
||||||
wrapper.appframe.add_module_icon("Accounts");
|
wrapper.appframe.add_module_icon("Accounts");
|
||||||
|
|
||||||
var main = $(wrapper).find(".layout-main"),
|
var main = $(wrapper).find(".layout-main"),
|
||||||
@ -30,7 +30,7 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
'</li>'+
|
'</li>'+
|
||||||
'<li>'+__('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
|
'<li>'+__('Please do NOT create Account (Ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.')+'</li>'+
|
||||||
'<li>'+
|
'<li>'+
|
||||||
'<b>'+__('To create a Bank Account:')+'</b>'+
|
'<b>'+__('To create a Bank Account:')+'</b>'+
|
||||||
__('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts and create a new Account Ledger (by clicking on Add Child) of type "Bank"')+
|
__('Go to the appropriate group (usually Application of Funds > Current Assets > Bank Accounts and create a new Account Ledger (by clicking on Add Child) of type "Bank"')+
|
||||||
'</li>'+
|
'</li>'+
|
||||||
'<li>'+
|
'<li>'+
|
||||||
@ -39,13 +39,13 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
'</li>'+
|
'</li>'+
|
||||||
'</ol>'+
|
'</ol>'+
|
||||||
'<p>'+__('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
|
'<p>'+__('Please setup your chart of accounts before you start Accounting Entries')+'</p></div>').appendTo(main);
|
||||||
|
|
||||||
if (frappe.boot.user.can_create.indexOf("Company") !== -1) {
|
if (frappe.boot.user.can_create.indexOf("Company") !== -1) {
|
||||||
wrapper.appframe.add_button(__('New Company'), function() { newdoc('Company'); },
|
wrapper.appframe.add_button(__('New Company'), function() { newdoc('Company'); },
|
||||||
'icon-plus');
|
'icon-plus');
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.appframe.set_title_right('Refresh', function() {
|
wrapper.appframe.set_title_right('Refresh', function() {
|
||||||
wrapper.$company_select.change();
|
wrapper.$company_select.change();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -53,11 +53,11 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
wrapper.$company_select = wrapper.appframe.add_select("Company", [])
|
wrapper.$company_select = wrapper.appframe.add_select("Company", [])
|
||||||
.change(function() {
|
.change(function() {
|
||||||
var ctype = frappe.get_route()[1] || 'Account';
|
var ctype = frappe.get_route()[1] || 'Account';
|
||||||
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(),
|
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(),
|
||||||
chart_area.get(0));
|
chart_area.get(0));
|
||||||
pscript.set_title(wrapper, ctype, $(this).val());
|
pscript.set_title(wrapper, ctype, $(this).val());
|
||||||
})
|
})
|
||||||
|
|
||||||
// load up companies
|
// load up companies
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies',
|
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_companies',
|
||||||
@ -86,7 +86,7 @@ pscript['onshow_Accounts Browser'] = function(wrapper){
|
|||||||
if(erpnext.account_chart && erpnext.account_chart.ctype != ctype) {
|
if(erpnext.account_chart && erpnext.account_chart.ctype != ctype) {
|
||||||
wrapper.$company_select.change();
|
wrapper.$company_select.change();
|
||||||
}
|
}
|
||||||
|
|
||||||
pscript.set_title(wrapper, ctype);
|
pscript.set_title(wrapper, ctype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +98,11 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
me.can_create = frappe.model.can_create(this.ctype);
|
me.can_create = frappe.model.can_create(this.ctype);
|
||||||
me.can_delete = frappe.model.can_delete(this.ctype);
|
me.can_delete = frappe.model.can_delete(this.ctype);
|
||||||
me.can_write = frappe.model.can_write(this.ctype);
|
me.can_write = frappe.model.can_write(this.ctype);
|
||||||
|
|
||||||
|
|
||||||
me.company = company;
|
me.company = company;
|
||||||
this.tree = new frappe.ui.Tree({
|
this.tree = new frappe.ui.Tree({
|
||||||
parent: $(wrapper),
|
parent: $(wrapper),
|
||||||
label: ctype==="Account" ? "Accounts" : "Cost Centers",
|
label: ctype==="Account" ? "Accounts" : "Cost Centers",
|
||||||
args: {ctype: ctype, comp: company},
|
args: {ctype: ctype, comp: company},
|
||||||
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
|
method: 'erpnext.accounts.page.accounts_browser.accounts_browser.get_children',
|
||||||
@ -114,7 +114,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
},
|
},
|
||||||
toolbar: [
|
toolbar: [
|
||||||
{ toggle_btn: true },
|
{ toggle_btn: true },
|
||||||
{
|
{
|
||||||
label: __("Open"),
|
label: __("Open"),
|
||||||
condition: function(node) { return !node.root },
|
condition: function(node) { return !node.root },
|
||||||
click: function(node, btn) {
|
click: function(node, btn) {
|
||||||
@ -134,7 +134,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
condition: function(node) {
|
condition: function(node) {
|
||||||
return !node.root && me.ctype === 'Account'
|
return !node.root && me.ctype === 'Account'
|
||||||
&& frappe.boot.user.can_read.indexOf("GL Entry") !== -1
|
&& frappe.boot.user.can_read.indexOf("GL Entry") !== -1
|
||||||
},
|
},
|
||||||
label: __("View Ledger"),
|
label: __("View Ledger"),
|
||||||
@ -147,7 +147,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
};
|
};
|
||||||
frappe.set_route("query-report", "General Ledger");
|
frappe.set_route("query-report", "General Ledger");
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
condition: function(node) { return !node.root && me.can_write },
|
condition: function(node) { return !node.root && me.can_write },
|
||||||
@ -170,8 +170,8 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
],
|
],
|
||||||
onrender: function(node) {
|
onrender: function(node) {
|
||||||
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
if (me.ctype == 'Account' && node.data && node.data.balance!==undefined) {
|
||||||
$('<span class="balance-area pull-right text-muted">'
|
$('<span class="balance-area pull-right text-muted">'
|
||||||
+ format_currency(node.data.balance, node.data.currency)
|
+ format_currency(node.data.balance, node.data.currency)
|
||||||
+ '</span>').insertBefore(node.$ul);
|
+ '</span>').insertBefore(node.$ul);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,18 +179,18 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
},
|
},
|
||||||
new_account: function() {
|
new_account: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
// the dialog
|
// the dialog
|
||||||
var d = new frappe.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title:__('New Account'),
|
title:__('New Account'),
|
||||||
fields: [
|
fields: [
|
||||||
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
|
{fieldtype:'Data', fieldname:'account_name', label:__('New Account Name'), reqd:true,
|
||||||
description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers, they are created automatically from the Customer and Supplier master")},
|
description: __("Name of new Account. Note: Please don't create accounts for Customers and Suppliers, they are created automatically from the Customer and Supplier master")},
|
||||||
{fieldtype:'Select', fieldname:'group_or_ledger', label:__('Group or Ledger'),
|
{fieldtype:'Select', fieldname:'group_or_ledger', label:__('Group or Ledger'),
|
||||||
options:'Group\nLedger', description: __('Further accounts can be made under Groups, but entries can be made against Ledger')},
|
options:'Group\nLedger', description: __('Further accounts can be made under Groups, but entries can be made against Ledger')},
|
||||||
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
|
{fieldtype:'Select', fieldname:'account_type', label:__('Account Type'),
|
||||||
options: ['', 'Bank', 'Cash', 'Warehouse', 'Receivable', 'Payable',
|
options: ['', 'Bank', 'Cash', 'Warehouse', 'Receivable', 'Payable',
|
||||||
'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account',
|
'Equity', 'Cost of Goods Sold', 'Fixed Asset', 'Expense Account',
|
||||||
'Income Account', 'Tax', 'Chargeable'].join('\n'),
|
'Income Account', 'Tax', 'Chargeable'].join('\n'),
|
||||||
description: __("Optional. This setting will be used to filter in various transactions.") },
|
description: __("Optional. This setting will be used to filter in various transactions.") },
|
||||||
{fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate')},
|
{fieldtype:'Float', fieldname:'tax_rate', label:__('Tax Rate')},
|
||||||
@ -199,7 +199,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
})
|
})
|
||||||
|
|
||||||
var fd = d.fields_dict;
|
var fd = d.fields_dict;
|
||||||
|
|
||||||
// account type if ledger
|
// account type if ledger
|
||||||
$(fd.group_or_ledger.input).change(function() {
|
$(fd.group_or_ledger.input).change(function() {
|
||||||
if($(this).val()=='Group') {
|
if($(this).val()=='Group') {
|
||||||
@ -212,7 +212,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// tax rate if tax
|
// tax rate if tax
|
||||||
$(fd.account_type.input).change(function() {
|
$(fd.account_type.input).change(function() {
|
||||||
if($(this).val()=='Tax') {
|
if($(this).val()=='Tax') {
|
||||||
@ -221,38 +221,38 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
$(fd.tax_rate.wrapper).toggle(false);
|
$(fd.tax_rate.wrapper).toggle(false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// create
|
// create
|
||||||
$(fd.create_new.input).click(function() {
|
$(fd.create_new.input).click(function() {
|
||||||
var btn = this;
|
var btn = this;
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.tree.get_selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
v.parent_account = node.label;
|
v.parent_account = node.label;
|
||||||
v.master_type = '';
|
v.master_type = '';
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_ac',
|
method: 'erpnext.accounts.utils.add_ac',
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
d.hide();
|
d.hide();
|
||||||
node.reload;
|
node.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// show
|
// show
|
||||||
d.onshow = function() {
|
d.onshow = function() {
|
||||||
$(fd.group_or_ledger.input).change();
|
$(fd.group_or_ledger.input).change();
|
||||||
$(fd.account_type.input).change();
|
$(fd.account_type.input).change();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(fd.group_or_ledger.input).val("Ledger").change();
|
$(fd.group_or_ledger.input).val("Ledger").change();
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
new_cost_center: function(){
|
new_cost_center: function(){
|
||||||
var me = this;
|
var me = this;
|
||||||
// the dialog
|
// the dialog
|
||||||
@ -265,17 +265,17 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
{fieldtype:'Button', fieldname:'create_new', label:__('Create New') }
|
{fieldtype:'Button', fieldname:'create_new', label:__('Create New') }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
// create
|
// create
|
||||||
$(d.fields_dict.create_new.input).click(function() {
|
$(d.fields_dict.create_new.input).click(function() {
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.tree.get_selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
|
|
||||||
v.parent_cost_center = node.label;
|
v.parent_cost_center = node.label;
|
||||||
v.company = me.company;
|
v.company = me.company;
|
||||||
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
args: v,
|
args: v,
|
||||||
method: 'erpnext.accounts.utils.add_cc',
|
method: 'erpnext.accounts.utils.add_cc',
|
||||||
|
@ -99,11 +99,12 @@ def add_ac(args=None):
|
|||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
ac = frappe.get_doc(args)
|
ac = frappe.new_doc("Account")
|
||||||
ac.doctype = "Account"
|
ac.update(args)
|
||||||
ac.old_parent = ""
|
ac.old_parent = ""
|
||||||
ac.freeze_account = "No"
|
ac.freeze_account = "No"
|
||||||
ac.insert()
|
ac.insert()
|
||||||
|
|
||||||
return ac.name
|
return ac.name
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@ -112,8 +113,8 @@ def add_cc(args=None):
|
|||||||
args = frappe.local.form_dict
|
args = frappe.local.form_dict
|
||||||
args.pop("cmd")
|
args.pop("cmd")
|
||||||
|
|
||||||
cc = frappe.get_doc(args)
|
cc = frappe.new_doc("Cost Center")
|
||||||
cc.doctype = "Cost Center"
|
cc.update(args)
|
||||||
cc.old_parent = ""
|
cc.old_parent = ""
|
||||||
cc.insert()
|
cc.insert()
|
||||||
return cc.name
|
return cc.name
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import cstr, flt
|
from frappe.utils import cstr, flt
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _, throw
|
||||||
from erpnext.controllers.buying_controller import BuyingController
|
from erpnext.controllers.buying_controller import BuyingController
|
||||||
|
|
||||||
class PurchaseOrder(BuyingController):
|
class PurchaseOrder(BuyingController):
|
||||||
@ -183,8 +183,7 @@ def make_purchase_receipt(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.run_method("set_missing_values")
|
||||||
doc.run_method("set_missing_values")
|
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
target.qty = flt(obj.qty) - flt(obj.received_qty)
|
target.qty = flt(obj.qty) - flt(obj.received_qty)
|
||||||
@ -222,8 +221,7 @@ def make_purchase_invoice(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.run_method("set_missing_values")
|
||||||
doc.run_method("set_missing_values")
|
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
target.amount = flt(obj.amount) - flt(obj.billed_amt)
|
target.amount = flt(obj.amount) - flt(obj.billed_amt)
|
||||||
|
@ -8,17 +8,17 @@ from erpnext.controllers.buying_controller import BuyingController
|
|||||||
class SupplierQuotation(BuyingController):
|
class SupplierQuotation(BuyingController):
|
||||||
tname = "Supplier Quotation Item"
|
tname = "Supplier Quotation Item"
|
||||||
fname = "quotation_items"
|
fname = "quotation_items"
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(SupplierQuotation, self).validate()
|
super(SupplierQuotation, self).validate()
|
||||||
|
|
||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.utilities import validate_status
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"Cancelled"])
|
"Cancelled"])
|
||||||
|
|
||||||
self.validate_common()
|
self.validate_common()
|
||||||
self.validate_with_previous_doc()
|
self.validate_with_previous_doc()
|
||||||
self.validate_uom_is_integer("uom", "qty")
|
self.validate_uom_is_integer("uom", "qty")
|
||||||
@ -28,10 +28,10 @@ class SupplierQuotation(BuyingController):
|
|||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
frappe.db.set(self, "status", "Cancelled")
|
frappe.db.set(self, "status", "Cancelled")
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
super(SupplierQuotation, self).validate_with_previous_doc(self.tname, {
|
super(SupplierQuotation, self).validate_with_previous_doc(self.tname, {
|
||||||
"Material Request": {
|
"Material Request": {
|
||||||
@ -45,7 +45,7 @@ class SupplierQuotation(BuyingController):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def validate_common(self):
|
def validate_common(self):
|
||||||
pc = frappe.get_doc('Purchase Common')
|
pc = frappe.get_doc('Purchase Common')
|
||||||
pc.validate_for_items(self)
|
pc.validate_for_items(self)
|
||||||
@ -53,27 +53,26 @@ class SupplierQuotation(BuyingController):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_purchase_order(source_name, target_doc=None):
|
def make_purchase_order(source_name, target_doc=None):
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.run_method("set_missing_values")
|
||||||
doc.run_method("set_missing_values")
|
target.run_method("get_schedule_dates")
|
||||||
doc.run_method("get_schedule_dates")
|
|
||||||
|
|
||||||
def update_item(obj, target, source_parent):
|
def update_item(obj, target, source_parent):
|
||||||
target.conversion_factor = 1
|
target.conversion_factor = 1
|
||||||
|
|
||||||
doclist = get_mapped_doc("Supplier Quotation", source_name, {
|
doclist = get_mapped_doc("Supplier Quotation", source_name, {
|
||||||
"Supplier Quotation": {
|
"Supplier Quotation": {
|
||||||
"doctype": "Purchase Order",
|
"doctype": "Purchase Order",
|
||||||
"validation": {
|
"validation": {
|
||||||
"docstatus": ["=", 1],
|
"docstatus": ["=", 1],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Supplier Quotation Item": {
|
"Supplier Quotation Item": {
|
||||||
"doctype": "Purchase Order Item",
|
"doctype": "Purchase Order Item",
|
||||||
"field_map": [
|
"field_map": [
|
||||||
["name", "supplier_quotation_item"],
|
["name", "supplier_quotation_item"],
|
||||||
["parent", "supplier_quotation"],
|
["parent", "supplier_quotation"],
|
||||||
["uom", "stock_uom"],
|
["uom", "stock_uom"],
|
||||||
["uom", "uom"],
|
["uom", "uom"],
|
||||||
["prevdoc_detail_docname", "prevdoc_detail_docname"],
|
["prevdoc_detail_docname", "prevdoc_detail_docname"],
|
||||||
@ -81,11 +80,11 @@ def make_purchase_order(source_name, target_doc=None):
|
|||||||
["prevdoc_docname", "prevdoc_docname"]
|
["prevdoc_docname", "prevdoc_docname"]
|
||||||
],
|
],
|
||||||
"postprocess": update_item
|
"postprocess": update_item
|
||||||
},
|
},
|
||||||
"Purchase Taxes and Charges": {
|
"Purchase Taxes and Charges": {
|
||||||
"doctype": "Purchase Taxes and Charges",
|
"doctype": "Purchase Taxes and Charges",
|
||||||
"add_if_empty": True
|
"add_if_empty": True
|
||||||
},
|
},
|
||||||
}, target_doc, set_missing_values)
|
}, target_doc, set_missing_values)
|
||||||
|
|
||||||
return doclist
|
return doclist
|
||||||
|
@ -76,10 +76,9 @@ def get_mapped_doc(source_name, target_doc=None):
|
|||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
def postprocess(source, target):
|
def postprocess(source, target):
|
||||||
sal_slip = frappe.get_doc(target)
|
target.run_method("pull_emp_details")
|
||||||
sal_slip.run_method("pull_emp_details")
|
target.run_method("get_leave_details")
|
||||||
sal_slip.run_method("get_leave_details")
|
target.run_method("calculate_net_pay")
|
||||||
sal_slip.run_method("calculate_net_pay")
|
|
||||||
|
|
||||||
doc = get_mapped_doc("Salary Structure", source_name, {
|
doc = get_mapped_doc("Salary Structure", source_name, {
|
||||||
"Salary Structure": {
|
"Salary Structure": {
|
||||||
|
@ -247,8 +247,7 @@ class SalesOrder(SellingController):
|
|||||||
return "order" if self.docstatus==1 else None
|
return "order" if self.docstatus==1 else None
|
||||||
|
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.run_method("onload_post_render")
|
||||||
doc.run_method("onload_post_render")
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_material_request(source_name, target_doc=None):
|
def make_material_request(source_name, target_doc=None):
|
||||||
@ -316,9 +315,8 @@ def make_delivery_note(source_name, target_doc=None):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_sales_invoice(source_name, target_doc=None):
|
def make_sales_invoice(source_name, target_doc=None):
|
||||||
def set_missing_values(source, target):
|
def set_missing_values(source, target):
|
||||||
doc = frappe.get_doc(target)
|
target.is_pos = 0
|
||||||
doc.is_pos = 0
|
target.run_method("onload_post_render")
|
||||||
doc.run_method("onload_post_render")
|
|
||||||
|
|
||||||
def update_item(source, target, source_parent):
|
def update_item(source, target, source_parent):
|
||||||
target.amount = flt(source.amount) - flt(source.billed_amt)
|
target.amount = flt(source.amount) - flt(source.billed_amt)
|
||||||
|
@ -5,18 +5,18 @@ pscript['onload_Sales Browser'] = function(wrapper){
|
|||||||
frappe.ui.make_app_page({
|
frappe.ui.make_app_page({
|
||||||
parent: wrapper,
|
parent: wrapper,
|
||||||
})
|
})
|
||||||
|
|
||||||
wrapper.appframe.add_module_icon("Selling")
|
wrapper.appframe.add_module_icon("Selling")
|
||||||
|
|
||||||
wrapper.appframe.set_title_right('Refresh', function() {
|
wrapper.appframe.set_title_right('Refresh', function() {
|
||||||
wrapper.make_tree();
|
wrapper.make_tree();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(wrapper)
|
$(wrapper)
|
||||||
.find(".layout-side-section")
|
.find(".layout-side-section")
|
||||||
.html('<div class="text-muted">'+
|
.html('<div class="text-muted">'+
|
||||||
__('Click on a link to get options to expand get options ') +
|
__('Click on a link to get options to expand get options ') +
|
||||||
__('Add') + ' / ' + __('Edit') + ' / '+ __('Delete') + '.</div>')
|
__('Add') + ' / ' + __('Edit') + ' / '+ __('Delete') + '.</div>')
|
||||||
|
|
||||||
wrapper.make_tree = function() {
|
wrapper.make_tree = function() {
|
||||||
@ -26,7 +26,7 @@ pscript['onload_Sales Browser'] = function(wrapper){
|
|||||||
args: {ctype: ctype},
|
args: {ctype: ctype},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
var root = r.message[0]["value"];
|
var root = r.message[0]["value"];
|
||||||
erpnext.sales_chart = new erpnext.SalesChart(ctype, root,
|
erpnext.sales_chart = new erpnext.SalesChart(ctype, root,
|
||||||
$(wrapper)
|
$(wrapper)
|
||||||
.find(".layout-main-section")
|
.find(".layout-main-section")
|
||||||
.css({
|
.css({
|
||||||
@ -36,7 +36,7 @@ pscript['onload_Sales Browser'] = function(wrapper){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.make_tree();
|
wrapper.make_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,17 +61,17 @@ erpnext.SalesChart = Class.extend({
|
|||||||
frappe.boot.user.in_create.indexOf(this.ctype) !== -1;
|
frappe.boot.user.in_create.indexOf(this.ctype) !== -1;
|
||||||
me.can_write = frappe.model.can_write(this.ctype);
|
me.can_write = frappe.model.can_write(this.ctype);
|
||||||
me.can_delete = frappe.model.can_delete(this.ctype);
|
me.can_delete = frappe.model.can_delete(this.ctype);
|
||||||
|
|
||||||
this.tree = new frappe.ui.Tree({
|
this.tree = new frappe.ui.Tree({
|
||||||
parent: $(parent),
|
parent: $(parent),
|
||||||
label: root,
|
label: root,
|
||||||
args: {ctype: ctype},
|
args: {ctype: ctype},
|
||||||
method: 'erpnext.selling.page.sales_browser.sales_browser.get_children',
|
method: 'erpnext.selling.page.sales_browser.sales_browser.get_children',
|
||||||
toolbar: [
|
toolbar: [
|
||||||
{toggle_btn: true},
|
{toggle_btn: true},
|
||||||
{
|
{
|
||||||
label:__("Edit"),
|
label:__("Edit"),
|
||||||
condition: function(node) {
|
condition: function(node) {
|
||||||
return !node.root && me.can_read;
|
return !node.root && me.can_read;
|
||||||
},
|
},
|
||||||
click: function(node) {
|
click: function(node) {
|
||||||
@ -103,44 +103,44 @@ erpnext.SalesChart = Class.extend({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
new_node: function() {
|
new_node: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
var fields = [
|
var fields = [
|
||||||
{fieldtype:'Data', fieldname: 'name_field',
|
{fieldtype:'Data', fieldname: 'name_field',
|
||||||
label:'New ' + me.ctype + ' Name', reqd:true},
|
label:'New ' + me.ctype + ' Name', reqd:true},
|
||||||
{fieldtype:'Select', fieldname:'is_group', label:'Group Node', options:'No\nYes',
|
{fieldtype:'Select', fieldname:'is_group', label:'Group Node', options:'No\nYes',
|
||||||
description: __("Further nodes can be only created under 'Group' type nodes")},
|
description: __("Further nodes can be only created under 'Group' type nodes")},
|
||||||
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
|
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
|
||||||
]
|
]
|
||||||
|
|
||||||
if(me.ctype == "Sales Person") {
|
if(me.ctype == "Sales Person") {
|
||||||
fields.splice(-1, 0, {fieldtype:'Link', fieldname:'employee', label:'Employee',
|
fields.splice(-1, 0, {fieldtype:'Link', fieldname:'employee', label:'Employee',
|
||||||
options:'Employee', description: __("Please enter Employee Id of this sales parson")});
|
options:'Employee', description: __("Please enter Employee Id of this sales parson")});
|
||||||
}
|
}
|
||||||
|
|
||||||
// the dialog
|
// the dialog
|
||||||
var d = new frappe.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
title: __('New ') + __(me.ctype),
|
title: __('New ') + __(me.ctype),
|
||||||
fields: fields
|
fields: fields
|
||||||
})
|
})
|
||||||
|
|
||||||
d.set_value("is_group", "No");
|
d.set_value("is_group", "No");
|
||||||
// create
|
// create
|
||||||
$(d.fields_dict.create_new.input).click(function() {
|
$(d.fields_dict.create_new.input).click(function() {
|
||||||
var btn = this;
|
var btn = this;
|
||||||
var v = d.get_values();
|
var v = d.get_values();
|
||||||
if(!v) return;
|
if(!v) return;
|
||||||
|
|
||||||
var node = me.tree.get_selected_node();
|
var node = me.tree.get_selected_node();
|
||||||
|
|
||||||
v.parent = node.label;
|
v.parent = node.label;
|
||||||
v.ctype = me.ctype;
|
v.ctype = me.ctype;
|
||||||
|
|
||||||
return frappe.call({
|
return frappe.call({
|
||||||
method: 'erpnext.selling.page.sales_browser.sales_browser.add_node',
|
method: 'erpnext.selling.page.sales_browser.sales_browser.add_node',
|
||||||
args: v,
|
args: v,
|
||||||
@ -152,9 +152,9 @@ erpnext.SalesChart = Class.extend({
|
|||||||
node.toggle_node();
|
node.toggle_node();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
d.show();
|
d.show();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -11,28 +11,27 @@ def get_children():
|
|||||||
frappe.local.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_')
|
frappe.local.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_')
|
||||||
if not frappe.form_dict.get('parent'):
|
if not frappe.form_dict.get('parent'):
|
||||||
frappe.local.form_dict['parent'] = ''
|
frappe.local.form_dict['parent'] = ''
|
||||||
|
|
||||||
return frappe.db.sql("""select name as value,
|
return frappe.db.sql("""select name as value,
|
||||||
if(is_group='Yes', 1, 0) as expandable
|
if(is_group='Yes', 1, 0) as expandable
|
||||||
from `tab%(ctype)s`
|
from `tab%(ctype)s`
|
||||||
where docstatus < 2
|
where docstatus < 2
|
||||||
and ifnull(%(parent_field)s,'') = "%(parent)s"
|
and ifnull(%(parent_field)s,'') = "%(parent)s"
|
||||||
order by name""" % frappe.local.form_dict, as_dict=1)
|
order by name""" % frappe.local.form_dict, as_dict=1)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def add_node():
|
def add_node():
|
||||||
# ctype = frappe.form_dict.get('ctype')
|
ctype = frappe.form_dict.get('ctype')
|
||||||
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
|
||||||
name_field = ctype.lower().replace(' ', '_') + '_name'
|
name_field = ctype.lower().replace(' ', '_') + '_name'
|
||||||
|
|
||||||
doclist = [{
|
doc = frappe.new_doc(ctype)
|
||||||
"doctype": ctype,
|
doc.update({
|
||||||
"__islocal": 1,
|
|
||||||
name_field: frappe.form_dict['name_field'],
|
name_field: frappe.form_dict['name_field'],
|
||||||
parent_field: frappe.form_dict['parent'],
|
parent_field: frappe.form_dict['parent'],
|
||||||
"is_group": frappe.form_dict['is_group']
|
"is_group": frappe.form_dict['is_group']
|
||||||
}]
|
})
|
||||||
if ctype == "Sales Person":
|
if ctype == "Sales Person":
|
||||||
doclist[0]["employee"] = frappe.form_dict.get('employee')
|
doc.employee = frappe.form_dict.get('employee')
|
||||||
|
|
||||||
frappe.get_doc(doclist).save()
|
doc.save()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Sales Browser/Customer Group";
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
cur_frm.cscript.set_root_readonly(doc);
|
cur_frm.cscript.set_root_readonly(doc);
|
||||||
}
|
}
|
||||||
@ -22,5 +24,5 @@ cur_frm.fields_dict['parent_customer_group'].get_query = function(doc,cdt,cdn) {
|
|||||||
filters: {
|
filters: {
|
||||||
'is_group': "Yes"
|
'is_group': "Yes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Sales Browser/Item Group";
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
cur_frm.cscript.set_root_readonly(doc);
|
cur_frm.cscript.set_root_readonly(doc);
|
||||||
@ -33,4 +34,4 @@ cur_frm.fields_dict['parent_item_group'].get_query = function(doc,cdt,cdn) {
|
|||||||
['Item Group', 'name', '!=', doc.item_group_name]
|
['Item Group', 'name', '!=', doc.item_group_name]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Sales Browser/Sales Person";
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
cur_frm.cscript.set_root_readonly(doc);
|
cur_frm.cscript.set_root_readonly(doc);
|
||||||
}
|
}
|
||||||
@ -33,4 +35,4 @@ cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = f
|
|||||||
|
|
||||||
cur_frm.fields_dict.employee.get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict.employee.get_query = function(doc, cdt, cdn) {
|
||||||
return { query: "erpnext.controllers.queries.employee_query" }
|
return { query: "erpnext.controllers.queries.employee_query" }
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||||
// License: GNU General Public License v3. See license.txt
|
// License: GNU General Public License v3. See license.txt
|
||||||
|
|
||||||
|
cur_frm.list_route = "Sales Browser/Territory";
|
||||||
|
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
cur_frm.cscript.set_root_readonly(doc);
|
cur_frm.cscript.set_root_readonly(doc);
|
||||||
}
|
}
|
||||||
@ -26,7 +28,7 @@ cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ******************** ITEM Group ********************************
|
// ******************** ITEM Group ********************************
|
||||||
cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['target_details'].grid.get_field("item_group").get_query = function(doc, cdt, cdn) {
|
||||||
return{
|
return{
|
||||||
filters:{ 'is_group': "No"}
|
filters:{ 'is_group': "No"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user