def latest(verbose=True, rebuild_website_config=True): import frappe.modules.patch_handler import frappe.model.sync from frappe.website import rebuild_config from frappe.utils.fixtures import sync_fixtures import frappe.translate frappe.connect() try: # run patches frappe.local.patch_log_list = [] frappe.modules.patch_handler.run_all() if verbose: print "\n".join(frappe.local.patch_log_list) # sync frappe.model.sync.sync_all() # build website config if any changes in templates etc. if rebuild_website_config: rebuild_config() sync_fixtures() frappe.translate.clear_cache() except frappe.modules.patch_handler.PatchError, e: print "\n".join(frappe.local.patch_log_list) raise
def execute(): sync_fixtures("meli_connector") frappe.reload_doctype("Item") meli_settings = frappe.get_doc("Meli Settings") if not meli_settings.enable_meli: return try: meli_items = get_item_list() except MeliError: print "Could not run MercadoLibre patch 'set_variant_id' for site: {0}".format( frappe.local.site) return if meli_settings.meli_url and meli_items: for item in frappe.db.sql( """select name, item_code, meli_id, has_variants, variant_of from tabItem where sync_with_meli=1 and meli_id is not null""", as_dict=1): if item.get("variant_of"): frappe.db.sql( """ update tabItem set meli_variant_id=meli_id where name = %s """, item.get("name")) elif not item.get("has_variants"): product = filter( lambda meli_item: meli_item['id'] == cint( item.get("meli_id")), meli_items) if product: frappe.db.sql( """ update tabItem set meli_variant_id=%s where name = %s """, (product[0]["variants"][0]["id"], item.get("name")))
def execute(): sync_fixtures("erpnext_shopify") frappe.reload_doctype("Item") shopify_settings = frappe.get_doc("Shopify Settings") if not shopify_settings.enable_shopify: return try: shopify_items = get_item_list() except ShopifyError: print "Could not run shopify patch 'set_variant_id' for site: {0}".format( frappe.local.site) return if shopify_settings.shopify_url and shopify_items: for item in frappe.db.sql( """select name, item_code, shopify_id, has_variants, variant_of from tabItem where sync_with_shopify=1 and shopify_id is not null""", as_dict=1): if item.get("variant_of"): frappe.db.sql( """ update tabItem set shopify_variant_id=shopify_id where name = %s """, item.get("name")) elif not item.get("has_variants"): product = filter( lambda shopify_item: shopify_item['id'] == cint( item.get("shopify_id")), shopify_items) if product: frappe.db.sql( """ update tabItem set shopify_variant_id=%s where name = %s """, (product[0]["variants"][0]["id"], item.get("name")))
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www)''' clear_global_cache() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_desktop_icons() # syncs statics render.clear_cache() if rebuild_website: statics.sync(verbose=verbose).start(True) else: statics.sync_statics() frappe.db.commit() clear_notifications() frappe.publish_realtime("version-update")
def latest(rebuild_website=True, quiet=False): import frappe.modules.patch_handler import frappe.model.sync from frappe.utils.fixtures import sync_fixtures import frappe.translate from frappe.core.doctype.notification_count.notification_count import clear_notifications verbose = not quiet frappe.connect() try: # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() clear_notifications() if rebuild_website: build_website() finally: frappe.destroy()
def migrate(context, rebuild_website=False): "Run patches, sync schema and rebuild files/translations" import frappe.modules.patch_handler import frappe.model.sync from frappe.utils.fixtures import sync_fixtures import frappe.translate from frappe.desk.notifications import clear_notifications for site in context.sites: print 'Migrating', site frappe.init(site=site) frappe.connect() try: prepare_for_update() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=context.verbose) frappe.translate.clear_cache() sync_fixtures() clear_notifications() finally: frappe.destroy() if rebuild_website: call_command(build_website, context) else: call_command(sync_www, context)
def execute(): sync_fixtures("erpnext_shopify") frappe.reload_doctype("Item") shopify_settings = frappe.get_doc("Shopify Settings") if not shopify_settings.enable_shopify: return try: shopify_items = get_item_list() except ShopifyError: print "Could not run shopify patch 'set_variant_id' for site: {0}".format(frappe.local.site) return if shopify_settings.shopify_url and shopify_items: for item in frappe.db.sql("""select name, item_code, shopify_id, has_variants, variant_of from tabItem where sync_with_shopify=1 and shopify_id is not null""", as_dict=1): if item.get("variant_of"): frappe.db.sql(""" update tabItem set shopify_variant_id=shopify_id where name = %s """, item.get("name")) elif not item.get("has_variants"): product = filter(lambda shopify_item: shopify_item['id'] == cint(item.get("shopify_id")), shopify_items) if product: frappe.db.sql(""" update tabItem set shopify_variant_id=%s where name = %s """, (product[0]["variants"][0]["id"], item.get("name")))
def execute(): app = __name__.split(".")[0] sync_fixtures(app) frappe.db.sql( "UPDATE `tabPlant Room` SET bio_id=ifnull(external_id, 0), bio_transactionid=external_transaction_id WHERE bio_id=0" )
def migrate(verbose=True, rebuild_website=False, skip_failing=False): '''Migrate all apps to the latest version, will: - run before migrate hooks - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www) - sync web pages (from /www) - run after migrate hooks ''' touched_tables_file = frappe.get_site_path('touched_tables.json') if os.path.exists(touched_tables_file): os.remove(touched_tables_file) try: frappe.flags.touched_tables = set() frappe.flags.in_migrate = True clear_global_cache() #run before_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('before_migrate', app_name=app): frappe.get_attr(fn)() # run patches frappe.modules.patch_handler.run_all(skip_failing) # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_jobs() sync_fixtures() sync_customizations() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # add static pages to global search global_search.update_global_search_for_all_web_pages() #run after_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('after_migrate', app_name=app): frappe.get_attr(fn)() frappe.db.commit() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False finally: with open(touched_tables_file, 'w') as f: json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4) frappe.flags.touched_tables.clear()
def latest(rebuild_website_config=True, quiet=False): import frappe.modules.patch_handler import frappe.model.sync from frappe.website import rebuild_config from frappe.utils.fixtures import sync_fixtures import frappe.translate from frappe.website import statics verbose = not quiet frappe.connect() try: # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) sync_fixtures() statics.sync().start() # build website config if any changes in templates etc. if rebuild_website_config: rebuild_config() frappe.translate.clear_cache() finally: frappe.destroy()
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www)''' clear_global_cache() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_customizations() sync_desktop_icons() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() frappe.db.commit() if not frappe.conf.get('global_help_setup'): # sync help if not set as global frappe.utils.help.sync() clear_notifications() frappe.publish_realtime("version-update")
def migrate(context, rebuild_website=False): "Run patches, sync schema and rebuild files/translations" import frappe.modules.patch_handler import frappe.model.sync from frappe.utils.fixtures import sync_fixtures import frappe.translate from frappe.desk.notifications import clear_notifications for site in context.sites: print 'Migrating', site frappe.init(site=site) frappe.connect() try: prepare_for_update() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=context.verbose) frappe.translate.clear_cache() sync_fixtures() clear_notifications() finally: frappe.publish_realtime("version-update") frappe.destroy() if rebuild_website: call_command(build_website, context) else: call_command(sync_www, context)
def execute(): sync_fixtures("woocommerceconnector") frappe.reload_doctype("Item") woocommerce_settings = frappe.get_doc("WooCommerce Config") if not woocommerce_settings.enable_woocommerce or not woocommerce_settings.password: return try: woocommerce_items = get_item_list() except woocommerceError: print("Could not run woocommerce patch 'set_variant_id' for site: {0}". format(frappe.local.site)) return if woocommerce_settings.woocommerce_url and woocommerce_items: for item in frappe.db.sql( """select name, item_code, woocommerce_id, has_variants, variant_of from tabItem where sync_with_woocommerce=1 and woocommerce_id is not null""", as_dict=1): if item.get("variant_of"): frappe.db.sql( """ update tabItem set woocommerce_variant_id=woocommerce_id where name = %s """, item.get("name")) elif not item.get("has_variants"): product = filter( lambda woocommerce_item: woocommerce_item['id'] == cint( item.get("woocommerce_id")), woocommerce_items) if product: frappe.db.sql( """ update tabItem set woocommerce_variant_id=%s where name = %s """, (product[0]["variants"][0]["id"], item.get("name")))
def install_app(name, verbose=False, set_as_patched=True): frappe.flags.in_install = name frappe.flags.ignore_in_install = False frappe.clear_cache() app_hooks = frappe.get_hooks(app_name=name) installed_apps = frappe.get_installed_apps() # install pre-requisites if app_hooks.required_apps: for app in app_hooks.required_apps: install_app(app, verbose=verbose) frappe.flags.in_install = name frappe.clear_cache() if name not in frappe.get_all_apps(): raise Exception("App not in apps.txt") if name in installed_apps: frappe.msgprint(_("App {0} already installed").format(name)) return print("\nInstalling {0}...".format(name)) if name != "frappe": frappe.only_for("System Manager") for before_install in app_hooks.before_install or []: out = frappe.get_attr(before_install)() if out == False: return if name != "frappe": add_module_defs(name) sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True) add_to_installed_apps(name) frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() if set_as_patched: set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() sync_jobs() sync_fixtures(name) sync_customizations(name) for after_sync in app_hooks.after_sync or []: frappe.get_attr(after_sync)() # frappe.flags.in_install = False
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run before migrate hooks - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www) - sync web pages (from /www) - run after migrate hooks ''' touched_tables_file = frappe.get_site_path('touched_tables.json') if os.path.exists(touched_tables_file): os.remove(touched_tables_file) try: frappe.flags.touched_tables = set() frappe.flags.in_migrate = True clear_global_cache() #run before_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('before_migrate', app_name=app): frappe.get_attr(fn)() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_customizations() sync_desktop_icons() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # add static pages to global search router.sync_global_search() #run after_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('after_migrate', app_name=app): frappe.get_attr(fn)() frappe.db.commit() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False finally: with open(touched_tables_file, 'w') as f: json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4) frappe.flags.touched_tables.clear()
def install_app(name, verbose=False, set_as_patched=True): frappe.flags.in_install = name frappe.flags.ignore_in_install = False frappe.clear_cache() app_hooks = frappe.get_hooks(app_name=name) installed_apps = frappe.get_installed_apps() # install pre-requisites if app_hooks.required_apps: for app in app_hooks.required_apps: install_app(app) frappe.flags.in_install = name frappe.clear_cache() if name not in frappe.get_all_apps(): raise Exception("App not in apps.txt") if name in installed_apps: frappe.msgprint(_("App {0} already installed").format(name)) return print("\nInstalling {0}...".format(name)) if name != "frappe": frappe.only_for("System Manager") for before_install in app_hooks.before_install or []: out = frappe.get_attr(before_install)() if out==False: return if name != "frappe": add_module_defs(name) sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True) sync_from_app(name) add_to_installed_apps(name) frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() if set_as_patched: set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() sync_fixtures(name) sync_customizations(name) for after_sync in app_hooks.after_sync or []: frappe.get_attr(after_sync)() # frappe.flags.in_install = False
def setUp(self): frappe.set_user("Administrator") sync_fixtures("erpnext_shopify") frappe.reload_doctype("Customer") frappe.reload_doctype("Sales Order") frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") self.setup_shopify()
def setUp(self): frappe.set_user("Administrator") sync_fixtures("woocommerceconnector") frappe.reload_doctype("Customer") frappe.reload_doctype("Sales Order") frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") self.setup_woocommerce()
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run before migrate hooks - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www) - sync web pages (from /www) - run after migrate hooks ''' frappe.flags.in_migrate = True clear_global_cache() #run before_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('before_migrate', app_name=app): frappe.get_attr(fn)() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_customizations() sync_desktop_icons() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # add static pages to global search router.sync_global_search() #run after_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('after_migrate', app_name=app): frappe.get_attr(fn)() frappe.db.commit() if not frappe.conf.get('global_help_setup'): # sync help if not set as global frappe.utils.help.sync() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False
def execute(): if not is_shopify_enabled(): return sync_fixtures("erpnext_shopify") fieldnames = frappe.db.sql("select fieldname from `tabCustom Field`", as_dict=1) if not any(field["fieldname"] == "shopify_supplier_id" for field in fieldnames): return frappe.db.sql("""update tabSupplier set shopify_supplier_id=supplier_name """) frappe.db.commit()
def execute(): if not is_shopify_enabled(): return sync_fixtures('erpnext_shopify') for index, shopify_item in enumerate(get_shopify_items(ignore_filter_conditions=True)): name = frappe.db.get_value("Item", {"shopify_product_id": shopify_item.get("id")}, "name") supplier = get_supplier(shopify_item) if name and supplier: frappe.db.set_value("Item", name, "default_supplier", supplier, update_modified=False) if (index+1) % 100 == 0: frappe.db.commit()
def install_app(name, verbose=False, set_as_patched=True): frappe.clear_cache() app_hooks = frappe.get_hooks(app_name=name) installed_apps = frappe.get_installed_apps() # install pre-requisites if app_hooks.required_apps: for app in app_hooks.required_apps: install_app(app) frappe.flags.in_install = name frappe.clear_cache() if name not in frappe.get_all_apps(): raise Exception("App not in apps.txt") if name in installed_apps: frappe.msgprint("App {0} already installed".format(name)) return print "Installing {0}...".format(name) if name != "frappe": frappe.only_for("System Manager") for before_install in app_hooks.before_install or []: out = frappe.get_attr(before_install)() if out == False: return if name != "frappe": add_module_defs(name) sync_for(name, force=True, sync_everything=True, verbose=verbose) sync_from_app(name) add_to_installed_apps(name) if set_as_patched: set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() print "Installing fixtures..." sync_fixtures(name) frappe.flags.in_install = False
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run before migrate hooks - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www) - sync web pages (from /www) - run after migrate hooks ''' frappe.flags.in_migrate = True clear_global_cache() #run before_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('before_migrate', app_name=app): frappe.get_attr(fn)() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_customizations() sync_desktop_icons() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # add static pages to global search router.sync_global_search() #run after_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('after_migrate', app_name=app): frappe.get_attr(fn)() frappe.db.commit() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False
def execute(): sync_fixtures("erpnext_shopify") frappe.reload_doctype("Item") frappe.reload_doctype("Customer") frappe.reload_doctype("Sales Order") frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") for doctype, column in iteritems({"Customer": "shopify_customer_id", "Item": "shopify_product_id", "Sales Order": "shopify_order_id", "Delivery Note": "shopify_order_id", "Sales Invoice": "shopify_order_id"}): if "shopify_id" in frappe.db.get_table_columns(doctype): frappe.db.sql("update `tab%s` set %s=shopify_id" % (doctype, column))
def execute(): if not is_woocommerce_enabled(): return sync_fixtures('erpnext_woocommerce') fieldnames = frappe.db.sql("select fieldname from `tabCustom Field`", as_dict=1) if not any(field['fieldname'] == 'woocommerce_supplier_id' for field in fieldnames): return frappe.db.sql( """update tabSupplier set woocommerce_supplier_id=supplier_name """) frappe.db.commit()
def install_app(name, verbose=False, set_as_patched=True): frappe.clear_cache() app_hooks = frappe.get_hooks(app_name=name) installed_apps = frappe.get_installed_apps() # install pre-requisites if app_hooks.required_apps: for app in app_hooks.required_apps: install_app(app) frappe.flags.in_install = name frappe.clear_cache() if name not in frappe.get_all_apps(with_frappe=True): raise Exception("App not in apps.txt") if name in installed_apps: frappe.msgprint("App {0} already installed".format(name)) return print "Installing {0}...".format(name) if name != "frappe": frappe.only_for("System Manager") for before_install in app_hooks.before_install or []: out = frappe.get_attr(before_install)() if out==False: return if name != "frappe": add_module_defs(name) sync_for(name, force=True, sync_everything=True, verbose=verbose) add_to_installed_apps(name) if set_as_patched: set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() print "Installing fixtures..." sync_fixtures(name) frappe.flags.in_install = False
def execute(): sync_fixtures("meli_connector") frappe.reload_doctype("Item") frappe.reload_doctype("Customer") frappe.reload_doctype("Sales Order") frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") for doctype, column in { "Customer": "meli_customer_id", "Item": "meli_product_id", "Sales Order": "meli_order_id", "Delivery Note": "meli_order_id", "Sales Invoice": "meli_order_id" }.items(): if "meli_id" in frappe.db.get_table_columns(doctype): frappe.db.sql("update `tab%s` set %s=meli_id" % (doctype, column))
def execute(): sync_fixtures("erpnext_shopify") frappe.reload_doctype("Item") frappe.reload_doctype("Customer") frappe.reload_doctype("Sales Order") frappe.reload_doctype("Delivery Note") frappe.reload_doctype("Sales Invoice") for doctype, column in iteritems({ "Customer": "shopify_customer_id", "Item": "shopify_product_id", "Sales Order": "shopify_order_id", "Delivery Note": "shopify_order_id", "Sales Invoice": "shopify_order_id" }): if "shopify_id" in frappe.db.get_table_columns(doctype): frappe.db.sql("update `tab%s` set %s=shopify_id" % (doctype, column))
def migrate(verbose=True, rebuild_website=False): '''Migrate all apps to the latest version, will: - run patches - sync doctypes (schema) - sync fixtures - sync desktop icons - sync web pages (from /www)''' frappe.flags.in_migrate = True clear_global_cache() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() sync_customizations() sync_desktop_icons() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # add static pages to global search router.sync_global_search() frappe.db.commit() if not frappe.conf.get('global_help_setup'): # sync help if not set as global frappe.utils.help.sync() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False
def execute(): frappe.reload_doc('metactical', 'doctype', 'Shipstation Order ID') sync_fixtures() frappe.reload_doc('stock', 'doctype', 'Delivery Note') delivery_notes = frappe.db.sql( '''SELECT name FROM `tabDelivery Note` WHERE ais_shipstation_orderid IS NOT NULL''', as_dict=1) shipstation_settings = frappe.db.sql( '''SELECT name FROM `tabShipstation Settings` LIMIT 1''', as_dict=1) for row in delivery_notes: delivery_note = frappe.get_doc('Delivery Note', row.name) if len(delivery_note.ais_shipstation_order_ids) == 0: shipstation_orderid = frappe.new_doc('Shipstation Order ID', delivery_note, 'ais_shipstation_order_ids') shipstation_orderid.update({ "settings_id": shipstation_settings[0].name, "shipstation_order_id": delivery_note.ais_shipstation_orderid }) shipstation_orderid.save()
def install_app(name, verbose=False, set_as_patched=True): frappe.flags.in_install_app = name frappe.clear_cache() app_hooks = frappe.get_hooks(app_name=name) installed_apps = frappe.get_installed_apps() if name not in frappe.get_all_apps(with_frappe=True): raise Exception("App not in apps.txt") if name in installed_apps: print "App Already Installed" frappe.msgprint(_("App Already Installed")) return if name != "frappe": frappe.only_for("System Manager") for before_install in app_hooks.before_install or []: frappe.get_attr(before_install)() if name != "frappe": add_module_defs(name) sync_for(name, force=True, sync_everything=True, verbose=verbose) add_to_installed_apps(name) if set_as_patched: set_all_patches_as_completed(name) for after_install in app_hooks.after_install or []: frappe.get_attr(after_install)() sync_fixtures() frappe.flags.in_install_app = False
def _migrate(site, verbose=False): import frappe.modules.patch_handler import frappe.model.sync from frappe.utils.fixtures import sync_fixtures import frappe.translate from frappe.desk.notifications import clear_notifications frappe.init(site=site) frappe.connect() try: prepare_for_update() # run patches frappe.modules.patch_handler.run_all() # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_fixtures() clear_notifications() finally: frappe.publish_realtime("version-update") frappe.destroy()
# -*- coding: utf-8 -*- from __future__ import unicode_literals import frappe from frappe import msgprint from frappe.utils.fixtures import sync_fixtures sync_fixtures() def execute(): #Transfer the address state field from data to link field address_list = frappe.db.sql("""SELECT name FROM `tabAddress` WHERE docstatus = 0""", as_list=1) for add in address_list: add_doc = frappe.get_doc("Address", add[0]) frappe.db.set_value("Address", add_doc.name, "state_rigpl", add_doc.state) print("Update Address: " + add_doc.name + " State value to " + str(add_doc.state))
def after_install(): app = __name__.split(".")[0] sync_fixtures(app) install_fixtures()
def execute(): sync_fixtures("erpnext_shopify")
def migrate(verbose=True, skip_failing=False, skip_search_index=False): '''Migrate all apps to the current version, will: - run before migrate hooks - run patches - sync doctypes (schema) - sync dashboards - sync fixtures - sync desktop icons - sync web pages (from /www) - sync web pages (from /www) - run after migrate hooks ''' service_status = check_connection(redis_services=["redis_cache"]) if False in service_status.values(): for service in service_status: if not service_status.get(service, True): print("{} service is not running.".format(service)) print("""Cannot run bench migrate without the services running. If you are running bench in development mode, make sure that bench is running: $ bench start Otherwise, check the server logs and ensure that all the required services are running.""" ) sys.exit(1) touched_tables_file = frappe.get_site_path('touched_tables.json') if os.path.exists(touched_tables_file): os.remove(touched_tables_file) try: frappe.flags.touched_tables = set() frappe.flags.in_migrate = True clear_global_cache() #run before_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('before_migrate', app_name=app): frappe.get_attr(fn)() # run patches frappe.modules.patch_handler.run_all(skip_failing) # sync frappe.model.sync.sync_all(verbose=verbose) frappe.translate.clear_cache() sync_jobs() sync_fixtures() sync_dashboards() sync_customizations() sync_languages() frappe.get_doc('Portal Settings', 'Portal Settings').sync_menu() # syncs statics render.clear_cache() # updating installed applications data frappe.get_single('Installed Applications').update_versions() #run after_migrate hooks for app in frappe.get_installed_apps(): for fn in frappe.get_hooks('after_migrate', app_name=app): frappe.get_attr(fn)() # build web_routes index if not skip_search_index: # Run this last as it updates the current session print('Building search index for {}'.format(frappe.local.site)) build_index_for_all_routes() frappe.db.commit() clear_notifications() frappe.publish_realtime("version-update") frappe.flags.in_migrate = False finally: with open(touched_tables_file, 'w') as f: json.dump(list(frappe.flags.touched_tables), f, sort_keys=True, indent=4) frappe.flags.touched_tables.clear()
# -*- coding: utf-8 -*- from __future__ import unicode_literals import frappe from frappe import msgprint from frappe.utils.fixtures import sync_fixtures sync_fixtures() def execute(): #Transfer the address state field from data to link field address_list = frappe.db.sql("""SELECT name FROM `tabAddress` WHERE docstatus = 0""",as_list=1) for add in address_list: add_doc = frappe.get_doc("Address", add[0]) frappe.db.set_value("Address", add_doc.name, "state_rigpl", add_doc.state) print ("Update Address: " + add_doc.name + " State value to " + str(add_doc.state))
def execute(): sync_fixtures("bcommerce")
def execute(): sync_fixtures("meli_connector")
def execute(): sync_fixtures("erpnext_woocommerce")