From 0ecad336429e5789c2441d46587a71de27e67b60 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Fri, 4 Nov 2016 12:26:55 +0530 Subject: [PATCH] cleanup and fixes --- .../doctype/sales_invoice/sales_invoice.js | 30 ++++--- erpnext/patches.txt | 6 +- .../add_account_user_role_for_timesheet.py | 31 +++++++ .../projects/doctype/timesheet/timesheet.json | 86 +++++++++---------- .../projects/doctype/timesheet/timesheet.py | 13 +-- .../doctype/sales_order/sales_order.json | 6 +- 6 files changed, 98 insertions(+), 74 deletions(-) create mode 100644 erpnext/patches/v7_1/add_account_user_role_for_timesheet.py diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 47f1a5c1c3..9b4306e68d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -483,20 +483,22 @@ frappe.ui.form.on('Sales Invoice', { frappe.ui.form.on('Sales Invoice Timesheet', { time_sheet: function(frm, cdt, cdn){ var d = locals[cdt][cdn]; - frappe.call({ - method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data", - args: { - 'name': d.time_sheet, - 'project': frm.doc.project || null - }, - callback: function(r, rt) { - if(r.message){ - data = r.message; - frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours); - frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount); - frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail); + if(d.time_sheet) { + frappe.call({ + method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data", + args: { + 'name': d.time_sheet, + 'project': frm.doc.project || null + }, + callback: function(r, rt) { + if(r.message){ + data = r.message; + frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours); + frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount); + frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail); + } } - } - }) + }) + } } }) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f3905dee2c..c7b61d482b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -340,6 +340,8 @@ erpnext.patches.v7_0.update_status_of_zero_amount_sales_order erpnext.patches.v7_1.add_field_for_task_dependent erpnext.patches.v7_0.repost_bin_qty_and_item_projected_qty erpnext.patches.v7_1.set_prefered_contact_email -execute:frappe.db.sql("update `tabSingles` set value = 1 where field = 'unlink_payment_on_cancellation_of_invoice' and doctype = 'Accounts Settings'") +execute:frappe.reload_doc('accounts', 'doctype', 'accounts_settings') +execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 0) execute:frappe.db.sql("update `tabStock Entry` set total_amount = null where purpose in('Repack', 'Manufacture')") -erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01 \ No newline at end of file +erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01 +erpnext.patches.v7_1.add_account_user_role_for_timesheet \ No newline at end of file diff --git a/erpnext/patches/v7_1/add_account_user_role_for_timesheet.py b/erpnext/patches/v7_1/add_account_user_role_for_timesheet.py new file mode 100644 index 0000000000..7372b0cc5f --- /dev/null +++ b/erpnext/patches/v7_1/add_account_user_role_for_timesheet.py @@ -0,0 +1,31 @@ +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe + +def execute(): + if not frappe.db.get_value('DocPerm', {'parent': 'Timesheet', 'role': 'Accounts User', 'permlevel': 1}): + doc = frappe.get_doc('DocType', 'Timesheet') + doc.append('permissions', { + 'role': "Accounts User", + 'permlevel': 0, + 'read': 1, + 'write': 1, + 'create': 1, + 'delete': 1, + 'submit': 1, + 'cancel': 1, + 'amend': 1, + 'report': 1, + 'email': 1 + }) + + doc.append('permissions', { + 'role': "Accounts User", + 'permlevel': 1, + 'read': 1, + 'write': 1 + }) + + doc.save(ignore_permissions=True) \ No newline at end of file diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json index 18d153dbb5..160e3b7fe4 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.json +++ b/erpnext/projects/doctype/timesheet/timesheet.json @@ -847,7 +847,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-11-03 16:06:32.259060", + "modified": "2016-11-04 18:27:08.484033", "modified_by": "Administrator", "module": "Projects", "name": "Timesheet", @@ -916,48 +916,6 @@ "submit": 1, "write": 1 }, - { - "amend": 1, - "apply_user_permissions": 0, - "cancel": 1, - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "is_custom": 0, - "permlevel": 0, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 1, - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "apply_user_permissions": 0, - "cancel": 0, - "create": 0, - "delete": 0, - "email": 1, - "export": 1, - "if_owner": 0, - "import": 0, - "is_custom": 0, - "permlevel": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "Accounts User", - "set_user_permissions": 0, - "share": 1, - "submit": 0, - "write": 1 - }, { "amend": 0, "apply_user_permissions": 0, @@ -978,6 +936,48 @@ "share": 0, "submit": 0, "write": 1 + }, + { + "amend": 1, + "apply_user_permissions": 0, + "cancel": 1, + "create": 1, + "delete": 1, + "email": 1, + "export": 0, + "if_owner": 0, + "import": 0, + "is_custom": 0, + "permlevel": 0, + "print": 0, + "read": 1, + "report": 1, + "role": "Accounts User", + "set_user_permissions": 0, + "share": 0, + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 0, + "delete": 0, + "email": 0, + "export": 0, + "if_owner": 0, + "import": 0, + "is_custom": 0, + "permlevel": 1, + "print": 0, + "read": 1, + "report": 0, + "role": "Accounts User", + "set_user_permissions": 0, + "share": 0, + "submit": 0, + "write": 1 } ], "quick_entry": 0, diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 9e32b528be..02e5f18f84 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -322,18 +322,7 @@ def make_sales_invoice(source_name, target=None): @frappe.whitelist() def make_salary_slip(source_name, target_doc=None): target = frappe.new_doc("Salary Slip") - set_missing_values(source_name, target) - - target.append("timesheets", get_mapped_doc("Timesheet", source_name, { - "Timesheet": { - "doctype": "Salary Slip Timesheet", - "field_map": { - "total_hours": "working_hours", - "name": "time_sheet" - }, - } - })) - + set_missing_values(source_name, target) target.run_method("get_emp_and_leave_details") return target diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index b59c066cc5..888a231cc6 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -372,7 +372,7 @@ "in_list_view": 0, "label": "Customer's Purchase Order", "length": 0, - "no_copy": 0, + "no_copy": 1, "oldfieldname": "po_no", "oldfieldtype": "Data", "permlevel": 0, @@ -403,7 +403,7 @@ "in_list_view": 0, "label": "Customer's Purchase Order Date", "length": 0, - "no_copy": 0, + "no_copy": 1, "oldfieldname": "po_date", "oldfieldtype": "Date", "permlevel": 0, @@ -3226,7 +3226,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-11-03 16:07:46.757630", + "modified": "2016-11-05 08:09:08.921026", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order",