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