From 26cf01aaba21c73fe4a554dc954cc63dfde4a731 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 22 Jul 2016 13:24:33 +0530 Subject: [PATCH] [mionr] fixes and cleanups --- erpnext/accounts/page/pos/pos.js | 6 ++-- .../controllers/sales_and_purchase_return.py | 4 +-- erpnext/patches.txt | 1 + .../v7_0/calculate_total_costing_amount.py | 14 ++++++++ .../projects/doctype/timesheet/timesheet.js | 17 ++++++---- .../projects/doctype/timesheet/timesheet.json | 33 ++++++++++++++++--- .../projects/doctype/timesheet/timesheet.py | 17 +++++++--- .../timesheet_detail/timesheet_detail.json | 12 +++---- 8 files changed, 76 insertions(+), 28 deletions(-) create mode 100644 erpnext/patches/v7_0/calculate_total_costing_amount.py diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index cb57ff406f..a89f40e0ba 100644 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -69,13 +69,13 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ var me = this; // navigator.onLine this.connection_status = false; - this.page.set_indicator("Offline", "grey") + this.page.set_indicator(__("Offline"), "grey") frappe.call({ method:"frappe.handler.ping", callback: function(r){ if(r.message){ me.connection_status = true; - me.page.set_indicator("Online", "green") + me.page.set_indicator(__("Online"), "green") } } }) @@ -278,7 +278,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ "fieldtype": "Data", "label": "Item", "fieldname": "pos_item", - "placeholder": "Search Item" + "placeholder": __("Search Item") }, parent: this.wrapper.find(".search-area"), only_input: true, diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 37b13c3e2d..8d30247acf 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -167,9 +167,7 @@ def make_return_doc(doctype, source_name, target_doc=None): target_doc.qty = -1* source_doc.qty if doctype == "Purchase Receipt": target_doc.received_qty = -1* source_doc.qty - target_doc.prevdoc_doctype = source_doc.prevdoc_doctype - target_doc.prevdoc_docname = source_doc.prevdoc_docname - target_doc.prevdoc_detail_docname = source_doc.prevdoc_detail_docname + target_doc.purchase_order = source_doc.purchase_order elif doctype == "Purchase Invoice": target_doc.received_qty = -1* source_doc.qty target_doc.purchase_order = source_doc.purchase_order diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c1813dc088..3e31d5ec20 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -302,3 +302,4 @@ erpnext.patches.v7_0.setup_account_table_for_expense_claim_type_if_exists erpnext.patches.v7_0.migrate_schools_to_erpnext erpnext.patches.v7_0.remove_administrator_role_in_doctypes erpnext.patches.v7_0.rename_fee_amount_to_fee_component +erpnext.patches.v7_0.calculate_total_costing_amount diff --git a/erpnext/patches/v7_0/calculate_total_costing_amount.py b/erpnext/patches/v7_0/calculate_total_costing_amount.py new file mode 100644 index 0000000000..f426904074 --- /dev/null +++ b/erpnext/patches/v7_0/calculate_total_costing_amount.py @@ -0,0 +1,14 @@ +import frappe +from frappe.utils import flt + +def execute(): + frappe.reload_doc('projects', 'doctype', 'timesheet') + + for data in frappe.get_all('Timesheet', fields=["name, total_costing_amount"], + filters = [["docstatus", "<", "2"]]): + if flt(data.total_costing_amount) == 0.0: + ts = frappe.get_doc('Timesheet', data.name) + ts.update_cost() + ts.calculate_total_amounts() + ts.flags.ignore_validate_update_after_submit = True + ts.save() diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index f816defe60..f3dfefa7d0 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -5,11 +5,11 @@ cur_frm.add_fetch('employee', 'employee_name', 'employee_name'); frappe.ui.form.on("Timesheet", { setup: function(frm) { frm.get_field('time_logs').grid.editable_fields = [ - {fieldname: 'billable', columns: 2}, + {fieldname: 'billable', columns: 1}, {fieldname: 'activity_type', columns: 2}, - {fieldname: 'from_time', columns: 2}, - {fieldname: 'hours', columns: 2}, - {fieldname: 'to_time', columns: 2}, + {fieldname: 'from_time', columns: 3}, + {fieldname: 'hours', columns: 1}, + {fieldname: 'project', columns: 3} ]; frm.fields_dict.employee.get_query = function() { @@ -22,7 +22,8 @@ frappe.ui.form.on("Timesheet", { child = locals[cdt][cdn]; return{ filters: { - 'project': child.project + 'project': child.project, + 'status': ["!=", "Closed"] } } } @@ -37,8 +38,7 @@ frappe.ui.form.on("Timesheet", { refresh: function(frm) { if(frm.doc.docstatus==1) { - if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0 - && !frm.doc.production_order){ + if(!frm.doc.sales_invoice && frm.doc.total_billing_amount > 0){ frm.add_custom_button(__("Make Sales Invoice"), function() { frm.trigger("make_invoice") }, "icon-file-alt"); } @@ -147,13 +147,16 @@ var calculate_time_and_amount = function(frm) { var tl = frm.doc.time_logs || []; total_hr = 0; total_billing_amount = 0; + total_costing_amount = 0; for(var i=0; i