[minor] ux fixes
diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js
index 7d14d9e..2edfa9e 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.js
+++ b/erpnext/projects/doctype/timesheet/timesheet.js
@@ -1,9 +1,9 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-cur_frm.add_fetch('employee', 'employee_name', 'employee_name');
frappe.ui.form.on("Timesheet", {
setup: function(frm) {
+ frm.add_fetch('employee', 'employee_name', 'employee_name');
frm.fields_dict.employee.get_query = function() {
return {
filters:{
@@ -51,8 +51,8 @@
}
if(frm.doc.per_billed > 0) {
- cur_frm.fields_dict["time_logs"].grid.toggle_enable("billing_hours", false);
- cur_frm.fields_dict["time_logs"].grid.toggle_enable("billable", false);
+ frm.fields_dict["time_logs"].grid.toggle_enable("billing_hours", false);
+ frm.fields_dict["time_logs"].grid.toggle_enable("billable", false);
}
},
@@ -77,7 +77,7 @@
},
from_time: function(frm, cdt, cdn) {
- calculate_end_time(frm, cdt, cdn)
+ calculate_end_time(frm, cdt, cdn);
},
to_time: function(frm, cdt, cdn) {
@@ -109,18 +109,20 @@
},
activity_type: function(frm, cdt, cdn) {
- var child = locals[cdt][cdn];
+ frm.script_manager.copy_from_first_row('time_logs', frm.selected_doc,
+ 'project');
+
frappe.call({
method: "erpnext.projects.doctype.timesheet.timesheet.get_activity_cost",
args: {
employee: frm.doc.employee,
- activity_type: child.activity_type
+ activity_type: frm.selected_doc.activity_type
},
callback: function(r){
if(r.message){
frappe.model.set_value(cdt, cdn, 'billing_rate', r.message['billing_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);
}
}
})
@@ -174,8 +176,8 @@
}
}
- cur_frm.set_value("total_billable_hours", total_billing_hr);
- cur_frm.set_value("total_hours", total_working_hr);
- cur_frm.set_value("total_billable_amount", total_billable_amount);
- cur_frm.set_value("total_costing_amount", total_costing_amount);
+ frm.set_value("total_billable_hours", total_billing_hr);
+ frm.set_value("total_hours", total_working_hr);
+ frm.set_value("total_billable_amount", total_billable_amount);
+ frm.set_value("total_costing_amount", total_costing_amount);
}
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index ca822b1..8ad64d2 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -16,11 +16,11 @@
// or set discount
item.discount_percentage = 0;
item.margin_type = 'Amount';
- item.margin_rate_or_amount = flt(item.rate - item.price_list_rate,
+ item.margin_rate_or_amount = flt(item.rate - item.price_list_rate,
precision("margin_rate_or_amount", item));
item.rate_with_margin = item.rate;
} else {
- item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
+ item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
precision("discount_percentage", item));
item.margin_type = '';
item.margin_rate_or_amount = 0;
@@ -602,8 +602,10 @@
toggle_conversion_factor: function(item) {
// toggle read only property for conversion factor field if the uom and stock uom are same
- this.frm.fields_dict.items.grid.toggle_enable("conversion_factor",
- (item.uom != item.stock_uom)? true: false)
+ if(this.frm.get_field('items').grid.fields_map.conversion_factor) {
+ this.frm.fields_dict.items.grid.toggle_enable("conversion_factor",
+ (item.uom != item.stock_uom)? true: false);
+ }
},
qty: function(doc, cdt, cdn) {
@@ -756,7 +758,7 @@
if(this.frm.doc.ignore_pricing_rule) {
var me = this;
var item_list = [];
-
+
$.each(this.frm.doc["items"] || [], function(i, d) {
if (d.item_code) {
item_list.push({
@@ -1144,7 +1146,7 @@
if(!item.item_code) {
frappe.throw(__("Please enter Item Code to get batch no"));
- } else if (doc.doctype == "Purchase Receipt" ||
+ } else if (doc.doctype == "Purchase Receipt" ||
(doc.doctype == "Purchase Invoice" && doc.update_stock)) {
return {
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 23d1fd4..3361020 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -30,11 +30,15 @@
});
frappe.ui.form.on("Material Request Item", {
- "qty": function (frm, doctype, name) {
+ qty: function (frm, doctype, name) {
var d = locals[doctype][name];
if (flt(d.qty) < flt(d.min_order_qty)) {
frappe.msgprint(__("Warning: Material Requested Qty is less than Minimum Order Qty"));
}
+ },
+ item_code: function(frm, doctype, name) {
+ frm.script_manager.copy_from_first_row('items', frm.selected_doc,
+ 'schedule_date');
}
});
@@ -118,18 +122,6 @@
},
- schedule_date: function(doc, cdt, cdn) {
- var val = locals[cdt][cdn].schedule_date;
- if(val) {
- $.each((doc.items || []), function(i, d) {
- if(!d.schedule_date) {
- d.schedule_date = val;
- }
- });
- refresh_field("items");
- }
- },
-
get_items_from_bom: function() {
var d = new frappe.ui.Dialog({
title: __("Get Items from BOM"),