added templates for projects

This commit is contained in:
Rushabh Mehta 2014-08-04 16:37:23 +05:30 committed by Anand Doshi
parent 873141c1a5
commit c9bd3f5d4a
24 changed files with 250 additions and 27 deletions

View File

@ -74,3 +74,4 @@ execute:frappe.delete_doc("Page", "trial-balance") #2014-07-22
erpnext.patches.v4_2.delete_old_print_formats #2014-07-29
erpnext.patches.v4_2.toggle_rounded_total #2014-07-30
erpnext.patches.v4_2.fix_account_master_type
erpnext.patches.v4_2.update_project_milestones

View File

@ -0,0 +1,7 @@
import frappe
def execute():
for project in frappe.db.sql_list("select name from tabProject"):
p = frappe.get_doc("Project", project)
p.update_milestones_completed()
p.db_set("percent_milestones_completed", p.percent_milestones_completed)

View File

@ -4,7 +4,7 @@
// show tasks
cur_frm.cscript.refresh = function(doc) {
if(!doc.__islocal) {
cur_frm.appframe.add_button(__("Gantt Chart"), function() {
cur_frm.add_custom_button(__("Gantt Chart"), function() {
frappe.route_options = {"project": doc.name}
frappe.set_route("Gantt", "Task");
}, "icon-tasks");
@ -19,4 +19,4 @@ cur_frm.fields_dict.customer.get_query = function(doc,cdt,cdn) {
return{
query: "erpnext.controllers.queries.customer_query"
}
}
}

View File

@ -136,6 +136,13 @@
"permlevel": 0,
"search_index": 0
},
{
"fieldname": "percent_milestones_completed",
"fieldtype": "Percent",
"label": "% Milestones Completed",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "section_break0",
"fieldtype": "Section Break",
@ -158,7 +165,7 @@
"fieldname": "percent_complete",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "Percent Complete",
"label": "% Tasks Completed",
"permlevel": 0,
"read_only": 1
},
@ -259,7 +266,7 @@
"icon": "icon-puzzle-piece",
"idx": 1,
"max_attachments": 4,
"modified": "2014-06-24 12:44:19.530707",
"modified": "2014-08-04 03:22:11.416219",
"modified_by": "Administrator",
"module": "Projects",
"name": "Project",

View File

@ -26,6 +26,13 @@ class Project(Document):
if getdate(self.completion_date) < getdate(self.project_start_date):
frappe.throw(_("Expected Completion Date can not be less than Project Start Date"))
self.update_milestones_completed()
def update_milestones_completed(self):
if self.project_milestones:
completed = filter(lambda x: x.status=="Completed", self.project_milestones)
self.percent_milestones_completed = len(completed) * 100 / len(self.project_milestones)
def on_update(self):
self.add_calendar_event()
@ -38,6 +45,7 @@ class Project(Document):
frappe.db.set_value("Project", self.name, "percent_complete",
int(float(completed) / total * 100))
def add_calendar_event(self):
# delete any earlier event for this project
delete_events(self.doctype, self.name)

View File

@ -0,0 +1,38 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-10">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
<span class="label label-{%= frappe.utils.guess_style(doc.status) %} filterable"
data-filter="status,=,{%= doc.status %}">
{%= doc.status %}
</span>
<span class="label label-{%= frappe.utils.guess_style(doc.priority) %} filterable"
data-filter="priority,=,{%= doc.priority %}">
{%= doc.priority %}
</span>
{% if(doc.status==="Open" && doc.completion_date
&& frappe.datetime.get_diff(doc.completion_date) <= 0) { %}
<span class="label label-danger filterable"
data-filter="completion_date,>=,Today"
title="{%= doc.get_formatted("completion_date") %}">
{%= __("Overdue") %}
</span>
{% } else if(doc.completion_date) { %}
<span class="label label-default filterable"
data-filter="completion_date,=,{%= doc.completion_date %}"
title="{%= __("Due Date") %}">
{%= doc.get_formatted("completion_date") %}
</span>
{% } %}
</div>
</div>
<div class="col-xs-1 text-right">
{% var completed = doc.percent_complete, title = __("% Tasks Completed") %}
{% include "templates/form_grid/includes/progress.html" %}
</div>
<div class="col-xs-1 text-right">
{% var completed = doc.percent_milestones_completed,
title = __("% Milestones Achieved") %}
{% include "templates/form_grid/includes/progress.html" %}
</div>
</div>

View File

@ -0,0 +1,5 @@
frappe.listview_settings['Project'] = {
add_fields: ["status", "priority", "is_active", "percent_complete",
"percent_milestones_completed", "completion_date"],
filters:[["status","=", "Open"]]
};

View File

@ -62,8 +62,10 @@ def get_events(start, end, filters=None):
data = frappe.db.sql("""select name, exp_start_date, exp_end_date,
subject, status, project from `tabTask`
where ((exp_start_date between '%(start)s' and '%(end)s') \
or (exp_end_date between '%(start)s' and '%(end)s'))
where ((ifnull(exp_start_date, '0000-00-00')!= '0000-00-00') \
and (exp_start_date between '%(start)s' and '%(end)s') \
or ((ifnull(exp_start_date, '0000-00-00')!= '0000-00-00') \
and exp_end_date between '%(start)s' and '%(end)s'))
%(conditions)s""" % {
"start": start,
"end": end,

View File

@ -0,0 +1,34 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
{% if(doc.project) { %}
<span class="filterable" style="margin-right: 8px;"
data-filter="project,=,{%= doc.project %}">
{%= doc.project %}</span>
{% } %}
<span class="label label-{%= frappe.utils.guess_style(doc.status) %} filterable"
data-filter="status,=,{%= doc.status %}">
{%= doc.status %}
</span>
<span class="label label-{%= frappe.utils.guess_style(doc.priority) %} filterable"
data-filter="priority,=,{%= doc.priority %}">
{%= doc.priority %}
</span>
{% if(doc.status==="Open" && doc.exp_end_date
&& frappe.datetime.get_diff(doc.exp_end_date) <= 0) { %}
<span class="label label-danger filterable"
data-filter="exp_end_date,>=,Today"
title="{%= doc.get_formatted("exp_end_date") %}">
{%= __("Overdue") %}
</span>
{% } else if(doc.exp_end_date) { %}
<span class="label label-default filterable"
data-filter="exp_end_date,=,{%= doc.exp_end_date %}"
title="{%= __("Due Date") %}">
{%= doc.get_formatted("exp_end_date") %}
</span>
{% } %}
</div>
</div>
</div>

View File

@ -0,0 +1,4 @@
frappe.listview_settings['Task'] = {
add_fields: ["project", "status", "priority", "exp_end_date"],
filters:[["status","=", "Open"]]
};

View File

@ -3,12 +3,27 @@
frappe.provide("erpnext.projects");
erpnext.projects.TimeLog = frappe.ui.form.Controller.extend({
onload: function() {
this.frm.set_query("task", erpnext.queries.task);
}
frappe.ui.form.on("Time Log", "onload", function(frm) {
frm.set_query("task", erpnext.queries.task);
});
cur_frm.cscript = new erpnext.projects.TimeLog({frm: cur_frm});
// set to time if hours is updated
frappe.ui.form.on("Time Log", "hours", function(frm) {
if(!frm.doc.from_time) {
frm.set_value("from_time", frappe.datetime.now_datetime());
}
var d = moment(frm.doc.from_time);
d.add(frm.doc.hours, "hours");
frm._setting_hours = true;
frm.set_value("to_time", d.format(moment.defaultDatetimeFormat));
frm._setting_hours = false;
});
cur_frm.add_fetch('task','project','project');
// set hours if to_time is updated
frappe.ui.form.on("Time Log", "to_time", function(frm) {
if(frm._setting_hours) return;
frm.set_value("hours", moment(cur_frm.doc.to_time).diff(moment(cur_frm.doc.from_time),
"hours"));
});
cur_frm.add_fetch('task','project','project');

View File

@ -26,6 +26,14 @@
"read_only": 0,
"reqd": 1
},
{
"fieldname": "hours",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Hours",
"permlevel": 0,
"read_only": 0
},
{
"fieldname": "to_time",
"fieldtype": "Datetime",
@ -35,14 +43,6 @@
"read_only": 0,
"reqd": 1
},
{
"fieldname": "hours",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Hours",
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "column_break_3",
"fieldtype": "Column Break",
@ -152,7 +152,7 @@
"icon": "icon-time",
"idx": 1,
"is_submittable": 1,
"modified": "2014-05-27 03:49:21.143356",
"modified": "2014-08-04 05:23:15.740050",
"modified_by": "Administrator",
"module": "Projects",
"name": "Time Log",

View File

@ -0,0 +1,25 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
{% if(doc.billable) { %}
<span style="margin-right: 8px;"
title="{%= __("Billable") %}" class="filterable"
data-filter="billable,=,Yes">
<i class="icon-money text-muted"></i>
</span>
{% } %}
<span class="label label-info filterable" style="margin-right: 8px;"
data-filter="activity_type,=,{%= doc.activity_type %}">
{%= doc.activity_type %}</span>
<span style="margin-right: 8px;" class="text-muted">
({%= doc.hours + " " + __("hours") %})
</span>
{% if(doc.project) { %}
<span class="filterable" style="margin-right: 8px;"
data-filter="project,=,{%= doc.project %}">
{%= doc.project %}</span>
{% } %}
</div>
</div>
</div>

View File

@ -3,10 +3,10 @@
// render
frappe.listview_settings['Time Log'] = {
add_fields: ["`tabTime Log`.`status`", "`tabTime Log`.`billable`", "`tabTime Log`.`activity_type`"],
add_fields: ["status", "billable", "activity_type", "task", "project", "hours"],
selectable: true,
onload: function(me) {
me.appframe.add_button(__("Make Time Log Batch"), function() {
me.appframe.add_primary_action(__("Make Time Log Batch"), function() {
var selected = me.get_checked_items() || [];
if(!selected.length) {

View File

@ -0,0 +1,15 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
<span class="label label-{%= doc.status=="Billed" ? "success" :
frappe.utils.guess_style(doc.status) %} filterable"
style="margin-right: 8px;"
data-filter="status,=,{%= doc.status %}">
{%= doc.status %}</span>
<span style="margin-right: 8px;" class="text-muted">
({%= doc.total_hours + " " + __("hours") %})
</span>
</div>
</div>
</div>

View File

@ -0,0 +1,4 @@
frappe.listview_settings['Time Log Batch'] = {
add_fields: ["status", "total_hours", "rate"],
filters:[["status","in", "Draft,Submitted"]]
};

View File

@ -1,4 +1,5 @@
frappe.listview_settings['Quotation'] = {
add_fields: ["customer_name", "quotation_to", "grand_total", "status",
"company", "currency", "order_type", "lead", "customer"]
"company", "currency", "order_type", "lead", "customer"],
filters: [["status", "=", "Submitted"]]
};

View File

@ -1,5 +1,5 @@
frappe.listview_settings['Sales Order'] = {
add_fields: ["grand_total", "company", "currency", "customer",
"customer_name", "per_delivered", "per_billed", "delivery_date"],
filters: [["per_delivered", "<", "100"]]
filters: [["per_delivered", "<", 100]]
};

View File

@ -0,0 +1,21 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
<span class="filterable" style="margin-right: 8px;"
data-filter="item,=,{%= doc.item %}">
{%= doc.item %}</span>
{% if(doc.expiry_date && frappe.datetime.get_diff(doc.expiry_date) <= 0) { %}
<span class="label label-danger filterable"
data-filter="expiry_date,>=,Today">
{%= __("Expired") %}: {%= doc.get_formatted("expiry_date") %}
</span>
{% } else if(doc.expiry_date) { %}
<span class="label label-default filterable"
data-filter="expiry_date,=,{%= doc.expiry_date %}">
{%= __("Expiry") %}: {%= doc.get_formatted("expiry_date") %}
</span>
{% } %}
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
frappe.listview_settings['Batch'] = {
add_fields: ["item", "expiry_date"]
};

View File

@ -1,3 +1,4 @@
frappe.listview_settings['Material Request'] = {
add_fields: ["material_request_type", "status", "per_ordered"]
add_fields: ["material_request_type", "status", "per_ordered"],
filters: [["per_ordered", "<", 100]]
};

View File

@ -0,0 +1,28 @@
<div class="row" style="max-height: 30px;">
<div class="col-xs-12">
<div class="text-ellipsis">
{%= list.get_avatar_and_id(doc) %}
<span class="filterable" style="margin-right: 8px;"
data-filter="item_code,=,{%= doc.item_code %}">
{%= doc.item_code %}</span>
{% var icon = {
"Available": ["icon-ok", "label-success"],
"Not Available": ["icon-remove", "label-danger"],
"Delivered": ["icon-truck", "label-success"],
"Purchase Returned": ["icon-retweet", "label-warning"],
"Sales Returned": ["icon-retweet", "label-warning"],
}[doc.status]; %}
<span class="label {%= icon[1] %} filterable"
data-filter="status,=,{%= doc.status %}"
title="{%= doc.purpose %}">
<i class="{%= icon[0] %}"></i> {%= doc.status %}
</span>
{% if(doc.warehouse) { %}
<span class="label label-default filterable"
data-filter="warehouse,=,{%= doc.warehouse %}">
{%= doc.warehouse %}
</span>
{% } %}
</div>
</div>
</div>

View File

@ -0,0 +1,3 @@
frappe.listview_settings['Serial No'] = {
add_fields: ["status", "item_code", "warehouse"]
};

View File

@ -43,6 +43,7 @@
"description": "Account for the warehouse (Perpetual Inventory) will be created under this Account.",
"fieldname": "create_account_under",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Parent Account",
"options": "Account",
"permlevel": 0
@ -150,7 +151,7 @@
],
"icon": "icon-building",
"idx": 1,
"modified": "2014-05-27 03:49:22.483111",
"modified": "2014-08-04 02:55:16.750848",
"modified_by": "Administrator",
"module": "Stock",
"name": "Warehouse",