From 4221814131c4d6d5fe0fb2b298481582294f16b0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 16 May 2013 15:28:19 +0530 Subject: [PATCH] [patches] [fix] replace sync with reload_doc in old patches --- patches/august_2012/change_profile_permission.py | 3 +-- patches/july_2012/address_contact_perms.py | 5 ++--- patches/july_2012/blog_guest_permission.py | 3 +-- patches/july_2012/project_patch_repeat.py | 7 +++---- patches/july_2012/supplier_quotation.py | 13 ++++++------- patches/june_2012/cms2.py | 11 +++++------ patches/june_2012/copy_uom_for_pur_inv_item.py | 8 +++----- patches/june_2012/reports_list_permission.py | 5 ++--- patches/june_2012/set_recurring_type.py | 3 +-- patches/june_2012/support_ticket_autoreply.py | 3 +-- patches/mar_2012/clean_property_setter.py | 3 +-- patches/mar_2012/create_custom_fields.py | 3 +-- patches/may_2012/cleanup_notification_control.py | 3 +-- patches/may_2012/cs_server_readonly.py | 3 +-- patches/may_2012/profile_perm_patch.py | 3 +-- patches/may_2012/remove_communication_log.py | 3 +-- patches/may_2012/std_pf_readonly.py | 3 +-- 17 files changed, 32 insertions(+), 50 deletions(-) diff --git a/patches/august_2012/change_profile_permission.py b/patches/august_2012/change_profile_permission.py index 27169d8792..7e945d5d9a 100644 --- a/patches/august_2012/change_profile_permission.py +++ b/patches/august_2012/change_profile_permission.py @@ -31,5 +31,4 @@ def execute(): webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'profile') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'profile') \ No newline at end of file diff --git a/patches/july_2012/address_contact_perms.py b/patches/july_2012/address_contact_perms.py index 5b79f22937..882cf728a5 100644 --- a/patches/july_2012/address_contact_perms.py +++ b/patches/july_2012/address_contact_perms.py @@ -6,7 +6,6 @@ def execute(): where parent in ('Address', 'Contact')""") webnotes.conn.commit() - import webnotes.model.sync - webnotes.model.sync.sync('utilities', 'address') - webnotes.model.sync.sync('utilities', 'contact') + webnotes.reload_doc('utilities', 'doctype', 'address') + webnotes.reload_doc('utilities', 'doctype', 'contact') webnotes.conn.begin() \ No newline at end of file diff --git a/patches/july_2012/blog_guest_permission.py b/patches/july_2012/blog_guest_permission.py index bc42a9d05c..3fcaa0d291 100644 --- a/patches/july_2012/blog_guest_permission.py +++ b/patches/july_2012/blog_guest_permission.py @@ -6,7 +6,6 @@ def execute(): webnotes.conn.commit() - import webnotes.model.sync - webnotes.model.sync.sync('website', 'blog', 1) + webnotes.reload_doc('website', 'doctype', 'blog') webnotes.conn.begin() diff --git a/patches/july_2012/project_patch_repeat.py b/patches/july_2012/project_patch_repeat.py index bd52522938..e031e35980 100644 --- a/patches/july_2012/project_patch_repeat.py +++ b/patches/july_2012/project_patch_repeat.py @@ -12,8 +12,7 @@ def execute(): and ifnull(t1.project_name, '') = ''""") webnotes.conn.commit() - from webnotes.model.sync import sync - sync("buying", "purchase_order") - sync("buying", "purchase_request") - sync("accounts", "purchase_invoice") + webnotes.reload_doc("buying", "doctype", "purchase_order") + webnotes.reload_doc("buying", "doctype", "purchase_request") + webnotes.reload_doc("accounts", "doctype", "purchase_invoice") webnotes.conn.begin() \ No newline at end of file diff --git a/patches/july_2012/supplier_quotation.py b/patches/july_2012/supplier_quotation.py index 49fa14dc9b..c51399c75b 100644 --- a/patches/july_2012/supplier_quotation.py +++ b/patches/july_2012/supplier_quotation.py @@ -1,13 +1,12 @@ from __future__ import unicode_literals def execute(): """sync supplier quotatoin and create supplier quotation mappers""" - from webnotes.model.sync import sync - sync('buying', 'supplier_quotation') - sync('buying', 'supplier_quotation_item') - sync('buying', 'purchase_request') - sync('buying', 'purchase_request_item') - sync('buying', 'purchase_order') - sync('buying', 'purchase_order_item') + webnotes.reload_doc('buying', 'doctype', 'supplier_quotation') + webnotes.reload_doc('buying', 'doctype', 'supplier_quotation_item') + webnotes.reload_doc('buying', 'doctype', 'purchase_request') + webnotes.reload_doc('buying', 'doctype', 'purchase_request_item') + webnotes.reload_doc('buying', 'doctype', 'purchase_order') + webnotes.reload_doc('buying', 'doctype', 'purchase_order_item') from webnotes.modules import reload_doc reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation') diff --git a/patches/june_2012/cms2.py b/patches/june_2012/cms2.py index 414af73c00..f912f86278 100644 --- a/patches/june_2012/cms2.py +++ b/patches/june_2012/cms2.py @@ -1,14 +1,13 @@ from __future__ import unicode_literals def execute(): import webnotes - import webnotes.model.sync # sync doctypes required for the patch - webnotes.model.sync.sync('website', 'web_cache') - webnotes.model.sync.sync('website', 'web_page') - webnotes.model.sync.sync('website', 'blog') - webnotes.model.sync.sync('website', 'website_settings') - webnotes.model.sync.sync('stock', 'item') + webnotes.reload_doc('website', 'doctype', 'web_cache') + webnotes.reload_doc('website', 'doctype', 'web_page') + webnotes.reload_doc('website', 'doctype', 'blog') + webnotes.reload_doc('website', 'doctype', 'website_settings') + webnotes.reload_doc('stock', 'doctype', 'item') cleanup() diff --git a/patches/june_2012/copy_uom_for_pur_inv_item.py b/patches/june_2012/copy_uom_for_pur_inv_item.py index b374249942..a22146c6a3 100644 --- a/patches/june_2012/copy_uom_for_pur_inv_item.py +++ b/patches/june_2012/copy_uom_for_pur_inv_item.py @@ -2,11 +2,9 @@ from __future__ import unicode_literals def execute(): import webnotes - # perform sync - import webnotes.model.sync - webnotes.model.sync.sync('buying', 'purchase_order_item') - webnotes.model.sync.sync('accounts', 'purchase_invoice_item') - webnotes.model.sync.sync('stock', 'purchase_receipt_item') + webnotes.reload_doc('buying', 'doctype', 'purchase_order_item') + webnotes.reload_doc('accounts', 'doctype', 'purchase_invoice_item') + webnotes.reload_doc('stock', 'doctype', 'purchase_receipt_item') webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Order Item` t2 set t1.uom = t2.uom where ifnull(t1.po_detail, '') != '' and t1.po_detail = t2.name") webnotes.conn.sql("update `tabPurchase Invoice Item` t1, `tabPurchase Receipt Item` t2 set t1.uom = t2.uom where ifnull(t1.pr_detail, '') != '' and t1.pr_detail = t2.name") \ No newline at end of file diff --git a/patches/june_2012/reports_list_permission.py b/patches/june_2012/reports_list_permission.py index a02f4fa37f..e34eb5ae46 100644 --- a/patches/june_2012/reports_list_permission.py +++ b/patches/june_2012/reports_list_permission.py @@ -8,8 +8,7 @@ def execute(): webnotes.conn.commit() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'search_criteria') - webnotes.model.sync.sync('core', 'report') + webnotes.reload_doc('core', 'doctype', 'search_criteria') + webnotes.reload_doc('core', 'doctype', 'report') webnotes.conn.begin() \ No newline at end of file diff --git a/patches/june_2012/set_recurring_type.py b/patches/june_2012/set_recurring_type.py index 79dd286fbc..7fb416ed7e 100644 --- a/patches/june_2012/set_recurring_type.py +++ b/patches/june_2012/set_recurring_type.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals def execute(): import webnotes - from webnotes.model.sync import sync - sync('accounts', 'sales_invoice') + webnotes.reload_doc('accounts', 'doctype', 'sales_invoice') webnotes.conn.sql("update `tabSales Invoice` set recurring_type = 'Monthly' where ifnull(convert_into_recurring_invoice, 0) = 1") \ No newline at end of file diff --git a/patches/june_2012/support_ticket_autoreply.py b/patches/june_2012/support_ticket_autoreply.py index 9fb0534bdd..32e095665c 100644 --- a/patches/june_2012/support_ticket_autoreply.py +++ b/patches/june_2012/support_ticket_autoreply.py @@ -4,9 +4,8 @@ def execute(): import webnotes import webnotes.utils - import webnotes.model.sync webnotes.conn.commit() - webnotes.model.sync.sync('setup', 'email_settings') + webnotes.reload_doc('setup', 'doctype', 'email_settings') webnotes.conn.begin() sync_support_mails = webnotes.utils.cint(webnotes.conn.get_value('Email Settings', diff --git a/patches/mar_2012/clean_property_setter.py b/patches/mar_2012/clean_property_setter.py index 08a0a94e1f..a9c7b81f36 100644 --- a/patches/mar_2012/clean_property_setter.py +++ b/patches/mar_2012/clean_property_setter.py @@ -12,8 +12,7 @@ def execute(): clean_docfield_properties() def change_property_setter_fieldnames(): - import webnotes.model.sync - webnotes.model.sync.sync('core', 'property_setter') + webnotes.reload_doc('core', 'doctype', 'property_setter') docfield_list = webnotes.conn.sql("""\ SELECT name, fieldname FROM `tabDocField`""", as_list=1) custom_field_list = webnotes.conn.sql("""\ diff --git a/patches/mar_2012/create_custom_fields.py b/patches/mar_2012/create_custom_fields.py index d4c1a13453..a91c765e5f 100644 --- a/patches/mar_2012/create_custom_fields.py +++ b/patches/mar_2012/create_custom_fields.py @@ -94,8 +94,7 @@ from webnotes.model.code import get_obj from webnotes.model.doc import Document def execute(): - import webnotes.model.sync - webnotes.model.sync.sync('core', 'custom_field') + webnotes.reload_doc('core', 'doctype', 'custom_field') for f in field_list: res = webnotes.conn.sql("""SELECT name FROM `tabCustom Field` WHERE dt=%s AND fieldname=%s""", (f[0], f[1])) diff --git a/patches/may_2012/cleanup_notification_control.py b/patches/may_2012/cleanup_notification_control.py index 25a704e198..1a7730ba5b 100644 --- a/patches/may_2012/cleanup_notification_control.py +++ b/patches/may_2012/cleanup_notification_control.py @@ -25,5 +25,4 @@ def execute(): webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('setup', 'notification_control') \ No newline at end of file + webnotes.reload_doc('setup', 'doctype', 'notification_control') \ No newline at end of file diff --git a/patches/may_2012/cs_server_readonly.py b/patches/may_2012/cs_server_readonly.py index b68060682c..51a9b760cf 100644 --- a/patches/may_2012/cs_server_readonly.py +++ b/patches/may_2012/cs_server_readonly.py @@ -27,5 +27,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'custom_script') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'custom_script') \ No newline at end of file diff --git a/patches/may_2012/profile_perm_patch.py b/patches/may_2012/profile_perm_patch.py index 4423fdb15d..29fa9c05be 100644 --- a/patches/may_2012/profile_perm_patch.py +++ b/patches/may_2012/profile_perm_patch.py @@ -19,5 +19,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'profile') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'profile') \ No newline at end of file diff --git a/patches/may_2012/remove_communication_log.py b/patches/may_2012/remove_communication_log.py index e44e673701..b6e7e7d276 100644 --- a/patches/may_2012/remove_communication_log.py +++ b/patches/may_2012/remove_communication_log.py @@ -1,8 +1,7 @@ from __future__ import unicode_literals def execute(): import webnotes - import webnotes.model.sync - webnotes.model.sync.sync('support', 'communication') + webnotes.reload_doc('support', 'doctype', 'communication') webnotes.conn.commit() webnotes.conn.begin() diff --git a/patches/may_2012/std_pf_readonly.py b/patches/may_2012/std_pf_readonly.py index 83b581325c..9fbbfe9a3c 100644 --- a/patches/may_2012/std_pf_readonly.py +++ b/patches/may_2012/std_pf_readonly.py @@ -27,5 +27,4 @@ def execute(): doc.save() webnotes.conn.commit() webnotes.conn.begin() - import webnotes.model.sync - webnotes.model.sync.sync('core', 'print_format') \ No newline at end of file + webnotes.reload_doc('core', 'doctype', 'print_format') \ No newline at end of file