Fixes in Project
This commit is contained in:
parent
78b96ca769
commit
650e679a5e
@ -131,7 +131,7 @@
|
||||
"options": "Project Task",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"reqd": 0
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "percent_complete",
|
||||
@ -279,7 +279,7 @@
|
||||
"icon": "icon-puzzle-piece",
|
||||
"idx": 1,
|
||||
"max_attachments": 4,
|
||||
"modified": "2015-03-31 06:12:03.372091",
|
||||
"modified": "2015-04-10 05:11:18.849171",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Project",
|
||||
|
@ -35,17 +35,12 @@ class Project(Document):
|
||||
|
||||
def validate(self):
|
||||
self.validate_dates()
|
||||
self.validate_tasks()
|
||||
self.sync_tasks()
|
||||
|
||||
def validate_dates(self):
|
||||
if self.project_start_date and self.completion_date:
|
||||
if getdate(self.completion_date) < getdate(self.project_start_date):
|
||||
frappe.throw(_("Expected Completion Date can not be less than Project Start Date"))
|
||||
|
||||
def validate_tasks(self):
|
||||
if not self.tasks:
|
||||
frappe.throw("Task is mandatory against a project")
|
||||
|
||||
def sync_tasks(self):
|
||||
"""sync tasks and remove table"""
|
||||
@ -74,8 +69,6 @@ class Project(Document):
|
||||
for t in frappe.get_all("Task", ["name"], {"project": self.name, "name": ("not in", task_names)}):
|
||||
frappe.delete_doc("Task", t.name)
|
||||
|
||||
self.tasks = []
|
||||
|
||||
def update_percent_complete(self):
|
||||
total = frappe.db.sql("""select count(*) from tabTask where project=%s""",
|
||||
self.name)[0][0]
|
||||
@ -85,7 +78,6 @@ class Project(Document):
|
||||
frappe.db.set_value("Project", self.name, "percent_complete",
|
||||
int(float(completed) / total * 100))
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_cost_center_name(project_name):
|
||||
return frappe.db.get_value("Project", project_name, "cost_center")
|
||||
|
@ -61,14 +61,11 @@ class Task(Document):
|
||||
self.act_end_date= tl.end_date
|
||||
|
||||
def update_project(self):
|
||||
if self.project:
|
||||
total_activity_cost = frappe.db.sql("""select sum(actual_cost) from `tabTask`
|
||||
where project = %s""",self.project)
|
||||
frappe.db.set_value("Project", self.project, "total_activity_cost", total_activity_cost)
|
||||
|
||||
total_expense_claim = frappe.db.sql("""select sum(total_expense_claim) from `tabTask`
|
||||
where project = %s""",self.project)
|
||||
frappe.db.set_value("Project", self.project, "total_expense_claim", total_expense_claim)
|
||||
if self.project and frappe.db.exists("Project", self.project):
|
||||
total_cost = frappe.db.sql("""select sum(actual_cost) as actual_cost, sum(total_expense_claim) as expense_claim
|
||||
from `tabTask` where project = %s""", self.project, as_dict=1)[0]
|
||||
frappe.db.set_value("Project", self.project, "total_activity_cost", total_cost.actual_cost)
|
||||
frappe.db.set_value("Project", self.project, "total_expense_claim", total_cost.expense_claim)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_events(start, end, filters=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user