parent
a5275a1ba9
commit
4313326ba0
@ -630,7 +630,7 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
'invoice_amount': flt(d.invoice_amount),
|
||||
'payment_amount': flt(d.payment_amount),
|
||||
'outstanding_amount': flt(d.invoice_amount - d.payment_amount, precision),
|
||||
'due_date': frappe.db.get_value(d.voucher_type, d.voucher_no,
|
||||
'due_date': frappe.db.get_value(d.voucher_type, d.voucher_no,
|
||||
"posting_date" if party_type=="Employee" else "due_date"),
|
||||
}))
|
||||
|
||||
@ -656,16 +656,14 @@ def get_companies():
|
||||
order_by="name")]
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children():
|
||||
def get_children(doctype, parent, company, is_root=False):
|
||||
from erpnext.accounts.report.financial_statements import sort_root_accounts
|
||||
|
||||
args = frappe.local.form_dict
|
||||
doctype, company = args['doctype'], args['company']
|
||||
fieldname = frappe.db.escape(doctype.lower().replace(' ','_'))
|
||||
doctype = frappe.db.escape(doctype)
|
||||
|
||||
# root
|
||||
if args['parent'] in ("Accounts", "Cost Centers"):
|
||||
if is_root:
|
||||
fields = ", root_type, report_type, account_currency" if doctype=="Account" else ""
|
||||
acc = frappe.db.sql(""" select
|
||||
name as value, is_group as expandable {fields}
|
||||
@ -675,7 +673,7 @@ def get_children():
|
||||
order by name""".format(fields=fields, fieldname = fieldname, doctype=doctype),
|
||||
company, as_dict=1)
|
||||
|
||||
if args["parent"]=="Accounts":
|
||||
if parent=="Accounts":
|
||||
sort_root_accounts(acc)
|
||||
else:
|
||||
# other
|
||||
@ -686,7 +684,7 @@ def get_children():
|
||||
where ifnull(`parent_{fieldname}`,'') = %s
|
||||
and docstatus<2
|
||||
order by name""".format(fields=fields, fieldname=fieldname, doctype=doctype),
|
||||
args['parent'], as_dict=1)
|
||||
parent, as_dict=1)
|
||||
|
||||
if doctype == 'Account':
|
||||
company_currency = frappe.db.get_value("Company", company, "default_currency")
|
||||
|
@ -587,7 +587,11 @@ def validate_bom_no(item, bom_no):
|
||||
frappe.throw(_("BOM {0} does not belong to Item {1}").format(bom_no, item))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children():
|
||||
def get_children(doctype, parent=None, is_tree=False):
|
||||
if not parent:
|
||||
frappe.msgprint(_('Please select a BOM'))
|
||||
return
|
||||
|
||||
if frappe.form_dict.parent:
|
||||
return frappe.db.sql("""select
|
||||
bom_item.item_code,
|
||||
|
@ -11,7 +11,7 @@ frappe.treeview_settings["BOM"] = {
|
||||
title: "BOM",
|
||||
breadcrumb: "Manufacturing",
|
||||
disable_add_node: true,
|
||||
root_label: "bom", //fieldname from filters
|
||||
root_label: "All Bill of Materials", //fieldname from filters
|
||||
get_label: function(node) {
|
||||
if(node.data.qty) {
|
||||
return node.data.qty + " x " + node.data.item_code;
|
||||
|
@ -2,8 +2,8 @@
|
||||
"allow_copy": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:subject",
|
||||
"allow_rename": 0,
|
||||
"autoname": "TASK.#####",
|
||||
"beta": 0,
|
||||
"creation": "2013-01-29 19:25:50",
|
||||
"custom": 0,
|
||||
@ -1214,7 +1214,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 5,
|
||||
"menu_index": 0,
|
||||
"modified": "2017-10-06 03:57:37.901446",
|
||||
"modified": "2017-11-10 18:37:19.660293",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Task",
|
||||
|
@ -6,7 +6,7 @@ import frappe, json
|
||||
|
||||
from frappe.utils import getdate, date_diff, add_days, cstr
|
||||
from frappe import _, throw
|
||||
from frappe.utils.nestedset import NestedSet, rebuild_tree
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
class CircularReferenceError(frappe.ValidationError): pass
|
||||
|
||||
@ -118,10 +118,10 @@ class Task(NestedSet):
|
||||
end_date = self.exp_end_date or self.act_end_date
|
||||
if end_date:
|
||||
for task_name in frappe.db.sql("""
|
||||
select name from `tabTask` as parent
|
||||
where parent.project = %(project)s
|
||||
select name from `tabTask` as parent
|
||||
where parent.project = %(project)s
|
||||
and parent.name in (
|
||||
select parent from `tabTask Depends On` as child
|
||||
select parent from `tabTask Depends On` as child
|
||||
where child.task = %(task)s and child.project = %(project)s)
|
||||
""", {'project': self.project, 'task':self.name }, as_dict=1):
|
||||
task = frappe.get_doc("Task", task_name.name)
|
||||
@ -198,22 +198,28 @@ def set_tasks_as_overdue():
|
||||
and `status` not in ('Closed', 'Cancelled')""")
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children():
|
||||
doctype = frappe.local.form_dict.get('doctype')
|
||||
def get_children(doctype, parent, task=None, project=None, is_root=False):
|
||||
conditions = ''
|
||||
|
||||
parent_field = 'parent_' + doctype.lower().replace(' ', '_')
|
||||
parent = frappe.form_dict.get("parent") or ""
|
||||
if task:
|
||||
# via filters
|
||||
conditions += ' and parent_task = "{0}"'.format(frappe.db.escape(task))
|
||||
elif parent and not is_root:
|
||||
# via expand child
|
||||
conditions += ' and parent_task = "{0}"'.format(frappe.db.escape(parent))
|
||||
else:
|
||||
conditions += ' and ifnull(parent_task, "")=""'
|
||||
|
||||
if parent == "task":
|
||||
parent = ""
|
||||
if project:
|
||||
conditions += ' and project = "{0}"'.format(frappe.db.escape(project))
|
||||
|
||||
tasks = frappe.db.sql("""select name as value,
|
||||
subject as title,
|
||||
is_group as expandable
|
||||
from `tab{doctype}`
|
||||
from `tabTask`
|
||||
where docstatus < 2
|
||||
and ifnull(`{parent_field}`,'') = %s
|
||||
order by name""".format(doctype=frappe.db.escape(doctype),
|
||||
parent_field=frappe.db.escape(parent_field)), (parent), as_dict=1)
|
||||
{conditions}
|
||||
order by name""".format(conditions=conditions), as_dict=1)
|
||||
|
||||
# return tasks
|
||||
return tasks
|
||||
|
@ -4,29 +4,30 @@ frappe.treeview_settings['Task'] = {
|
||||
get_tree_nodes: "erpnext.projects.doctype.task.task.get_children",
|
||||
add_tree_node: "erpnext.projects.doctype.task.task.add_node",
|
||||
filters: [
|
||||
{
|
||||
fieldname: "project",
|
||||
fieldtype:"Link",
|
||||
options: "Project",
|
||||
label: __("Project"),
|
||||
},
|
||||
{
|
||||
fieldname: "task",
|
||||
fieldtype:"Link",
|
||||
options: "Task",
|
||||
label: __("Task"),
|
||||
get_query: function(){
|
||||
get_query: function() {
|
||||
return {
|
||||
filters: [["Task", 'is_group', '=', 1]]
|
||||
};
|
||||
}
|
||||
}
|
||||
],
|
||||
title: "Task",
|
||||
breadcrumb: "Projects",
|
||||
get_tree_root: false,
|
||||
root_label: "task",
|
||||
ignore_fields:["parent_task"],
|
||||
get_label: function(node) {
|
||||
return node.data.value;
|
||||
},
|
||||
onload: function(me){
|
||||
root_label: "All Tasks",
|
||||
ignore_fields: ["parent_task"],
|
||||
onload: function(me) {
|
||||
me.make_tree();
|
||||
me.set_root = true;
|
||||
},
|
||||
toolbar: [
|
||||
{
|
||||
@ -39,7 +40,7 @@ frappe.treeview_settings['Task'] = {
|
||||
'fields': [
|
||||
{'fieldname': 'tasks', 'label': 'Tasks', 'fieldtype': 'Text'},
|
||||
],
|
||||
primary_action: function(){
|
||||
primary_action: function() {
|
||||
d.hide();
|
||||
return frappe.call({
|
||||
method: "erpnext.projects.doctype.task.task.add_multiple_tasks",
|
||||
|
@ -90,10 +90,10 @@ class Warehouse(NestedSet):
|
||||
def get_new_warehouse_name_without_abbr(self, name):
|
||||
company_abbr = frappe.db.get_value("Company", self.company, "abbr")
|
||||
parts = name.rsplit(" - ", 1)
|
||||
|
||||
|
||||
if parts[-1].lower() == company_abbr.lower():
|
||||
name = parts[0]
|
||||
|
||||
|
||||
return name
|
||||
|
||||
def recalculate_bin_qty(self, new_name):
|
||||
@ -139,25 +139,19 @@ class Warehouse(NestedSet):
|
||||
return 1
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_children():
|
||||
def get_children(doctype, parent=None, company=None, is_root=False):
|
||||
from erpnext.stock.utils import get_stock_value_on
|
||||
doctype = frappe.local.form_dict.get('doctype')
|
||||
company = frappe.local.form_dict.get('company')
|
||||
|
||||
parent_field = 'parent_' + doctype.lower().replace(' ', '_')
|
||||
parent = frappe.form_dict.get("parent") or ""
|
||||
|
||||
if parent == "Warehouses":
|
||||
if is_root:
|
||||
parent = ""
|
||||
|
||||
warehouses = frappe.db.sql("""select name as value,
|
||||
is_group as expandable
|
||||
from `tab{doctype}`
|
||||
from `tabWarehouse`
|
||||
where docstatus < 2
|
||||
and ifnull(`{parent_field}`,'') = %s
|
||||
and ifnull(`parent_warehouse`,'') = %s
|
||||
and (`company` = %s or company is null or company = '')
|
||||
order by name""".format(doctype=frappe.db.escape(doctype),
|
||||
parent_field=frappe.db.escape(parent_field)), (parent, company), as_dict=1)
|
||||
order by name""", (parent, company), as_dict=1)
|
||||
|
||||
# return warehouses
|
||||
for wh in warehouses:
|
||||
|
Loading…
x
Reference in New Issue
Block a user