billable field access from grid

This commit is contained in:
Rohit Waghchaure 2016-07-18 18:07:02 +05:30
parent 5f9566f3af
commit f14bf502ef
2 changed files with 19 additions and 23 deletions

View File

@ -5,7 +5,8 @@ cur_frm.add_fetch('employee', 'employee_name', 'employee_name');
frappe.ui.form.on("Timesheet", { frappe.ui.form.on("Timesheet", {
setup: function(frm) { setup: function(frm) {
frm.get_field('time_logs').grid.editable_fields = [ frm.get_field('time_logs').grid.editable_fields = [
{fieldname: 'activity_type', columns: 4}, {fieldname: 'billable', columns: 2},
{fieldname: 'activity_type', columns: 2},
{fieldname: 'from_time', columns: 2}, {fieldname: 'from_time', columns: 2},
{fieldname: 'hours', columns: 2}, {fieldname: 'hours', columns: 2},
{fieldname: 'to_time', columns: 2}, {fieldname: 'to_time', columns: 2},
@ -37,7 +38,7 @@ frappe.ui.form.on("Timesheet", {
refresh: function(frm) { refresh: function(frm) {
if(frm.doc.docstatus==1) { if(frm.doc.docstatus==1) {
if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0 if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0
&& frm.doc.employee){ && !frm.doc.production_order){
frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") }, frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") },
"icon-file-alt"); "icon-file-alt");
} }
@ -106,25 +107,20 @@ frappe.ui.form.on("Timesheet Detail", {
activity_type: function(frm, cdt, cdn) { activity_type: function(frm, cdt, cdn) {
child = locals[cdt][cdn]; child = locals[cdt][cdn];
if(frm.doc.employee || frm.doc.production_order){ frappe.call({
frappe.call({ method: "erpnext.projects.doctype.timesheet.timesheet.get_activity_cost",
method: "erpnext.projects.doctype.timesheet.timesheet.get_activity_cost", args: {
args: { employee: frm.doc.employee,
employee: frm.doc.employee, activity_type: child.activity_type
activity_type: child.activity_type },
}, callback: function(r){
callback: function(r){ if(r.message){
if(r.message){ frappe.model.set_value(cdt, cdn, 'billing_rate', r.message['billing_rate']);
frappe.model.set_value(cdt, cdn, 'billing_rate', r.message['billing_rate']); frappe.model.set_value(cdt, cdn, 'costing_rate', r.message['costing_rate']);
frappe.model.set_value(cdt, cdn, 'costing_rate', r.message['costing_rate']); calculate_billing_costing_amount(frm, cdt, cdn)
calculate_billing_costing_amount(frm, cdt, cdn)
}
} }
}) }
}else { })
frappe.model.set_value(cdt, cdn, 'activity_type', null);
frappe.show_alert(__("Select employee"))
}
} }
}); });

View File

@ -14,7 +14,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"depends_on": "eval:parent.employee", "depends_on": "eval:!parent.production_order",
"fieldname": "billable", "fieldname": "billable",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@ -163,7 +163,7 @@
"allow_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"depends_on": "eval:parent.employee", "depends_on": "eval:!parent.production_order",
"fieldname": "section_break_11", "fieldname": "section_break_11",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@ -532,7 +532,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-07-11 03:28:09.410519", "modified": "2016-07-18 13:57:29.873073",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Projects", "module": "Projects",
"name": "Timesheet Detail", "name": "Timesheet Detail",