From 8f62aec2e35ed93548d7cf7f6639781b1ee6e634 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 1 Jan 2019 13:54:54 +0530 Subject: [PATCH 1/8] [Fix] Not able to delete department --- erpnext/utilities/transaction_base.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 4845e0b960..f845cef9b1 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -146,8 +146,18 @@ class TransactionBase(StatusUpdater): return ret def delete_events(ref_type, ref_name): - frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent` - where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True) + events = frappe.db.sql_list(""" SELECT + distinct `tabEvent`.name + from + `tabEvent`, `tabEvent Participants` + where + `tabEvent`.name = `tabEvent Participants`.parent + and `tabEvent Participants`.reference_doctype = %s + and `tabEvent Participants`.reference_docname = %s + """, (ref_type, ref_name)) or [] + + if events: + frappe.delete_doc("Event", events, for_reload=True) def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None): if isinstance(qty_fields, string_types): From c186f153ff796989683c12b60ccd4a76c4a069ee Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 1 Jan 2019 14:18:14 +0530 Subject: [PATCH 2/8] Added test cases --- .../hr/doctype/department/test_department.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/department/test_department.py b/erpnext/hr/doctype/department/test_department.py index da696613f9..2eeca26e30 100644 --- a/erpnext/hr/doctype/department/test_department.py +++ b/erpnext/hr/doctype/department/test_department.py @@ -1,9 +1,24 @@ # 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 +import unittest test_ignore = ["Leave Block List"] +class TestDepartment(unittest.TestCase): + def test_remove_department_data(self): + doc = create_department("Test Department") + frappe.delete_doc('Department', doc.name) +def create_department(department_name, parent_department=None): + doc = frappe.get_doc({ + 'doctype': 'Department', + 'is_group': 0, + 'parent_department': parent_department, + 'department_name': department_name, + 'company': frappe.defaults.get_defaults().company + }).insert() + + return doc -import frappe test_records = frappe.get_test_records('Department') \ No newline at end of file From 94e35e7a7e233858a1f0670ec64ef2cabfa271eb Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Tue, 1 Jan 2019 17:55:13 +0100 Subject: [PATCH 3/8] Fix #15917 (#16311) --- erpnext/accounts/report/financial_statements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index db733dd1e1..09cf5b1d2f 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -213,7 +213,7 @@ def prepare_data(accounts, balance_must_be, period_list, company_currency): total = 0 row = frappe._dict({ "account": _(d.name), - "parent_account": _(d.parent_account), + "parent_account": _(d.parent_account) if d.parent_account else '', "indent": flt(d.indent), "year_start_date": year_start_date, "year_end_date": year_end_date, From c14c7c84e3d299341fb945c0a7294997012b450b Mon Sep 17 00:00:00 2001 From: Sagar Vora Date: Wed, 2 Jan 2019 21:28:11 +0530 Subject: [PATCH 4/8] fix: leave application and timesheet tests --- erpnext/hr/doctype/leave_application/test_leave_application.py | 2 +- erpnext/projects/doctype/timesheet/test_timesheet.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 4748011b62..a682e8b76f 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -457,7 +457,7 @@ def get_leave_period(): return frappe.get_doc(dict( name = 'Test Leave Period', doctype = 'Leave Period', - from_date = "{0}-01-01".format(now_datetime().year), + from_date = "{0}-12-01".format(now_datetime().year - 1), to_date = "{0}-12-31".format(now_datetime().year), company = "_Test Company", is_active = 1 diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 8c84c11ae9..f1179033be 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -186,6 +186,8 @@ def make_salary_structure_for_timesheet(employee): if not frappe.db.get_value("Salary Structure Assignment", {'employee':employee, 'docstatus': 1}): + frappe.db.set_value('Employee', employee, 'date_of_joining', + add_months(nowdate(), -5)) create_salary_structure_assignment(employee, salary_structure.name) return salary_structure From 8bac5b6e73ed9e46342e8b4d22287348f66f3c64 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Thu, 3 Jan 2019 16:20:35 +0530 Subject: [PATCH 5/8] [minor] Employee is reqd to preview salary slip from salary structure --- erpnext/hr/doctype/salary_structure/salary_structure.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index 033938de36..79d75bfdf6 100755 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -124,6 +124,7 @@ frappe.ui.form.on('Salary Structure', { "label":__("Employee"), "fieldname":"employee", "fieldtype":"Select", + "reqd": true, options: employees }, { fieldname:"fetch", From 3ac57c756ba958a6c1490d55d43afa8d3b8ca1de Mon Sep 17 00:00:00 2001 From: Sahil Khan Date: Fri, 4 Jan 2019 12:57:34 +0530 Subject: [PATCH 6/8] fix: remove print statement from test case --- erpnext/hr/doctype/upload_attendance/test_upload_attendance.py | 1 - 1 file changed, 1 deletion(-) diff --git a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py index 5ab2847dde..6e151d0e3c 100644 --- a/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py +++ b/erpnext/hr/doctype/upload_attendance/test_upload_attendance.py @@ -29,6 +29,5 @@ class TestUploadAttendance(unittest.TestCase): for row in data: if row[1] == employee: filtered_data.append(row) - print(filtered_data) for row in filtered_data: self.assertTrue(getdate(row[3]) >= getdate(date_of_joining) and getdate(row[3]) <= getdate(relieving_date)) From 0d54271d150070bce25d801af9586d2ef7279cc6 Mon Sep 17 00:00:00 2001 From: Frappe Bot Date: Sat, 5 Jan 2019 09:11:14 +0000 Subject: [PATCH 7/8] bumped to version 11.0.3-beta.33 --- erpnext/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 14e4f68864..3ab6752d8c 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -12,7 +12,7 @@ app_license = "GNU General Public License (v3)" source_link = "https://github.com/frappe/erpnext" develop_version = '12.x.x-develop' -staging_version = '11.0.3-beta.32' +staging_version = '11.0.3-beta.33' error_report_email = "support@erpnext.com" From ed6725172d67a476fdfcb1307fec2e63ecc9de61 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Sun, 6 Jan 2019 20:07:18 +0530 Subject: [PATCH 8/8] Replaced str to cstr in genral ledger report --- erpnext/accounts/report/general_ledger/general_ledger.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py index 7e50d9be61..8c3deaff48 100644 --- a/erpnext/accounts/report/general_ledger/general_ledger.py +++ b/erpnext/accounts/report/general_ledger/general_ledger.py @@ -25,7 +25,7 @@ def execute(filters=None): account_details.setdefault(acc.name, acc) if filters.get('party'): - parties = str(filters.get("party")).strip() + parties = cstr(filters.get("party")).strip() filters.party = [d.strip() for d in parties.split(',') if d] validate_filters(filters, account_details) @@ -60,11 +60,11 @@ def validate_filters(filters, account_details): frappe.throw(_("From Date must be before To Date")) if filters.get('project'): - projects = str(filters.get("project")).strip() + projects = cstr(filters.get("project")).strip() filters.project = [d.strip() for d in projects.split(',') if d] if filters.get('cost_center'): - cost_centers = str(filters.get("cost_center")).strip() + cost_centers = cstr(filters.get("cost_center")).strip() filters.cost_center = [d.strip() for d in cost_centers.split(',') if d]