List route for tree browser based doctypes; Fixes to add child in tree browsers

This commit is contained in:
Anand Doshi 2014-04-22 18:54:54 +05:30
parent 4ef1835bee
commit 3e41fd1fd3
15 changed files with 150 additions and 145 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.list_route = "Accounts Browser/Account";
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) {
msgprint(__("Please create new account from Chart of Accounts."));

View File

@ -2,6 +2,9 @@
// License: GNU General Public License v3. See license.txt
frappe.provide("erpnext.accounts");
cur_frm.list_route = "Accounts Browser/Cost Center";
erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
onload: function() {
this.setup_queries();

View File

@ -784,8 +784,7 @@ def make_delivery_note(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("onload_post_render")
target.run_method("onload_post_render")
def update_item(source_doc, target_doc, source_parent):
target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \

View File

@ -238,7 +238,7 @@ erpnext.AccountsChart = Class.extend({
method: 'erpnext.accounts.utils.add_ac',
callback: function(r) {
d.hide();
node.reload;
node.reload();
}
});
});

View File

@ -99,11 +99,12 @@ def add_ac(args=None):
args = frappe.local.form_dict
args.pop("cmd")
ac = frappe.get_doc(args)
ac.doctype = "Account"
ac = frappe.new_doc("Account")
ac.update(args)
ac.old_parent = ""
ac.freeze_account = "No"
ac.insert()
return ac.name
@frappe.whitelist()
@ -112,8 +113,8 @@ def add_cc(args=None):
args = frappe.local.form_dict
args.pop("cmd")
cc = frappe.get_doc(args)
cc.doctype = "Cost Center"
cc = frappe.new_doc("Cost Center")
cc.update(args)
cc.old_parent = ""
cc.insert()
return cc.name

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt
from frappe import msgprint, _
from frappe import msgprint, _, throw
from erpnext.controllers.buying_controller import 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
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("set_missing_values")
target.run_method("set_missing_values")
def update_item(obj, target, source_parent):
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
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("set_missing_values")
target.run_method("set_missing_values")
def update_item(obj, target, source_parent):
target.amount = flt(obj.amount) - flt(obj.billed_amt)

View File

@ -55,9 +55,8 @@ def make_purchase_order(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("set_missing_values")
doc.run_method("get_schedule_dates")
target.run_method("set_missing_values")
target.run_method("get_schedule_dates")
def update_item(obj, target, source_parent):
target.conversion_factor = 1

View File

@ -76,10 +76,9 @@ def get_mapped_doc(source_name, target_doc=None):
from frappe.model.mapper import get_mapped_doc
def postprocess(source, target):
sal_slip = frappe.get_doc(target)
sal_slip.run_method("pull_emp_details")
sal_slip.run_method("get_leave_details")
sal_slip.run_method("calculate_net_pay")
target.run_method("pull_emp_details")
target.run_method("get_leave_details")
target.run_method("calculate_net_pay")
doc = get_mapped_doc("Salary Structure", source_name, {
"Salary Structure": {

View File

@ -247,8 +247,7 @@ class SalesOrder(SellingController):
return "order" if self.docstatus==1 else None
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.run_method("onload_post_render")
target.run_method("onload_post_render")
@frappe.whitelist()
def make_material_request(source_name, target_doc=None):
@ -316,9 +315,8 @@ def make_delivery_note(source_name, target_doc=None):
@frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None):
def set_missing_values(source, target):
doc = frappe.get_doc(target)
doc.is_pos = 0
doc.run_method("onload_post_render")
target.is_pos = 0
target.run_method("onload_post_render")
def update_item(source, target, source_parent):
target.amount = flt(source.amount) - flt(source.billed_amt)

View File

@ -153,7 +153,7 @@ erpnext.SalesChart = Class.extend({
}
}
}
})
});
});
d.show();
},

View File

@ -21,18 +21,17 @@ def get_children():
@frappe.whitelist()
def add_node():
# ctype = frappe.form_dict.get('ctype')
ctype = frappe.form_dict.get('ctype')
parent_field = 'parent_' + ctype.lower().replace(' ', '_')
name_field = ctype.lower().replace(' ', '_') + '_name'
doclist = [{
"doctype": ctype,
"__islocal": 1,
doc = frappe.new_doc(ctype)
doc.update({
name_field: frappe.form_dict['name_field'],
parent_field: frappe.form_dict['parent'],
"is_group": frappe.form_dict['is_group']
}]
})
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()

View File

@ -1,6 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// 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.set_root_readonly(doc);
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// 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.set_root_readonly(doc);

View File

@ -1,6 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// 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.set_root_readonly(doc);
}

View File

@ -1,6 +1,8 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// 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.set_root_readonly(doc);
}