From 70f9d07df8da16f95e7ee76e438ca4fa6888bea8 Mon Sep 17 00:00:00 2001 From: Shreya Date: Thu, 17 May 2018 18:58:47 +0530 Subject: [PATCH] Fix patches for Travis --- .../v10_1/transfer_subscription_to_auto_repeat.py | 3 ++- .../create_department_records_for_each_company.py | 2 +- .../make_asset_finance_book_against_old_entries.py | 5 +++-- .../patches/v11_0/rename_field_max_days_allowed.py | 1 + ...ve_employee_parent_to_child_in_salary_structure.py | 2 ++ .../v7_1/update_missing_salary_component_type.py | 2 ++ erpnext/patches/v8_0/update_production_orders.py | 3 +++ erpnext/patches/v9_0/fix_subscription_next_date.py | 11 ++++++++--- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py index 481c5571b5..a9078e305c 100644 --- a/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py +++ b/erpnext/patches/v10_1/transfer_subscription_to_auto_repeat.py @@ -21,7 +21,8 @@ def execute(): frappe.reload_doc('stock', 'doctype', 'delivery_note') for doctype in to_rename: - rename_field(doctype, 'subscription', 'auto_repeat') + if frappe.db.has_column(doctype, 'subscription'): + rename_field(doctype, 'subscription', 'auto_repeat') subscriptions = frappe.db.sql('select * from `tabSubscription`', as_dict=1) diff --git a/erpnext/patches/v11_0/create_department_records_for_each_company.py b/erpnext/patches/v11_0/create_department_records_for_each_company.py index bef524c34b..2018ffd2fc 100644 --- a/erpnext/patches/v11_0/create_department_records_for_each_company.py +++ b/erpnext/patches/v11_0/create_department_records_for_each_company.py @@ -2,7 +2,7 @@ import frappe from frappe.utils.nestedset import rebuild_tree def execute(): - for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening']: + for doctype in ['department', 'leave_period', 'staffing_plan', 'job_opening', 'payroll_entry']: frappe.reload_doc("hr", "doctype", doctype) companies = frappe.db.get_all("Company", fields=["name", "abbr"]) diff --git a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py index 18622f2301..4adae4981d 100644 --- a/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py +++ b/erpnext/patches/v11_0/make_asset_finance_book_against_old_entries.py @@ -11,6 +11,7 @@ def execute(): frappe.reload_doc('assets', 'doctype', 'asset_category') frappe.reload_doc('assets', 'doctype', 'asset') frappe.reload_doc('assets', 'doctype', 'asset_movement') + frappe.reload_doc('assets', 'doctype', 'asset_category_account') frappe.db.sql(""" update `tabAsset` ast, `tabWarehouse` wh set ast.location = wh.warehouse_name where ast.warehouse = wh.name""") @@ -36,8 +37,8 @@ def execute(): frappe.db.sql(""" update `tabDepreciation Schedule` ds, `tabAsset` ast set ds.depreciation_method = ast.depreciation_method, ds.finance_book_id = 1 where ds.parent = ast.name """) - for catergory in frappe.get_all('Asset Category'): - asset_category_doc = frappe.get_doc("Asset Category", catergory) + for category in frappe.get_all('Asset Category'): + asset_category_doc = frappe.get_doc("Asset Category", category) row = asset_category_doc.append('finance_books', { 'depreciation_method': asset_category_doc.depreciation_method, 'total_number_of_depreciations': asset_category_doc.total_number_of_depreciations, diff --git a/erpnext/patches/v11_0/rename_field_max_days_allowed.py b/erpnext/patches/v11_0/rename_field_max_days_allowed.py index e0acf06f4b..0356726f38 100644 --- a/erpnext/patches/v11_0/rename_field_max_days_allowed.py +++ b/erpnext/patches/v11_0/rename_field_max_days_allowed.py @@ -2,6 +2,7 @@ import frappe from frappe.model.utils.rename_field import rename_field def execute(): + frappe.db.sql("""update `tabLeave Type` set max_days_allowed = '0' where trim(coalesce(max_days_allowed, '')) = ''""") frappe.reload_doc("hr", "doctype", "leave_type") frappe.db.sql_ddl("""ALTER table `tabLeave Type` modify max_days_allowed int(8) NOT NULL""") rename_field("Leave Type", "max_days_allowed", "max_continuous_days_allowed") diff --git a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py index 4308526048..b5172db638 100644 --- a/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py +++ b/erpnext/patches/v7_0/move_employee_parent_to_child_in_salary_structure.py @@ -3,6 +3,8 @@ import frappe def execute(): frappe.reload_doc('hr', 'doctype', 'salary_structure') frappe.reload_doc('hr', 'doctype', 'salary_structure_employee') + if not frappe.db.has_column('Salary Structure', 'employees'): + return for ss in frappe.db.sql(""" select employee, name from `tabSalary Structure`""", as_dict=True): ss_doc = frappe.get_doc('Salary Structure', ss.name) salary_employee = ss_doc.append('employees',{}) diff --git a/erpnext/patches/v7_1/update_missing_salary_component_type.py b/erpnext/patches/v7_1/update_missing_salary_component_type.py index 25624f56ea..7d50ee4dff 100644 --- a/erpnext/patches/v7_1/update_missing_salary_component_type.py +++ b/erpnext/patches/v7_1/update_missing_salary_component_type.py @@ -10,6 +10,8 @@ earnings or deductions in existing salary slips def execute(): frappe.reload_doc("accounts", "doctype", "salary_component_account") + frappe.reload_doc("hr", "doctype", "salary_component") + frappe.reload_doc("hr", "doctype", "taxable_salary_slab") for s in frappe.db.sql('''select name, type, salary_component_abbr from `tabSalary Component` where ifnull(type, "")="" or ifnull(salary_component_abbr, "") = ""''', as_dict=1): diff --git a/erpnext/patches/v8_0/update_production_orders.py b/erpnext/patches/v8_0/update_production_orders.py index 7d87d68319..8e993cc102 100644 --- a/erpnext/patches/v8_0/update_production_orders.py +++ b/erpnext/patches/v8_0/update_production_orders.py @@ -10,6 +10,9 @@ def execute(): "BOM Item", "BOM Explosion Item", "BOM"): frappe.reload_doctype(doctype) + frappe.reload_doc("stock", "doctype", "item") + frappe.reload_doc("stock", "doctype", "item_default") + # fetch all draft and submitted work orders fields = ["name"] if "source_warehouse" in frappe.db.get_table_columns("Work Order"): diff --git a/erpnext/patches/v9_0/fix_subscription_next_date.py b/erpnext/patches/v9_0/fix_subscription_next_date.py index ac9db31a37..1789848a17 100644 --- a/erpnext/patches/v9_0/fix_subscription_next_date.py +++ b/erpnext/patches/v9_0/fix_subscription_next_date.py @@ -7,12 +7,17 @@ from frappe.utils import getdate from frappe.desk.doctype.auto_repeat.auto_repeat import get_next_schedule_date def execute(): - frappe.reload_doctype('Subscription') + frappe.reload_doc('accounts', 'doctype', 'subscription') + fields = ["name", "reference_doctype", "reference_document", + "start_date", "frequency", "repeat_on_day"] + + for d in fields: + if not frappe.db.has_column('Subscription', d): + return doctypes = ('Purchase Order', 'Sales Order', 'Purchase Invoice', 'Sales Invoice') for data in frappe.get_all('Subscription', - fields = ["name", "reference_doctype", "reference_document", - "start_date", "frequency", "repeat_on_day"], + fields = fields, filters = {'reference_doctype': ('in', doctypes), 'docstatus': 1}): recurring_id = frappe.db.get_value(data.reference_doctype, data.reference_document, "recurring_id")