mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 19:49:18 +00:00
[projects] added ganttview, removed old timesheet
This commit is contained in:
@@ -15,20 +15,16 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// show tasks
|
||||
wn.require("public/app/js/gantt_task.js");
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
if(!doc.__islocal) {
|
||||
// refresh gantt chart
|
||||
wn.require('app/projects/gantt_task.js');
|
||||
if(!cur_frm.gantt_area)
|
||||
cur_frm.gantt_area = $('<div>')
|
||||
.appendTo(cur_frm.fields_dict.project_tasks.wrapper);
|
||||
cur_frm.gantt_area.empty();
|
||||
erpnext.show_task_gantt(cur_frm.gantt_area, cur_frm.docname);
|
||||
} else {
|
||||
if(cur_frm.gantt_area)
|
||||
cur_frm.gantt_area.empty();
|
||||
cur_frm.add_custom_button("Gantt Chart", function() {
|
||||
wn.route_options = {"project": doc.name}
|
||||
wn.set_route("Gantt", "Task");
|
||||
}, "icon-tasks");
|
||||
cur_frm.add_custom_button("Tasks", function() {
|
||||
wn.route_options = {"project": doc.name}
|
||||
wn.set_route("List", "Task");
|
||||
}, "icon-list");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,57 +18,14 @@ from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import flt, getdate
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document
|
||||
from webnotes.model.bean import copy_doclist
|
||||
from webnotes import msgprint
|
||||
|
||||
sql = webnotes.conn.sql
|
||||
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# Get Customer Details along with its primary contact details
|
||||
# ==============================================================
|
||||
def get_customer_details(self):
|
||||
details =sql("select address, territory, customer_group,customer_name from `tabCustomer` where name=%s and docstatus!=2",(self.doc.customer),as_dict=1)
|
||||
if details:
|
||||
ret = {
|
||||
'customer_address' : details and details[0]['address'] or '',
|
||||
'territory' : details and details[0]['territory'] or '',
|
||||
'customer_group' : details and details[0]['customer_group'] or '',
|
||||
'customer_name' : details and details[0]['customer_name'] or ''
|
||||
}
|
||||
#get primary contact details(this is done separately coz. , if join query used & no primary contact thn it would not be able to fetch customer details)
|
||||
contact_det = sql("select contact_name, phone, email_id from `tabContact` where customer_name='%s' and is_customer=1 and is_primary_contact=1 and docstatus!=2" %(self.doc.customer), as_dict = 1)
|
||||
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
|
||||
ret['contact_no'] = contact_det and contact_det[0]['phone'] or ''
|
||||
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
|
||||
return ret
|
||||
else:
|
||||
msgprint("Customer : %s does not exist in system." % (self.doc.customer))
|
||||
raise Exception
|
||||
|
||||
# Get customer's contact person details
|
||||
# ==============================================================
|
||||
def get_contact_details(self):
|
||||
contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s' and docstatus != 2" %(self.doc,contact_person,self.doc.customer), as_dict=1)
|
||||
if contact:
|
||||
ret = {
|
||||
'contact_no' : contact and contact[0]['contact_no'] or '',
|
||||
'email_id' : contact and contact[0]['email_id'] or ''
|
||||
}
|
||||
return ret
|
||||
else:
|
||||
msgprint("Contact Person : %s does not exist in the system." % (self.doc,contact_person))
|
||||
raise Exception
|
||||
|
||||
#calculate gross profit
|
||||
#=============================================
|
||||
def get_gross_profit(self):
|
||||
pft, per_pft =0, 0
|
||||
pft = flt(self.doc.project_value) - flt(self.doc.est_material_cost)
|
||||
@@ -77,16 +34,15 @@ class DocType:
|
||||
ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft}
|
||||
return ret
|
||||
|
||||
# validate
|
||||
#================================================
|
||||
def validate(self):
|
||||
"""validate start date before end date"""
|
||||
if self.doc.project_start_date and self.doc.completion_date:
|
||||
if getdate(self.doc.completion_date) < getdate(self.doc.project_start_date):
|
||||
msgprint("Expected Completion Date can not be less than Project Start Date")
|
||||
raise Exception
|
||||
|
||||
def on_update(self):
|
||||
# update milestones
|
||||
"""add events for milestones"""
|
||||
webnotes.conn.sql("""delete from tabEvent where ref_type='Project' and ref_name=%s""",
|
||||
self.doc.name)
|
||||
for d in self.doclist:
|
||||
@@ -103,3 +59,12 @@ class DocType:
|
||||
event.ref_type = 'Project'
|
||||
event.ref_name = self.doc.name
|
||||
event.save(1)
|
||||
|
||||
def update_percent_complete(self):
|
||||
total = webnotes.conn.sql("""select count(*) from tabTask where project=%s""",
|
||||
self.doc.name)[0][0]
|
||||
completed = webnotes.conn.sql("""select count(*) from tabTask where
|
||||
project=%s and status='Closed'""", self.doc.name)[0][0]
|
||||
webnotes.conn.set_value("Project", self.doc.name, "percent_complete",
|
||||
int(float(completed) / total * 100))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"creation": "2013-03-07 11:55:07",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-03 17:03:08",
|
||||
"modified": "2013-06-07 12:38:37",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
@@ -26,19 +26,14 @@
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Project",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"role": "Projects User",
|
||||
"submit": 0,
|
||||
"write": 1
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
@@ -145,19 +140,6 @@
|
||||
"options": "Internal\nExternal\nOther",
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"description": "Tasks belonging to this Project.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "sb_tasks",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Tasks"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "project_tasks",
|
||||
"fieldtype": "HTML",
|
||||
"label": "Project Tasks"
|
||||
},
|
||||
{
|
||||
"description": "Important dates and commitments in your project life cycle",
|
||||
"doctype": "DocField",
|
||||
@@ -196,6 +178,14 @@
|
||||
"oldfieldtype": "Text Editor",
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "percent_complete",
|
||||
"fieldtype": "Percent",
|
||||
"in_list_view": 1,
|
||||
"label": "Percent Complete",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "company",
|
||||
@@ -290,6 +280,18 @@
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"role": "Projects User",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 1,
|
||||
"role": "All"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user