filters added, ui change, update project moved to project.py

This commit is contained in:
Neil Trini Lasrado 2015-04-14 18:49:48 +05:30
parent ec5c66f8f0
commit 4e6e4726a4
7 changed files with 183 additions and 161 deletions

View File

@ -169,3 +169,11 @@ frappe.ui.form.on("Expense Claim", "employee_name", function(frm) {
frappe.ui.form.on("Expense Claim", "task", function(frm) {
erpnext.expense_claim.set_title(frm);
});
cur_frm.fields_dict['task'].get_query = function(doc) {
return {
filters:{
'project': doc.project
}
}
}

View File

@ -7,13 +7,6 @@
"doctype": "DocType",
"document_type": "Master",
"fields": [
{
"fieldname": "overview",
"fieldtype": "Section Break",
"label": "Overview",
"options": "icon-file",
"permlevel": 0
},
{
"description": "",
"fieldname": "project_name",
@ -112,6 +105,49 @@
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "customer_details",
"fieldtype": "Section Break",
"label": "",
"oldfieldtype": "Section Break",
"options": "icon-user",
"permlevel": 0
},
{
"fieldname": "customer",
"fieldtype": "Link",
"in_filter": 1,
"label": "Customer",
"no_copy": 0,
"oldfieldname": "customer",
"oldfieldtype": "Link",
"options": "Customer",
"permlevel": 0,
"print_hide": 1,
"reqd": 0,
"search_index": 1
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"permlevel": 0
},
{
"fieldname": "column_break_14",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "sales_order",
"fieldtype": "Link",
"label": "Sales Order",
"options": "Sales Order",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "sb_milestones",
"fieldtype": "Section Break",
@ -155,13 +191,6 @@
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "company",
"fieldtype": "Link",
"label": "Company",
"options": "Company",
"permlevel": 0
},
{
"fieldname": "section_break_18",
"fieldtype": "Section Break",
@ -179,7 +208,7 @@
{
"fieldname": "actual_time",
"fieldtype": "Float",
"label": "Actual Time",
"label": "Actual Time (in Hours)",
"permlevel": 0,
"precision": "",
"read_only": 1
@ -202,18 +231,16 @@
"search_index": 0
},
{
"fieldname": "project_details",
"fieldname": "section_break_26",
"fieldtype": "Section Break",
"label": "Project Costing",
"oldfieldtype": "Section Break",
"options": "icon-money",
"permlevel": 0
"permlevel": 0,
"precision": ""
},
{
"fieldname": "project_value",
"fieldname": "estimated_costing",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Project Value",
"label": "Estimated Costing",
"no_copy": 0,
"oldfieldname": "project_value",
"oldfieldtype": "Currency",
@ -222,47 +249,12 @@
"reqd": 0,
"search_index": 0
},
{
"fieldname": "total_costing_amount",
"fieldtype": "Currency",
"label": "Total Costing Amount",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "total_expense_claim",
"fieldtype": "Currency",
"label": "Total Expense Claim",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "column_break_22",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "est_material_cost",
"fieldtype": "Currency",
"label": "Estimated Material Cost",
"no_copy": 0,
"oldfieldname": "est_material_cost",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "total_billing_amount",
"fieldtype": "Currency",
"label": "Total Billing Amount",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
@ -271,24 +263,30 @@
"permlevel": 0
},
{
"fieldname": "margin",
"fieldname": "project_details",
"fieldtype": "Section Break",
"label": "Margin",
"oldfieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
"label": "",
"oldfieldtype": "Section Break",
"options": "icon-money",
"permlevel": 0
},
{
"fieldname": "gross_margin_value",
"description": "",
"fieldname": "total_costing_amount",
"fieldtype": "Currency",
"label": "Gross Margin Value",
"no_copy": 0,
"oldfieldname": "gross_margin_value",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"label": "Total Costing Amount (via Time Logs)",
"permlevel": 0,
"reqd": 0,
"search_index": 0
"precision": "",
"read_only": 1
},
{
"description": "",
"fieldname": "total_expense_claim",
"fieldtype": "Currency",
"label": "Total Expense Claim (via Expense Claims)",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "column_break_28",
@ -297,44 +295,59 @@
"precision": ""
},
{
"fieldname": "per_gross_margin",
"description": "",
"fieldname": "total_billing_amount",
"fieldtype": "Currency",
"label": "Gross Margin %",
"label": "Total Billing Amount (via Time Logs)",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "margin",
"fieldtype": "Section Break",
"label": "",
"oldfieldtype": "Column Break",
"permlevel": 0,
"width": "50%"
},
{
"fieldname": "gross_margin",
"fieldtype": "Currency",
"label": "Gross Margin",
"no_copy": 0,
"oldfieldname": "per_gross_margin",
"oldfieldname": "gross_margin_value",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"read_only": 1,
"reqd": 0,
"search_index": 0
},
{
"fieldname": "customer_details",
"fieldtype": "Section Break",
"label": "Customer Details",
"oldfieldtype": "Section Break",
"options": "icon-user",
"permlevel": 0
"fieldname": "column_break_37",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "customer",
"fieldtype": "Link",
"in_filter": 1,
"label": "Customer",
"fieldname": "per_gross_margin",
"fieldtype": "Percent",
"label": "Gross Margin %",
"no_copy": 0,
"oldfieldname": "customer",
"oldfieldtype": "Link",
"options": "Customer",
"oldfieldname": "per_gross_margin",
"oldfieldtype": "Currency",
"options": "",
"permlevel": 0,
"print_hide": 1,
"read_only": 1,
"reqd": 0,
"search_index": 1
"search_index": 0
}
],
"icon": "icon-puzzle-piece",
"idx": 1,
"max_attachments": 4,
"modified": "2015-04-13 07:13:06.962942",
"modified": "2015-04-14 07:37:56.810833",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",

View File

@ -44,6 +44,8 @@ class Project(Document):
def sync_tasks(self):
"""sync tasks and remove table"""
if self.flags.dont_sync_tasks: return
task_names = []
for t in self.tasks:
if t.task_id:
@ -79,6 +81,22 @@ class Project(Document):
project=%s and status in ('Closed', 'Cancelled')""", self.name)[0][0]
frappe.db.set_value("Project", self.name, "percent_complete",
int(float(completed) / total * 100))
def update_costing(self):
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount,
sum(total_billing_amount) as billing_amount, sum(total_expense_claim) as expense_claim,
min(act_start_date) as start_date, max(act_end_date) as end_date, sum(actual_time) as time
from `tabTask` where project = %s""", self.name, as_dict=1)[0]
self.total_costing_amount = total_cost.costing_amount
self.total_billing_amount = total_cost.billing_amount
self.total_expense_claim = total_cost.expense_claim
self.actual_start_date = total_cost.start_date
self.actual_end_date = total_cost.end_date
self.actual_time = total_cost.time
self.gross_margin = flt(total_cost.billing_amount) - flt(total_cost.costing_amount)
if self.total_billing_amount:
self.per_gross_margin = (self.gross_margin / flt(self.total_billing_amount)) *100
@frappe.whitelist()
def get_cost_center_name(project_name):

View File

@ -18,24 +18,14 @@
"reqd": 1
},
{
"fieldname": "exp_start_date",
"fieldtype": "Date",
"label": "Expected Start Date",
"oldfieldname": "exp_start_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0
},
{
"fieldname": "exp_end_date",
"fieldtype": "Date",
"in_filter": 1,
"label": "Expected End Date",
"oldfieldname": "exp_end_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0,
"search_index": 1
"fieldname": "project",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Project",
"oldfieldname": "project",
"oldfieldtype": "Link",
"options": "Project",
"permlevel": 0
},
{
"fieldname": "column_break0",
@ -56,16 +46,6 @@
"options": "Open\nWorking\nPending Review\nClosed\nCancelled",
"permlevel": 0
},
{
"fieldname": "project",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Project",
"oldfieldname": "project",
"oldfieldtype": "Link",
"options": "Project",
"permlevel": 0
},
{
"fieldname": "priority",
"fieldtype": "Select",
@ -104,33 +84,45 @@
"oldfieldtype": "Section Break",
"permlevel": 0
},
{
"fieldname": "exp_start_date",
"fieldtype": "Date",
"label": "Expected Start Date",
"oldfieldname": "exp_start_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0
},
{
"default": "0",
"description": "in Hours",
"description": "",
"fieldname": "expected_time",
"fieldtype": "Float",
"label": "Expected Time",
"label": "Expected Time (in hours)",
"oldfieldname": "exp_total_hrs",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 0
},
{
"fieldname": "column_break_12",
"fieldname": "column_break_11",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "allocated_budget",
"fieldtype": "Currency",
"label": "Allocated Budget",
"oldfieldname": "allocated_budget",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0
"fieldname": "exp_end_date",
"fieldtype": "Date",
"in_filter": 1,
"label": "Expected End Date",
"oldfieldname": "exp_end_date",
"oldfieldtype": "Date",
"permlevel": 0,
"reqd": 0,
"search_index": 1
},
{
"description": "",
"fieldname": "actual",
"fieldtype": "Section Break",
"label": "",
@ -142,7 +134,7 @@
{
"fieldname": "act_start_date",
"fieldtype": "Date",
"label": "Actual Start Date",
"label": "Actual Start Date (via Time Logs)",
"oldfieldname": "act_start_date",
"oldfieldtype": "Date",
"permlevel": 0,
@ -150,10 +142,10 @@
},
{
"default": "",
"description": "in Hours",
"description": "",
"fieldname": "actual_time",
"fieldtype": "Float",
"label": "Actual Time",
"label": "Actual Time (in hours)",
"options": "",
"permlevel": 0,
"precision": "",
@ -168,7 +160,7 @@
{
"fieldname": "act_end_date",
"fieldtype": "Date",
"label": "Actual End Date",
"label": "Actual End Date (via Time Logs)",
"oldfieldname": "act_end_date",
"oldfieldtype": "Date",
"permlevel": 0,
@ -183,7 +175,7 @@
{
"fieldname": "total_costing_amount",
"fieldtype": "Currency",
"label": "Total Costing Amount",
"label": "Total Costing Amount (via Time Logs)",
"oldfieldname": "actual_budget",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
@ -193,7 +185,7 @@
{
"fieldname": "total_expense_claim",
"fieldtype": "Currency",
"label": "Total Expense Claim",
"label": "Total Expense Claim (via Expense Claim)",
"options": "Company:company:default_currency",
"permlevel": 0,
"precision": "",
@ -209,7 +201,7 @@
"fieldname": "total_billing_amount",
"fieldtype": "Currency",
"hidden": 0,
"label": "Total Billing Amount",
"label": "Total Billing Amount (via Time Logs)",
"permlevel": 0,
"precision": "",
"read_only": 1
@ -257,7 +249,7 @@
"idx": 1,
"istable": 0,
"max_attachments": 5,
"modified": "2015-04-13 05:36:33.544083",
"modified": "2015-04-14 07:56:24.481667",
"modified_by": "Administrator",
"module": "Projects",
"name": "Task",

View File

@ -64,18 +64,10 @@ class Task(Document):
def update_project(self):
if self.project and frappe.db.exists("Project", self.project):
total_cost = frappe.db.sql("""select sum(total_costing_amount) as costing_amount,
sum(total_billing_amount) as billing_amount, sum(total_expense_claim) as expense_claim,
min(act_start_date) as start_date, max(act_end_date) as end_date, sum(actual_time) as time
from `tabTask` where project = %s""", self.project, as_dict=1)[0]
frappe.db.set_values("Project", self.project, {
"total_costing_amount": total_cost.costing_amount,
"total_billing_amount": total_cost.billing_amount,
"total_expense_claim": total_cost.expense_claim,
"actual_start_date": total_cost.start_date,
"actual_end_date": total_cost.end_date,
"actual_time": total_cost.time
})
project = frappe.get_doc("Project", self.project)
project.flags.dont_sync_tasks = True
project.update_costing()
project.save()
@frappe.whitelist()
def get_events(start, end, filters=None):

View File

@ -4,7 +4,6 @@
frappe.provide("erpnext.projects");
frappe.ui.form.on("Time Log", "onload", function(frm) {
frm.set_query("task", erpnext.queries.task);
if (frm.doc.for_manufacturing) {
frappe.ui.form.trigger("Time Log", "production_order");
}
@ -88,3 +87,11 @@ frappe.ui.form.on("Time Log", "billable", function(frm) {
frm.doc("billing_amount", 0);
}
});
cur_frm.fields_dict['task'].get_query = function(doc) {
return {
filters:{
'project': doc.project
}
}
}

View File

@ -232,10 +232,10 @@
},
{
"default": "0",
"description": "per hour",
"description": "",
"fieldname": "costing_rate",
"fieldtype": "Currency",
"label": "Costing Rate",
"label": "Costing Rate (per hour)",
"permlevel": 0,
"precision": "",
"read_only": 1
@ -257,10 +257,10 @@
},
{
"default": "0",
"description": "per hour",
"description": "",
"fieldname": "billing_rate",
"fieldtype": "Currency",
"label": "Billing Rate",
"label": "Billing Rate (per hour)",
"permlevel": 0,
"precision": "",
"read_only": 1
@ -322,15 +322,7 @@
"icon": "icon-time",
"idx": 1,
"is_submittable": 1,
<<<<<<< HEAD
<<<<<<< HEAD
"modified": "2015-04-06 02:47:16.187046",
=======
"modified": "2015-04-09 08:29:34.464429",
>>>>>>> Fixes in time_log
=======
"modified": "2015-04-13 04:31:20.855439",
>>>>>>> task and project- billing amount and actual amount added
"modified": "2015-04-14 09:07:28.468792",
"modified_by": "Administrator",
"module": "Projects",
"name": "Time Log",