Example #1
0
def migrate(cr, version):
    openupgrade.update_module_names(cr, apriori.renamed_modules.iteritems())
    openupgrade.copy_columns(cr, column_copies)
    openupgrade.rename_columns(cr, column_renames)
    remove_obsolete(cr)
    pre_create_columns(cr)
    cleanup_modules(cr)
Example #2
0
def migrate(cr, version):
    openupgrade.rename_columns(cr, _column_renames)
    cr.execute(
        # we rely on the ORM to write this value
        'alter table ir_model_fields add column store boolean'
    )
    openupgrade.copy_columns(cr, {
        'ir_act_window': [
            ('target', None, None),
        ],
    })
    openupgrade.map_values(
        cr, openupgrade.get_legacy_name('target'), 'target',
        [
            ('inlineview', 'inline'),
        ],
        table='ir_act_window')
    cr.execute(
        "update ir_ui_view set type='kanban' where type='sales_team_dashboard'"
    )
    cr.execute('update res_currency set symbol=name where symbol is null')
    # create xmlids for installed languages
    cr.execute(
        '''insert into ir_model_data
        (module, name, model, res_id)
        select
        'base',
        'lang_' ||
        case
            when char_length(code) > 2 then
            case
                when upper(substring(code from 1 for 2)) =
                upper(substring(code from 4 for 2)) then
                    substring(code from 1 for 2)
                else
                    code
            end
            else
                code
        end,
        'res.lang', id
        from res_lang''')
    openupgrade.update_module_names(
        cr, [
            ('account_full_reconcile', 'account'),
            ('mail_tip', 'mail'),
            ('project_timesheet', 'hr_timesheet'),
            ('sale_service', 'sale_timesheet'),
            ('share', 'base'),
            ('web_tip', 'web'),
            ('web_view_editor', 'web'),
            ('mail_tip', 'mail'),
            ('im_odoo_support', 'im_livechat'),
            ('marketing', 'marketing_campaign'),
            # OCA/sale-workflow
            ('sale_order_back2draft', 'sale'),
            # OCA/social
            ('mass_mailing_security_group', 'mass_mailing'),
        ], merge_modules=True,
    )
Example #3
0
def merge_padron_into_account(cr):
    _logger.info('Mergin padron module into account')
    openupgrade.update_module_names(
        cr,
        [('l10n_ar_padron_afip', 'l10n_ar_account')],
        merge_modules=True,
    )
Example #4
0
def migrate(env, version):
    openupgrade.update_module_names(env.cr, apriori.renamed_modules.items())
    openupgrade.update_module_names(env.cr,
                                    apriori.merged_modules.items(),
                                    merge_modules=True)
    openupgrade.copy_columns(env.cr, column_copies)
    openupgrade.rename_columns(env.cr, column_renames)
    openupgrade.rename_models(env.cr, model_renames_ir_actions_report)
    env.cr.execute("""UPDATE ir_actions SET type = 'ir.actions.report'
        WHERE type = 'ir.actions.report.xml'""")

    rule_xml_ids = ('ir_config_parameter_rule', 'ir_values_default_rule')
    env.cr.execute(
        """ DELETE FROM ir_rule WHERE id IN (
                SELECT res_id FROM ir_model_data WHERE module = 'base'
                    AND name IN %s) """, (rule_xml_ids, ))
    env.cr.execute(
        """ DELETE FROM ir_model_data WHERE module = 'base'
                AND name IN %s """, (rule_xml_ids, ))

    # All existing server actions are of type server action
    env.cr.execute(""" ALTER TABLE ir_act_server ADD COLUMN usage VARCHAR;
        UPDATE ir_act_server SET usage = 'ir_actions_server'""")
    # For some window actions, there is a value in the old column
    # that was inherited from ir_actions before
    env.cr.execute(
        """ ALTER TABLE ir_act_window ADD COLUMN usage VARCHAR;
        UPDATE ir_act_window SET usage = %s""",
        (AsIs(openupgrade.get_legacy_name('usage')), ))

    # work_days interval was removed from selection values
    env.cr.execute("""
        UPDATE ir_cron SET interval_type = 'days'
        WHERE interval_type = 'work_days'""")
Example #5
0
def migrate(env, version):
    cr = env.cr
    install_new_modules(env.cr)

    if openupgrade.is_module_installed(env.cr, 'bank_view_improv'):
        openupgrade.update_module_names(env.cr,
                                        [('bank_view_improv', 'nsm_account')],
                                        merge_modules=True)

    if openupgrade.is_module_installed(env.cr, 'nsm_analytic'):
        openupgrade.update_module_names(env.cr,
                                        [('nsm_analytic', 'nsm_account')],
                                        merge_modules=True)

    if openupgrade.is_module_installed(env.cr, 'nsm_analytic_2'):
        openupgrade.update_module_names(env.cr,
                                        [('nsm_analytic_2', 'nsm_account')],
                                        merge_modules=True)

    if openupgrade.is_module_installed(env.cr, 'nsm_invoice_layout'):
        openupgrade.update_module_names(
            env.cr, [('nsm_invoice_layout', 'nsm_account')],
            merge_modules=True)

    if openupgrade.is_module_installed(env.cr,
                                       'nsm_merge_to_print_supplier_invoices'):
        openupgrade.update_module_names(
            env.cr, [('nsm_merge_to_print_supplier_invoices', 'nsm_account')],
            merge_modules=True)
Example #6
0
def migrate(env, version):
    install_new_modules(env.cr)

    if openupgrade.is_module_installed(env.cr, 'nsm_supportal_extension'):
        openupgrade.update_module_names(
            env.cr, [('nsm_supportal_extension', 'nsm_supplier_portal')],
            merge_modules=True)
Example #7
0
def pre_init_hook(cr):
    """Loaded before installing the module.
    """
    openupgrade.update_module_names(
        cr, [('stock_location_restrict_group',
              'stock_location_restrict_procurement_group')],
        merge_modules=True)
Example #8
0
def migrate(env, version):
    openupgrade.remove_tables_fks(env.cr, _obsolete_tables)
    remove_invoice_table_relations(env)
    # Deactivate the noupdate flag (hardcoded on initial SQL load) for allowing
    # to update changed data on this group.
    openupgrade.logged_query(
        env.cr,
        """
        UPDATE ir_model_data SET noupdate=False
        WHERE module='base' AND name='group_user'""",
    )
    openupgrade.update_module_names(env.cr, apriori.renamed_modules.items())
    openupgrade.update_module_names(env.cr,
                                    apriori.merged_modules.items(),
                                    merge_modules=True)
    openupgrade.copy_columns(env.cr, column_copies)
    openupgrade.rename_columns(env.cr, column_renames)
    openupgrade.rename_fields(env, field_renames, no_deep=True)
    openupgrade.rename_xmlids(env.cr, xmlid_renames_res_country_state)
    openupgrade.rename_xmlids(env.cr, xmlid_renames_ir_model_access)
    fill_ir_model_data_noupdate(env)
    fix_lang_table(env.cr)
    remove_offending_translations(env)
    handle_web_favicon_module(env)
    add_res_lang_url_code(env)
    switch_noupdate_records(env)
    rename_ir_module_category(env)
    openupgrade.logged_query(
        env.cr, """ UPDATE ir_model_constraint
        SET create_date = date_init
        WHERE create_date IS NULL AND date_init IS NOT NULL """)
    openupgrade.logged_query(
        env.cr, """ UPDATE ir_model_constraint
        SET write_date = date_update
        WHERE write_date IS NULL AND date_update IS NOT NULL """)
Example #9
0
def migrate(cr, version):
    """
    Don't request an env for the base pre-migration as flushing the env in
    odoo/modules/registry.py will break on the 'base' module not yet having
    been instantiated.
    """
    if "openupgrade_framework" not in tools.config["server_wide_modules"]:
        logging.error(
            "openupgrade_framework is not preloaded. You are highly "
            "recommended to run the Odoo with --load=openupgrade_framework "
            "when migrating your database.")

    openupgrade.rename_xmlids(cr, rename_xmlids_l10n_ec)
    openupgrade.rename_xmlids(cr, rename_xmlids_mail)

    openupgrade.update_module_names(cr, renamed_modules.items())
    openupgrade.update_module_names(cr,
                                    merged_modules.items(),
                                    merge_modules=True)

    openupgrade.convert_field_to_html(cr, "res_company", "report_footer",
                                      "report_footer")
    openupgrade.convert_field_to_html(cr, "res_company", "report_header",
                                      "report_header")
    openupgrade.convert_field_to_html(cr, "res_partner", "comment", "comment")
Example #10
0
def cleanup_modules(cr):
    """Don't report as missing these modules, as they are integrated in
    other modules."""
    openupgrade.update_module_names(
        cr,
        [
            ('marketing_crm', 'crm'),
            ('web_gantt', 'web'),
            ('web_graph', 'web'),
            ('web_kanban_sparkline', 'web'),
            ('web_tests', 'web'),
            ('website_report', 'report'),
            # from OCA/server-tools - features included now in core
            ('base_concurrency', 'base'),
            ('base_debug4all', 'base'),
            ('cron_run_manually', 'base'),
            ('shell', 'base'),
            # from OCA/social - included in core
            ('website_mail_snippet_table_edit', 'mass_mailing'),
            ('mass_mailing_sending_queue', 'mass_mailing'),
            # from OCA/crm - included in core
            ('crm_lead_lost_reason', 'crm'),
        ],
        merge_modules=True,
    )
Example #11
0
def migrate(env, version):
    openupgrade.update_module_names(env.cr, apriori.renamed_modules.items())
    openupgrade.update_module_names(env.cr,
                                    apriori.merged_modules.items(),
                                    merge_modules=True)
    openupgrade.rename_models(env.cr, model_renames)
    openupgrade.rename_tables(env.cr, table_renames)
    if openupgrade.table_exists(env.cr, 'stock_incoterms'):
        openupgrade.rename_models(
            env.cr,
            [('stock.incoterms', 'account.incoterms')],
        )
        openupgrade.rename_tables(
            env.cr,
            [('stock_incoterms', 'account_incoterms')],
        )
    openupgrade.rename_xmlids(env.cr, xmlid_renames)
    eliminate_duplicate_translations(env.cr)

    # Make the system and admin user XML ids refer to the same entry for now to
    # prevent errors when base data is loaded. The users are picked apart in
    # this module's end stage migration script.
    env.cr.execute(""" INSERT INTO ir_model_data
        (module, name, model, res_id, noupdate)
        VALUES('base', 'user_admin', 'res.users', 1, true)""")
    env.cr.execute(""" INSERT INTO ir_model_data
        (module, name, model, res_id, noupdate)
        (SELECT module, 'partner_admin', model, res_id, noupdate
         FROM ir_model_data WHERE module = 'base' AND name = 'partner_root')
        """)
    fix_lang_constraints(env)
    fix_lang_table(env)
    # for migration of web module
    openupgrade.rename_columns(
        env.cr, {'res_company': [('external_report_layout', None)]})
Example #12
0
def migrate(env, version):
    openupgrade.update_module_names(
        env.cr,
        [
            ("l10n_br_simple", "l10n_br_coa_simple"),
        ],
        merge_modules=True,
    )
Example #13
0
 def migrate(self):
     if can_upgrade:
         openupgrade.update_module_names(self.env.cr, [
             ('hr_attendance_calendar', 'hr_attendance_extra_hours'),
         ],
                                         merge_modules=True)
         return True
     return False
def rename_module(cr):
    openupgrade.update_module_names(
        cr,
        [
            ('connector_locomotivecms', 'shopinvader_locomotive'),
        ],
        merge_modules=True,
    )
Example #15
0
def migrate(cr, version):
    """
    unificamos el modulo de padron en l10n_ar_account
    """
    openupgrade.update_module_names(
        cr,
        [('l10n_ar_padron_afip', 'l10n_ar_account')],
        merge_modules=True,
    )
Example #16
0
def migrate(cr, version):
    openupgrade.update_module_names(
        cr,
        [('email_template', 'mail')],
        merge_modules=True,
    )
    openupgrade.rename_models(cr, model_renames)
    openupgrade.rename_tables(cr, table_renames)
    openupgrade.rename_columns(cr, column_renames)
Example #17
0
def pre_init_hook(cr):
    """
    Rename the module 'shopinvader_stock' into 'shopinvader_product_stock'.
    :param cr: database cursor
    :return:
    """
    openupgrade.update_module_names(
        cr, [('shopinvader_stock', 'shopinvader_product_stock')],
        merge_modules=True)
Example #18
0
def cleanup_modules(cr):
    openupgrade.update_module_names(
        cr,
        [
            ('sale_layout', 'sale'),
            ('product_visible_discount', 'sale'),
        ],
        merge_modules=True
    )
Example #19
0
def migrate(env, version):
    # Deactivate the noupdate flag (hardcoded on initial SQL load) for allowing
    # to update changed data on this group.
    openupgrade.logged_query(
        env.cr,
        """
        UPDATE ir_model_data SET noupdate=False
        WHERE  module='base' AND name='group_user'""",
    )
    openupgrade.update_module_names(env.cr, apriori.renamed_modules.items())
    openupgrade.update_module_names(env.cr,
                                    apriori.merged_modules.items(),
                                    merge_modules=True)
    if openupgrade.table_exists(env.cr, 'product_uom'):
        openupgrade.rename_models(env.cr, model_renames_product)
        openupgrade.rename_tables(env.cr, table_renames_product)
    if openupgrade.table_exists(env.cr, 'stock_incoterms'):
        openupgrade.rename_models(env.cr, model_renames_stock)
        openupgrade.rename_tables(env.cr, table_renames_stock)
    openupgrade.rename_xmlids(env.cr, xmlid_renames)
    switch_noupdate_flag(env)
    eliminate_duplicate_translations(env.cr)

    # Make the system and admin user XML ids refer to the same entry for now to
    # prevent errors when base data is loaded. The users are picked apart in
    # this module's end stage migration script.
    # Safely, we check first if the `base.user_admin` already exists to
    # avoid possible conflicts: very old databases may have this record.
    env.cr.execute("""
        SELECT id
        FROM ir_model_data
        WHERE name='user_admin' AND module='base' AND model='res.users'""")
    if env.cr.fetchone():
        env.cr.execute("""
            UPDATE ir_model_data
            SET model='res.users',res_id=1,noupdate=true
            WHERE name='user_admin' AND module='base' AND model='res.users'""")
    else:
        env.cr.execute("""
            INSERT INTO ir_model_data
            (module, name, model, res_id, noupdate)
            VALUES('base', 'user_admin', 'res.users', 1, true)""")
    env.cr.execute(""" INSERT INTO ir_model_data
        (module, name, model, res_id, noupdate)
        (SELECT module, 'partner_admin', model, res_id, noupdate
         FROM ir_model_data WHERE module = 'base' AND name = 'partner_root')
        """)
    fix_lang_constraints(env)
    fix_lang_table(env)
    # fast compute of res_model_name
    fill_ir_attachment_res_model_name(env.cr)
    # for migration of web module
    openupgrade.rename_columns(
        env.cr, {'res_company': [('external_report_layout', None)]})
    # for migration of website module
    fill_ir_ui_view_key(env.cr)
Example #20
0
def cleanup_modules(cr):
    """Don't report as missing these modules, as they are integrated in
    other modules."""
    openupgrade.update_module_names(
        cr,
        [
            ('account_asset_disposal_analytic', 'account_asset_analytic'),
        ],
        merge_modules=True,
    )
 def migrate(self):
     if can_upgrade:
         openupgrade.update_module_names(
             self.env.cr, [
                 ('hr_attendance_calendar', 'hr_attendance_extra_hours'),
             ],
             merge_modules=True
         )
         return True
     return False
Example #22
0
def rename_mass_mailing_event(env):
    env.cr.execute("""
        SELECT id
        FROM ir_module_module
        WHERE name = 'mass_mailing_event' AND state <> 'uninstalled'""")
    row = env.cr.fetchone()
    if row:
        openupgrade.update_module_names(env.cr, [
            ("mass_mailing_event", "mass_mailing_event_registration_exclude")
        ],
                                        merge_modules=True)
Example #23
0
def migrate(cr, version):
    modules = [
        ('account_cash_discount_payment_term', 'account_cash_discount_base'),
    ]
    openupgrade.update_module_names(cr, modules, merge_modules=True)
    # recompute fields
    cr.execute("""
        ALTER TABLE account_invoice
            DROP COLUMN IF EXISTS discount_amount;
        ALTER TABLE account_invoice
            DROP COLUMN IF EXISTS amount_total_with_discount;
        """)
Example #24
0
def migrate(cr, version):
    openupgrade.copy_columns(cr, column_copys)
    openupgrade.update_module_names(
        cr, [
            ('hr_timesheet_invoice', 'contract'),
            ('contract_journal', 'contract'),
            ('contract_discount', 'contract'),
            ('contract_recurring_invoicing_marker', 'contract'),
            ('contract_recurring_invoicing_monthly_last_day', 'contract'),
            ('contract_show_recurring_invoice', 'contract'),
        ], merge_modules=True,
    )
Example #25
0
def migrate(cr, version):
    openupgrade.copy_columns(cr, column_copys)
    openupgrade.update_module_names(
        cr,
        [
            ('hr_timesheet_invoice', 'contract'),
            ('contract_journal', 'contract'),
            ('contract_discount', 'contract'),
            ('contract_recurring_invoicing_marker', 'contract'),
            ('contract_recurring_invoicing_monthly_last_day', 'contract'),
            ('contract_show_recurring_invoice', 'contract'),
        ],
        merge_modules=True,
    )
Example #26
0
def rename_modules(ctx):
    """ Rename modules """
    update_module_names(
        ctx.env.cr,
        [
            # Here we need to list:
            # all modules on which
            # the module is renamed between the old and new version

            # Example:
            # ('account_financial_report_webkit', 'account_financial_report'),
        ],
        merge_modules=True,
    )
Example #27
0
def migrate_account_invoice_shipping_address(cr):
    """The feature of this module is now on core, so we merge and change data
    accordingly.
    """
    module_name = 'account_invoice_shipping_address'
    if not openupgrade.is_module_installed(cr, module_name):
        return
    openupgrade.update_module_names(
        cr,
        [(module_name, 'sale')],
        merge_modules=True,
    )
    openupgrade.rename_columns(
        cr,
        [('address_shipping_id', 'partner_shipping_id')],
    )
def migrate(env, version):
    openupgrade.update_module_names(
        env.cr,
        [("delivery_carrier_label_postlogistics", "delivery_postlogistics")],
        merge_modules=True,
    )

    # Delete obsolete model
    env.cr.execute("""
        DELETE FROM ir_model_fields
        WHERE model_id IN
        (SELECT id FROM ir_model WHERE model IN
            ('postlogistics.auth', 'delivery.carrier.template.option'));
    """)

    # Remove obsolete view
    openupgrade.delete_records_safely_by_xml_id(
        env, ["delivery_postlogistics.view_postlogistics_auth_form"])
Example #29
0
def pre_init_hook(cr):
    """Since 4 modules (sale_warehouse_calendar, sale_cutoff_time_delivery,
    sale_partner_delivery_window, sale_partner_cutoff_delivery_window)
    are merged into this one, we have to set the previous modules as
    uninstalled, as well as we need to update the module names in ir_model_data
    """
    query_installed = """
        SELECT id FROM ir_module_module
        WHERE name IN %s and state IN ('installed', 'to upgrade')
    """
    cr.execute(query_installed, (MERGED_MODULE_NAMES, ))
    modules_installed = any(row[0] for row in cr.fetchall())
    if modules_installed:
        modules_to_merge = [(merged_module_name, "sale_delivery_date")
                            for merged_module_name in MERGED_MODULE_NAMES]
        openupgrade.update_module_names(cr,
                                        modules_to_merge,
                                        merge_modules=True)
Example #30
0
def migrate(cr, version):
    """
    Don't request an env for the base pre migration as flushing the env in
    odoo/modules/registry.py will break on the 'base' module not yet having
    been instantiated.
    """
    if "openupgrade_framework" not in tools.config["server_wide_modules"]:
        logging.error(
            "openupgrade_framework is not preloaded. You are highly "
            "recommended to run the Odoo with --load=openupgrade_framework "
            "when migrating your database.")
    # Rename xmlids of module categies with allow_merge
    openupgrade.rename_xmlids(cr,
                              module_category_xmlid_renames,
                              allow_merge=True)
    # Update ir_model_data timestamps from obsolete columns
    openupgrade.logged_query(
        cr,
        """
        UPDATE ir_model_data
        SET create_date = COALESCE(date_init, create_date),
            write_date = COALESCE(date_update, write_date)
        WHERE (create_date IS NULL OR write_date IS NULL) AND
            (date_init IS NOT NULL OR date_update IS NOT NULL)
        """,
    )
    # Set default values from odoo/addons/base/data/base_data.sql
    cr.execute(""" ALTER TABLE ir_model_data
        ALTER COLUMN create_date
        SET DEFAULT NOW() AT TIME ZONE 'UTC',
        ALTER COLUMN write_date
        SET DEFAULT NOW() AT TIME ZONE 'UTC'
    """)
    # Perform module renames and merges
    openupgrade.update_module_names(cr, renamed_modules.items())
    openupgrade.update_module_names(cr,
                                    merged_modules.items(),
                                    merge_modules=True)
    # Migrate partners from Fil to Tagalog
    # See https://github.com/odoo/odoo/commit/194ed76c5cc9
    openupgrade.logged_query(
        cr, "UPDATE res_partner SET lang = 'tl_PH' WHERE lang = 'fil_PH'")
    deduplicate_ir_properties(cr)
Example #31
0
def migrate(env, version):
    openupgrade.remove_tables_fks(env.cr, _obsolete_tables)
    openupgrade.update_module_names(env.cr, apriori.renamed_modules.items())
    openupgrade.update_module_names(env.cr,
                                    apriori.merged_modules.items(),
                                    merge_modules=True)
    openupgrade.rename_columns(env.cr, column_renames)
    openupgrade.rename_models(env.cr, model_renames_ir_actions_report)
    handle_partner_sector(env)
    env.cr.execute("""UPDATE ir_actions SET type = 'ir.actions.report'
        WHERE type = 'ir.actions.report.xml'""")

    rule_xml_ids = ('ir_config_parameter_rule', 'ir_values_default_rule')
    env.cr.execute(
        """ DELETE FROM ir_rule WHERE id IN (
                SELECT res_id FROM ir_model_data WHERE module = 'base'
                    AND name IN %s) """, (rule_xml_ids, ))
    env.cr.execute(
        """ DELETE FROM ir_model_data WHERE module = 'base'
                AND name IN %s """, (rule_xml_ids, ))

    # All existing server actions are of type server action
    env.cr.execute(""" ALTER TABLE ir_act_server ADD COLUMN usage VARCHAR;
        UPDATE ir_act_server SET usage = 'ir_actions_server'""")
    # For some window actions, there is a value in the old column
    # that was inherited from ir_actions before
    env.cr.execute(
        """ ALTER TABLE ir_act_window ADD COLUMN usage VARCHAR;
        UPDATE ir_act_window SET usage = %s""",
        (AsIs(openupgrade.get_legacy_name('usage')), ))

    # work_days interval was removed from selection values
    env.cr.execute("""
        UPDATE ir_cron SET interval_type = 'days'
        WHERE interval_type = 'work_days'""")
    fill_cron_action_server_pre(env)
    openupgrade.set_xml_ids_noupdate_value(env, 'base', ['lang_km'], True)
    set_currency_rate_dates(env)

    # Rename 'mass_mailing_event' module to not collide with the new
    # core module with the same name.
    rename_mass_mailing_event(env)
Example #32
0
def rename_old_italian_module(cr):

    if not openupgrade.is_module_installed(cr, "l10n_it_esigibilita_iva"):
        return

    openupgrade.rename_xmlids(
        cr,
        [
            (
                "l10n_it_esigibilita_iva.view_tax_code_esigibilita_form",
                "l10n_it_vat_payability.view_tax_code_payability_form",
            ),
        ],
    )
    openupgrade.update_module_names(
        cr,
        [
            ("l10n_it_esigibilita_iva", "l10n_it_vat_payability"),
        ],
        merge_modules=True,
    )