From 956277b1210231d464b1eec98bfe9910580c3303 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 8 Jun 2018 14:05:05 +0530 Subject: [PATCH 1/7] Fix tests --- erpnext/assets/doctype/asset/asset.py | 2 + erpnext/assets/doctype/asset/test_asset.py | 62 ++++++++++++------- .../test_leave_application.py | 30 +++++++-- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 6cdb550c9d..f2d8bb725b 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -24,6 +24,8 @@ class Asset(AccountsController): self.make_depreciation_schedule() self.set_accumulated_depreciation() get_depreciation_accounts(self) + else: + self.finance_books = [] if self.get("schedules"): self.validate_expected_value_after_useful_life() diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 9846ec9717..32bb8025aa 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -22,10 +22,10 @@ class TestAsset(unittest.TestCase): pi = make_purchase_invoice(asset.name, asset.item_code, asset.gross_purchase_amount, asset.company, asset.purchase_date) + pi.supplier = "_Test Supplier" pi.insert() pi.submit() - asset.load_from_db() self.assertEqual(asset.supplier, "_Test Supplier") self.assertEqual(asset.purchase_date, getdate("2015-01-01")) @@ -39,7 +39,6 @@ class TestAsset(unittest.TestCase): gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry` where voucher_type='Purchase Invoice' and voucher_no = %s order by account""", pi.name) - self.assertEqual(gle, expected_gle) pi.cancel() @@ -54,20 +53,21 @@ class TestAsset(unittest.TestCase): def test_schedule_for_straight_line_method(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "next_depreciation_date": "2020-12-31", "depreciation_method": "Straight Line", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": add_days(nowdate(), 5) + "depreciation_start_date": "2020-06-06" }) asset.insert() self.assertEqual(asset.status, "Draft") expected_schedules = [ - ["2018-06-11", 490.20, 490.20], - ["2019-04-11", 49673.20, 50163.40], - ["2020-02-11", 39836.60, 90000.00] + ["2020-06-06", 163.93, 163.93], + ["2021-04-06", 49836.07, 50000.0], + ["2022-02-06", 40000.0, 90000.00] ] schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount] @@ -78,6 +78,7 @@ class TestAsset(unittest.TestCase): def test_schedule_for_straight_line_method_for_existing_asset(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) asset.is_existing_asset = 1 + asset.calculate_depreciation = 1 asset.number_of_depreciations_booked = 1 asset.opening_accumulated_depreciation = 40000 asset.append("finance_books", { @@ -86,14 +87,14 @@ class TestAsset(unittest.TestCase): "depreciation_method": "Straight Line", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": add_days(nowdate(), 5) + "depreciation_start_date": "2020-06-06" }) asset.insert() self.assertEqual(asset.status, "Draft") asset.save() expected_schedules = [ - ["2018-06-11", 588.24, 40588.24], - ["2019-04-11", 49411.76, 90000.00] + ["2020-06-06", 197.37, 40197.37], + ["2021-04-06", 49802.63, 90000.00] ] schedules = [[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount] for d in asset.get("schedules")] @@ -102,22 +103,23 @@ class TestAsset(unittest.TestCase): def test_schedule_for_double_declining_method(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "next_depreciation_date": "2020-12-31", "depreciation_method": "Double Declining Balance", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": add_days(nowdate(), 5) + "depreciation_start_date": "2020-06-06" }) asset.insert() self.assertEqual(asset.status, "Draft") asset.save() expected_schedules = [ - ["2018-06-11", 66667.0, 66667.0], - ["2019-04-11", 22222.0, 88889.0], - ["2020-02-11", 1111.0, 90000.0] + ["2020-06-06", 66667.0, 66667.0], + ["2021-04-06", 22222.0, 88889.0], + ["2022-02-06", 1111.0, 90000.0] ] schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount] @@ -127,6 +129,7 @@ class TestAsset(unittest.TestCase): def test_schedule_for_double_declining_method_for_existing_asset(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.is_existing_asset = 1 asset.number_of_depreciations_booked = 1 asset.opening_accumulated_depreciation = 50000 @@ -136,7 +139,7 @@ class TestAsset(unittest.TestCase): "depreciation_method": "Double Declining Balance", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": add_days(nowdate(), 5) + "depreciation_start_date": "2020-06-06" }) asset.insert() self.assertEqual(asset.status, "Draft") @@ -145,8 +148,8 @@ class TestAsset(unittest.TestCase): asset.save() expected_schedules = [ - ["2018-06-11", 33333.0, 83333.0], - ["2019-04-11", 6667.0, 90000.0] + ["2020-06-06", 33333.0, 83333.0], + ["2021-04-06", 6667.0, 90000.0] ] schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount] @@ -157,6 +160,7 @@ class TestAsset(unittest.TestCase): def test_schedule_for_prorated_straight_line_method(self): set_prorated_depreciation_schedule() asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.is_existing_asset = 0 asset.available_for_use_date = "2020-01-30" asset.append("finance_books", { @@ -186,6 +190,7 @@ class TestAsset(unittest.TestCase): def test_depreciation(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.available_for_use_date = "2020-01-30" asset.append("finance_books", { "expected_value_after_useful_life": 10000, @@ -220,6 +225,7 @@ class TestAsset(unittest.TestCase): def test_depreciation_entry_cancellation(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "depreciation_method": "Straight Line", @@ -242,15 +248,15 @@ class TestAsset(unittest.TestCase): depr_entry = asset.get("schedules")[0].journal_entry self.assertFalse(depr_entry) - def test_scrap_asset(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "depreciation_method": "Straight Line", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": "2020-12-31" + "depreciation_start_date": "2020-06-06" }) asset.insert() asset.submit() @@ -280,6 +286,7 @@ class TestAsset(unittest.TestCase): def test_asset_sale(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "depreciation_method": "Straight Line", @@ -320,13 +327,13 @@ class TestAsset(unittest.TestCase): def test_asset_expected_value_after_useful_life(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) - asset.depreciation_method = "Straight Line" + asset.calculate_depreciation = 1 asset.append("finance_books", { "expected_value_after_useful_life": 10000, "depreciation_method": "Straight Line", "total_number_of_depreciations": 3, "frequency_of_depreciation": 10, - "depreciation_start_date": "2020-12-31" + "depreciation_start_date": "2020-06-06" }) asset.insert() accumulated_depreciation_after_full_schedule = \ @@ -339,6 +346,17 @@ class TestAsset(unittest.TestCase): def tearDown(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) + pi = [d[0] for d in frappe.db.sql(''' + select p.name from `tabPurchase Invoice` p, `tabPurchase Invoice Item` pi + where p.name = pi.parent + and pi.asset = %s + ''', (asset.name))] + if pi: + pi_doc = frappe.get_doc("Purchase Invoice", pi[0]) + print(pi[0]) + pi_doc.cancel + # if pi: + # frappe.db.set_value("Purchase Invoice", {"name": pi[0]}, "docstatus", 2) if asset.docstatus == 1 and asset.status not in ("Scrapped", "Sold", "Draft", "Cancelled"): asset.cancel() @@ -367,11 +385,11 @@ def create_asset(): "item_code": "Macbook Pro", "company": "_Test Company", "purchase_date": "2015-01-01", - "calculate_depreciation": 1, + "calculate_depreciation": 0, "gross_purchase_amount": 100000, "expected_value_after_useful_life": 10000, "warehouse": "_Test Warehouse - _TC", - "available_for_use_date": add_days(nowdate(),3), + "available_for_use_date": "2020-06-06", "location": "Test Location", "asset_owner": "Company" }) diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 4e85074b69..a9a1a9d1c6 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -54,9 +54,12 @@ class TestLeaveApplication(unittest.TestCase): def tearDown(self): frappe.set_user("Administrator") + def _clear_roles(self): + frappe.db.sql("""delete from `tabHas Role` where parent in + ("test@example.com", "test1@example.com", "test2@example.com")""") + def _clear_applications(self): frappe.db.sql("""delete from `tabLeave Application`""") - frappe.db.sql("""delete from `tabDepartment Approver` where parentfield = 'Leave Approver'""") def get_application(self, doc): application = frappe.copy_doc(doc) @@ -65,6 +68,10 @@ class TestLeaveApplication(unittest.TestCase): return application def test_block_list(self): + self._clear_roles() + + from frappe.utils.user import add_role + add_role("test@example.com", "HR User") clear_user_permissions_for_doctype("Employee") frappe.db.set_value("Department", "_Test Department - _TC", @@ -86,8 +93,11 @@ class TestLeaveApplication(unittest.TestCase): self.assertTrue(application.insert()) def test_overlap(self): + self._clear_roles() self._clear_applications() + from frappe.utils.user import add_role + add_role("test@example.com", "Employee") frappe.set_user("test@example.com") make_allocation_record() @@ -99,8 +109,11 @@ class TestLeaveApplication(unittest.TestCase): self.assertRaises(OverlapError, application.insert) def test_overlap_with_half_day_1(self): + self._clear_roles() self._clear_applications() + from frappe.utils.user import add_role + add_role("test@example.com", "Employee") frappe.set_user("test@example.com") make_allocation_record() @@ -129,8 +142,12 @@ class TestLeaveApplication(unittest.TestCase): self.assertRaises(OverlapError, application.insert) def test_overlap_with_half_day_2(self): + self._clear_roles() self._clear_applications() + from frappe.utils.user import add_role + add_role("test@example.com", "Employee") + frappe.set_user("test@example.com") make_allocation_record() @@ -147,8 +164,12 @@ class TestLeaveApplication(unittest.TestCase): self.assertRaises(OverlapError, application.insert) def test_overlap_with_half_day_3(self): + self._clear_roles() self._clear_applications() + from frappe.utils.user import add_role + add_role("test@example.com", "Employee") + frappe.set_user("test@example.com") make_allocation_record() @@ -176,7 +197,6 @@ class TestLeaveApplication(unittest.TestCase): application.half_day_date = "2013-01-05" application.insert() - def test_optional_leave(self): leave_period = get_leave_period() today = nowdate() @@ -228,6 +248,7 @@ class TestLeaveApplication(unittest.TestCase): # check leave balance is reduced self.assertEqual(get_leave_balance_on(employee.name, leave_type, today), 9) + def test_leaves_allowed(self): employee = get_employee() leave_period = get_leave_period() @@ -412,7 +433,7 @@ def get_leave_period(): to_date = "{0}-12-31".format(now_datetime().year), company = "_Test Company", is_active = 1 - )).insert() + )).insert() def allocate_leaves(employee, leave_period, leave_type, new_leaves_allocated, eligible_leaves=0): allocate_leave = frappe.get_doc({ @@ -427,5 +448,4 @@ def allocate_leaves(employee, leave_period, leave_type, new_leaves_allocated, el "docstatus": 1 }).insert() - allocate_leave.submit() - + allocate_leave.submit() \ No newline at end of file From 3b201cc2fd2420bd9f7393a0659cb24ab3b9663a Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 8 Jun 2018 17:15:15 +0530 Subject: [PATCH 2/7] Remove python 3 stage from travis --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8ffffbdd8..6c5afc3fac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,6 +52,4 @@ jobs: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - bench migrate - env: Patch Testing - allow_failures: - - python: "3.6" \ No newline at end of file + env: Patch Testing \ No newline at end of file From 294238abfd399fd82c2852766765d4f8ec436e2e Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 8 Jun 2018 17:15:30 +0530 Subject: [PATCH 3/7] Fix shopify test case --- erpnext/assets/doctype/asset/test_asset.py | 3 +-- .../doctype/shopify_settings/sync_product.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 32bb8025aa..e3610e1d11 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -22,7 +22,7 @@ class TestAsset(unittest.TestCase): pi = make_purchase_invoice(asset.name, asset.item_code, asset.gross_purchase_amount, asset.company, asset.purchase_date) - + print(pi.name) pi.supplier = "_Test Supplier" pi.insert() pi.submit() @@ -353,7 +353,6 @@ class TestAsset(unittest.TestCase): ''', (asset.name))] if pi: pi_doc = frappe.get_doc("Purchase Invoice", pi[0]) - print(pi[0]) pi_doc.cancel # if pi: # frappe.db.set_value("Purchase Invoice", {"name": pi[0]}, "docstatus", 2) diff --git a/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py b/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py index 55f47a600e..ff1edea713 100644 --- a/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py +++ b/erpnext/erpnext_integrations/doctype/shopify_settings/sync_product.py @@ -216,7 +216,7 @@ def get_supplier(shopify_item): "doctype": "Supplier", "supplier_name": shopify_item.get("vendor"), "shopify_supplier_id": shopify_item.get("vendor").lower(), - "supplier_type": get_supplier_type() + "supplier_group": get_supplier_group() }).insert() return supplier.name else: @@ -224,15 +224,15 @@ def get_supplier(shopify_item): else: return "" -def get_supplier_type(): - supplier_type = frappe.db.get_value("Supplier Type", _("Shopify Supplier")) - if not supplier_type: - supplier_type = frappe.get_doc({ - "doctype": "Supplier Type", - "supplier_type": _("Shopify Supplier") +def get_supplier_group(): + supplier_group = frappe.db.get_value("Supplier Group", _("Shopify Supplier")) + if not supplier_group: + supplier_group = frappe.get_doc({ + "doctype": "Supplier Group", + "supplier_group_name": _("Shopify Supplier") }).insert() - return supplier_type.name - return supplier_type + return supplier_group.name + return supplier_group def get_item_details(shopify_item): item_details = {} From 77662eb5f4f20a986357c2ae159145098f5406e7 Mon Sep 17 00:00:00 2001 From: Shreya Date: Fri, 8 Jun 2018 17:35:49 +0530 Subject: [PATCH 4/7] Fix shopify test case --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6c5afc3fac..b8ffffbdd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,4 +52,6 @@ jobs: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - bench migrate - env: Patch Testing \ No newline at end of file + env: Patch Testing + allow_failures: + - python: "3.6" \ No newline at end of file From 664f30a018a7098e021627bdd03c9d1995cfa5c1 Mon Sep 17 00:00:00 2001 From: Shreya Date: Sat, 9 Jun 2018 23:46:50 +0530 Subject: [PATCH 5/7] Fix asset maintenance json --- .travis.yml | 5 +- erpnext/assets/doctype/asset/test_asset.py | 3 +- .../asset_maintenance_log.json | 87 ++++++++++++------- 3 files changed, 57 insertions(+), 38 deletions(-) diff --git a/.travis.yml b/.travis.yml index b8ffffbdd8..4cfde8a679 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ dist: trusty python: - "2.7" - - "3.6" services: - mysql @@ -52,6 +51,4 @@ jobs: - wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz - bench --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz --mariadb-root-password travis - bench migrate - env: Patch Testing - allow_failures: - - python: "3.6" \ No newline at end of file + env: Patch Testing \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index e3610e1d11..45e9c3e6f8 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe import unittest -from frappe.utils import cstr, nowdate, getdate, flt, add_days +from frappe.utils import cstr, nowdate, getdate, flt from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset, restore_asset from erpnext.assets.doctype.asset.asset import make_sales_invoice, make_purchase_invoice @@ -22,7 +22,6 @@ class TestAsset(unittest.TestCase): pi = make_purchase_invoice(asset.name, asset.item_code, asset.gross_purchase_amount, asset.company, asset.purchase_date) - print(pi.name) pi.supplier = "_Test Supplier" pi.insert() pi.submit() diff --git a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json index 767097dd34..95968cffe4 100644 --- a/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json +++ b/erpnext/assets/doctype/asset_maintenance_log/asset_maintenance_log.json @@ -15,6 +15,7 @@ "fields": [ { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -42,11 +43,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -74,16 +76,17 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "asset_maintenance.asset_name", + "fetch_from": "asset_maintenance.asset_name", "fieldname": "asset_name", "fieldtype": "Read Only", "hidden": 0, @@ -107,11 +110,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -137,16 +141,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "asset_maintenance.item_code", + "fetch_from": "asset_maintenance.item_code", "fieldname": "item_code", "fieldtype": "Read Only", "hidden": 0, @@ -170,16 +175,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "asset_maintenance.item_name", + "fetch_from": "asset_maintenance.item_name", "fieldname": "item_name", "fieldtype": "Read Only", "hidden": 0, @@ -203,11 +209,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -233,11 +240,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -265,16 +273,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "task.maintenance_type", + "fetch_from": "task.maintenance_type", "fieldname": "maintenance_type", "fieldtype": "Read Only", "hidden": 0, @@ -298,16 +307,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "task.periodicity", + "fetch_from": "task.periodicity", "fieldname": "periodicity", "fieldtype": "Data", "hidden": 0, @@ -331,16 +341,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "task.assign_to_name", + "fetch_from": "task.assign_to_name", "fieldname": "assign_to_name", "fieldtype": "Read Only", "hidden": 0, @@ -364,11 +375,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -394,11 +406,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -427,11 +440,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -458,11 +472,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -490,11 +505,12 @@ "reqd": 1, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -520,16 +536,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "task.has_certificate", + "fetch_from": "task.certificate_required", "fieldname": "has_certificate", "fieldtype": "Check", "hidden": 0, @@ -553,11 +570,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -585,11 +603,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -615,16 +634,17 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, "columns": 0, - "fetch_from": "task.description", + "fetch_from": "task.description", "fieldname": "description", "fieldtype": "Read Only", "hidden": 0, @@ -648,11 +668,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -678,11 +699,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 1, "bold": 0, "collapsible": 0, @@ -709,11 +731,12 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 }, { "allow_bulk_edit": 0, + "allow_in_quick_entry": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -741,7 +764,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "translatable": 0, + "translatable": 0, "unique": 0 } ], @@ -755,7 +778,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-25 22:43:39.866477", + "modified": "2018-06-09 23:45:55.492528", "modified_by": "Administrator", "module": "Assets", "name": "Asset Maintenance Log", From 83d5dc119b053040bdc3e867ce138e1acf7076d8 Mon Sep 17 00:00:00 2001 From: Shreya Date: Sun, 10 Jun 2018 00:38:30 +0530 Subject: [PATCH 6/7] Fix Employee tax declaration test case --- ...test_employee_tax_exemption_declaration.py | 31 +++++++++++-------- .../test_leave_application.py | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py index dff02eac14..8974c36b5b 100644 --- a/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py +++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/test_employee_tax_exemption_declaration.py @@ -8,7 +8,7 @@ import unittest from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): - def setup(self): + def setUp(self): make_employee("employee@taxexepmtion.com") make_employee("employee1@taxexepmtion.com") create_payroll_period() @@ -19,7 +19,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "payroll_period": "Test Payroll Period", + "payroll_period": "_Test Payroll Period", "declarations": [dict(exemption_sub_category = "_Test Sub Category", exemption_category = "_Test Category", amount = 150000)] @@ -27,7 +27,7 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): self.assertRaises(frappe.ValidationError, declaration.save) declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", - "payroll_period": "Test Payroll Period", + "payroll_period": "_Test Payroll Period", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), "declarations": [dict(exemption_sub_category = "_Test Sub Category", exemption_category = "_Test Category", @@ -39,7 +39,8 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "payroll_period": "Test Payroll Period", + "company": "_Test Company", + "payroll_period": "_Test Payroll Period", "declarations": [dict(exemption_sub_category = "_Test Sub Category", exemption_category = "_Test Category", amount = 100000), @@ -54,7 +55,8 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "payroll_period": "Test Payroll Period", + "company": "_Test Company", + "payroll_period": "_Test Payroll Period", "declarations": [dict(exemption_sub_category = "_Test Sub Category", exemption_category = "_Test Category", amount = 100000), @@ -62,17 +64,18 @@ class TestEmployeeTaxExemptionDeclaration(unittest.TestCase): exemption_category = "_Test Category", amount = 50000), ] - }) + }).insert() self.assertTrue(declaration.submit) duplicate_declaration = frappe.get_doc({ "doctype": "Employee Tax Exemption Declaration", "employee": frappe.get_value("Employee", {"user_id":"employee@taxexepmtion.com"}, "name"), - "payroll_period": "Test Payroll Period", + "company": "_Test Company", + "payroll_period": "_Test Payroll Period", "declarations": [dict(exemption_sub_category = "_Test Sub Category", exemption_category = "_Test Category", amount = 100000) ] - }) + }).insert() self.assertRaises(frappe.DocstatusTransitionError, duplicate_declaration.submit) duplicate_declaration.employee = frappe.get_value("Employee", {"user_id":"employee1@taxexepmtion.com"}, "name") self.assertTrue(duplicate_declaration.submit) @@ -93,20 +96,22 @@ def create_exemption_category(): category = frappe.get_doc({ "doctype": "Employee Tax Exemption Category", "name": "_Test Category", - "deduction_component": "_Test Tax", + "deduction_component": "Income Tax", "max_amount": 100000 }).insert() - if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"): + if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Sub Category"): frappe.get_doc({ "doctype": "Employee Tax Exemption Sub Category", "name": "_Test Sub Category", "exemption_category": "_Test Category", - "max_amount": 100000 + "max_amount": 100000, + "is_active": 1 }).insert() - if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test Category"): + if not frappe.db.exists("Employee Tax Exemption Sub Category", "_Test1 Sub Category"): frappe.get_doc({ "doctype": "Employee Tax Exemption Sub Category", "name": "_Test1 Sub Category", "exemption_category": "_Test Category", - "max_amount": 50000 + "max_amount": 50000, + "is_active": 1 }).insert() diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index a9a1a9d1c6..1532e8534b 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -433,7 +433,7 @@ def get_leave_period(): to_date = "{0}-12-31".format(now_datetime().year), company = "_Test Company", is_active = 1 - )).insert() + )).insert() def allocate_leaves(employee, leave_period, leave_type, new_leaves_allocated, eligible_leaves=0): allocate_leave = frappe.get_doc({ From 9680dc476f55980ada1d767e56aa3180d86d8f9e Mon Sep 17 00:00:00 2001 From: Shreya Date: Mon, 11 Jun 2018 15:40:09 +0530 Subject: [PATCH 7/7] Remove commented code --- erpnext/assets/doctype/asset/test_asset.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py index 45e9c3e6f8..3f706f8b64 100644 --- a/erpnext/assets/doctype/asset/test_asset.py +++ b/erpnext/assets/doctype/asset/test_asset.py @@ -345,17 +345,6 @@ class TestAsset(unittest.TestCase): def tearDown(self): asset = frappe.get_doc("Asset", {"asset_name": "Macbook Pro 1"}) - pi = [d[0] for d in frappe.db.sql(''' - select p.name from `tabPurchase Invoice` p, `tabPurchase Invoice Item` pi - where p.name = pi.parent - and pi.asset = %s - ''', (asset.name))] - if pi: - pi_doc = frappe.get_doc("Purchase Invoice", pi[0]) - pi_doc.cancel - # if pi: - # frappe.db.set_value("Purchase Invoice", {"name": pi[0]}, "docstatus", 2) - if asset.docstatus == 1 and asset.status not in ("Scrapped", "Sold", "Draft", "Cancelled"): asset.cancel()