Example #1
0
def migrate(env, version):
    cr = env.cr
    openupgrade.delete_records_safely_by_xml_id(
        env,
        ['account.action_view_account_move_line_reconcile'],
    )
    openupgrade.copy_columns(cr, _column_copies)
    openupgrade.rename_columns(cr, _column_renames)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(cr, xmlid_renames)
    if openupgrade.table_exists(cr, 'sale_order'):
        openupgrade.rename_fields(env, _field_renames_sale)
    if openupgrade.table_exists(cr, 'sale_layout_category'):
        fill_account_invoice_line_sections(cr)
    if openupgrade.table_exists(cr, 'account_move_reverse'):
        # module account_reversal
        openupgrade.rename_fields(env, _field_renames_account_reversal)
    if not openupgrade.column_exists(env.cr, 'res_company', 'incoterm_id'):
        openupgrade.logged_query(
            env.cr,
            """
            ALTER TABLE res_company ADD COLUMN incoterm_id INTEGER""",
        )
    prefill_account_chart_template_transfer_account_prefix(env)
    openupgrade.set_xml_ids_noupdate_value(
        env, 'account', ['account_analytic_line_rule_billing_user'], False)
Example #2
0
def migrate(env, version):
    cr = env.cr
    openupgrade.copy_columns(cr, _column_copies)
    openupgrade.rename_columns(cr, _column_renames)
    openupgrade.rename_fields(env, _field_renames)
    if openupgrade.table_exists(cr, 'sale_order'):
        openupgrade.rename_fields(env, _field_sale_renames)
        # https://github.com/odoo/odoo/commit/ca25a692bd19fdca2b2600f2054eb419aae28999
        openupgrade.logged_query(
            env.cr, """
            UPDATE ir_config_parameter
            SET key = 'account.use_invoice_terms'
            WHERE key = 'sale.use_sale_note'"""
        )
    openupgrade.rename_models(cr, _model_renames)
    openupgrade.rename_tables(cr, _table_renames)
    type_change_account_fiscal_position_zips(env)
    create_account_invoice_amount_tax_company_signed(env)
    create_account_move_new_columns(env)
    fill_account_move_line_parent_state(env)
    fill_account_move_line_account_internal_type(env)
    create_res_partner_ranks(env)
    add_helper_invoice_move_rel(env)
    if openupgrade.table_exists(cr, 'account_voucher'):
        add_helper_voucher_move_rel(env)
Example #3
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)
    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)
    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)]})
    # for migration of website module
    fill_ir_ui_view_key(env.cr)
def update_invoice_relation_fields(env):
    # In a Odoo project started from v13.0, these invoices tables doesn't exist!
    if openupgrade.table_exists(env.cr, "account_invoice"):
        openupgrade.logged_query(
            env.cr,
            """
            UPDATE account_move am
            SET (intrastat_transaction_id, intrastat_transport_id,
                src_dest_country_id, intrastat_country, src_dest_region_id
                ) = (ai.intrastat_transaction_id,
                ai.intrastat_transport_id, ai.src_dest_country_id,
                ai.intrastat_country, ai.src_dest_region_id)
            FROM account_invoice ai
            WHERE am.old_invoice_id = ai.id""",
        )
        if openupgrade.table_exists(env.cr, "account_invoice_line"):
            openupgrade.logged_query(
                env.cr,
                """
                UPDATE intrastat_product_computation_line ipcl
                SET invoice_line_id = aml.id
                FROM account_invoice_line ail
                JOIN account_move_line aml ON aml.old_invoice_line_id = ail.id
                WHERE ipcl.%(old_line_id)s = ail.id""" % {
                    "old_line_id":
                    openupgrade.get_legacy_name("invoice_line_id")
                },
            )
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(cr, 'licence_licence'):
        openupgrade.rename_models(cr, _model_renames)
        if openupgrade.table_exists(cr, 'software_license'):
            cr.execute("DROP TABLE software_license;")
        if openupgrade.table_exists(cr, 'software_license_application'):
            cr.execute("DROP TABLE software_license_application;")
        openupgrade.rename_tables(cr, _table_renames)
Example #6
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 #7
0
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(cr, 'project_category_main') and \
            openupgrade.table_exists(cr, 'project_category'):
        query = """
            UPDATE business_requirement_resource m SET categ_id = a.id
              FROM project_category a, project_category_main b
            WHERE a.name = b.name
              AND m.categ_id = b.id
            ;
        """
        openupgrade.logged_query(cr, query)
    openupgrade.logging("business_requirement_resource migration done.")
Example #8
0
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(cr, 'account_asset_asset'):
        # `account_asset` module was installed in v11
        if openupgrade.table_exists(cr, 'account_asset'):
            # `account_asset_management` module also installed in v11
            # TODO: Merge in existing tables assets if both module installed
            pass
        else:
            openupgrade.rename_models(cr, _model_renames)
            openupgrade.rename_tables(cr, _table_renames)
            openupgrade.copy_columns(cr, _column_copies)
            openupgrade.rename_columns(cr, _column_renames)
            openupgrade.rename_fields(env, _field_renames)
Example #9
0
def migrate(env, version):
    cr = env.cr
    # pre-creation for speed up
    if not openupgrade.column_exists(cr, 'res_company', 'nomenclature_id'):
        openupgrade.add_fields(
            env,
            [
                ('nomenclature_id', 'res.company', 'res_company', 'many2one',
                 'int4', 'barcodes'),
            ],
        )

        # done here instead of post-migration to avoid the default
        if openupgrade.table_exists(cr, 'stock_picking_type'):
            openupgrade.logged_query(
                cr, """
                UPDATE res_company rc
                SET nomenclature_id = spt.barcode_nomenclature_id
                FROM stock_picking_type spt
                LEFT JOIN stock_warehouse sw ON spt.warehouse_id = sw.id
                WHERE sw.company_id = rc.id
                    AND spt.barcode_nomenclature_id IS NOT NULL""")

        default_nomenclature_id = env["ir.model.data"].xmlid_to_res_id(
            "barcodes.default_barcode_nomenclature",
            raise_if_not_found=False,
        )
        if default_nomenclature_id:
            openupgrade.logged_query(
                env.cr, """
                UPDATE res_company
                SET nomenclature_id = {def_n_id}
                WHERE nomenclature_id IS NULL
                """.format(def_n_id=default_nomenclature_id))
Example #10
0
def import_website_seo_redirection_data(env):
    """Check if module was installed looking to the expected table, and then
    import data in the new website feature table.
    """
    if not openupgrade.table_exists(env.cr, 'website_seo_redirection'):
        return
    # Transfer normal redirections directly
    openupgrade.logged_query(
        env.cr, """
        INSERT INTO website_redirect
        (type, url_from, url_to, active, sequence)
        SELECT '301', wsr.origin, wsr.destination, True, 10
        FROM website_seo_redirection wsr""",
    )
    # Find relocated pages and relocate them
    openupgrade.logged_query(
        env.cr, """
        UPDATE website_page wp
        SET url = wsr.destination
        FROM website_seo_redirection wsr
        WHERE
            wp.url = wsr.origin AND
            wsr.relocate_controller AND
            wsr.origin LIKE '/page/%%'"""
    )
Example #11
0
def migrate(env, version):
    if openupgrade.table_exists(env.cr, "crm_lead_tag"):
        openupgrade.rename_models(
            env.cr,
            [
                ("crm.lead.tag", "crm.tag"),
            ],
        )
        openupgrade.rename_tables(
            env.cr,
            [
                ("crm_lead_tag", "crm_tag"),
            ],
        )
    openupgrade.set_xml_ids_noupdate_value(
        env, "sales_team", ["crm_rule_all_salesteam", "sale_team_comp_rule"], True
    )
    openupgrade.rename_xmlids(
        env.cr,
        [
            ("crm.crm_lead_tag_action", "sales_team.sales_team_crm_tag_action"),
            ("crm.crm_lead_tag_form", "sales_team.sales_team_crm_tag_view_form"),
            ("crm.crm_lead_tag_tree", "sales_team.sales_team_crm_tag_view_tree"),
            ("crm.access_crm_lead_tag", "sales_team.access_crm_tag"),
            ("crm.access_crm_lead_tag_manager", "sales_team.access_crm_tag_manager"),
            ("crm.access_crm_lead_tag_salesman", "sales_team.access_crm_tag_salesman"),
        ],
    )
Example #12
0
def migrate(env, version):
    post_init_hook(env.cr, None)

    # if not coming from a v10 database return
    if not openupgrade.table_exists(
        env.cr, "l10n_br_fiscal_document_invalidate_number"
    ):
        return

    # else migrate some partner fiscal data:
    env.cr.execute(
        """
        SELECT id, code, is_company FROM l10n_br_account_partner_fiscal_type;
        """
    )
    fiscal_profiles = env.cr.fetchall()
    for profile in fiscal_profiles:
        code = False
        if profile[1] == "Contribuinte":
            code = "CNT"
        if profile[1] == "Simples Nacional":
            code = "SNC"
        if profile[1] == "Não Contribuinte" and profile[2]:
            code = "CNT"
        if profile[1] == "Não Contribuinte" and not profile[2]:
            code = "PFNC"
        # TODO map Revenda?
        if code:
            openupgrade.logged_query(
                env.cr,
                """
                UPDATE res_partner set fiscal_profile_id=
                (SELECT id from l10n_br_fiscal_partner_profile
                WHERE code=%s)
                WHERE openupgrade_legacy_12_0_partner_fiscal_type_id=%s
                """,
                (code, profile[0]),
            )

    # and then migrate product fiscal data:
    env.cr.execute(
        """SELECT product_template.id, c.code FROM product_template
        JOIN account_product_fiscal_classification as c
        ON c.id = openupgrade_legacy_12_0_fiscal_classification_id
        WHERE c.code IS NOT NULL;
        """
    )
    templates = env.cr.fetchall()
    for item in templates:
        tmpl = env["product.template"].browse(item[0])
        ncms = env["l10n_br_fiscal.ncm"].search([("code", "=", item[1])])
        product_data = {}
        if ncms:
            product_data["ncm_id"] = ncms[0].id
        genre_code = item[1][0:2]
        genres = env["l10n_br_fiscal.product.genre"].search([("code", "=", genre_code)])
        if genres:
            product_data["fiscal_genre_id"] = genres[0].id
        if ncms or genres:
            tmpl.write(product_data)
Example #13
0
def migrate(env, version):
    openupgrade.copy_columns(env.cr, _column_copies)
    if openupgrade.column_exists(env.cr, 'sale_order', 'payment_tx_id'):
        # from sale_payment module
        openupgrade.rename_columns(env.cr, _column_renames)
        rename_sale_payment_config_parameters(env.cr, _config_param_renames)
        openupgrade.lift_constraints(env.cr, "sale_order", "payment_tx_id")
        openupgrade.lift_constraints(env.cr, "sale_order ", "payment_acquirer_id")
        openupgrade.lift_constraints(env.cr, "payment_transaction ", "sale_order_id")
    if openupgrade.column_exists(env.cr, 'sale_order', 'requested_date'):
        # from sale_order_dates module
        openupgrade.rename_fields(env, _field_renames_order_dates)
    if openupgrade.table_exists(env.cr, 'sale_quote_line'):
        # from website_quote module
        openupgrade.rename_columns(env.cr, _column_renames2)
    fill_sale_order_line_sections(env.cr)
    openupgrade.logged_query(
        env.cr,
        "ALTER TABLE sale_order_line ADD COLUMN qty_delivered_method varchar",
    )
    openupgrade.logged_query(
        env.cr,
        "ALTER TABLE sale_order_line ADD COLUMN untaxed_amount_invoiced "
        "NUMERIC")
    openupgrade.logged_query(
        env.cr,
        "ALTER TABLE sale_order_line ADD COLUMN untaxed_amount_to_invoice "
        "NUMERIC")
Example #14
0
def migrate(env, version):
    if not openupgrade.table_exists(env.cr, "account_move_queue_job_rel"):
        return
    openupgrade.logged_query(
        env.cr,
        """
        INSERT INTO account_move_validation_job_rel
        (invoice_id, job_id)
        SELECT rel.invoice_id, rel.job_id
        FROM account_move_queue_job_rel rel
        JOIN queue_job qj ON qj.id = rel.job_id
        WHERE qj.method_name = 'action_invoice_open_job'
        """,
    )
    openupgrade.logged_query(
        env.cr,
        """
        DELETE FROM account_move_queue_job_rel
        WHERE job_id IN (
            SELECT rel.job_id
            FROM account_move_queue_job_rel rel
            JOIN queue_job qj ON qj.id = rel.job_id
            WHERE qj.method_name = 'action_invoice_open_job'
        )
        """,
    )
Example #15
0
def fill_account_move_reverse_entry_id(env):
    AccountMove = env['account.move']
    if openupgrade.table_exists(env.cr, 'account_move_reverse'):
        reversal_moves = AccountMove.search([
            ('auto_reverse', '=', True),
            ('reverse_entry_id', '=', False),
        ])
        reversal_moves.write({'reverse_date': '2999-12-31'})
        env['ir.filters'].create({
            'name':
            'To be reversed (undetermined date)',
            'model_id':
            'account.move',
            'domain':
            "[('auto_reverse', '=', True),"
            "('reverse_entry_id', '=', False),"
            "('reverse_date', '=', '2999-12-31')]",
        })
    domain = [('reverse_entry_id', '=', False)]
    installed_langs = env['res.lang'].search([])  # search only active
    for lang in installed_langs:
        reversal_text = env['ir.translation']._get_source(
            name=False, types='code', lang=lang.code, source='reversal of: ')
        reversal_moves = AccountMove.search(domain + [('ref', '=like', '%s%%' %
                                                       reversal_text)])
        for move in reversal_moves:
            name = move.ref.partition(reversal_text)[2]
            origin = AccountMove.search([('name', '=', name)], limit=1)
            if origin and not origin[0].reverse_entry_id:
                origin[0].reverse_entry_id = move.id
Example #16
0
def map_tax_groups_to_taxes(cr, registry):
    if (openupgrade.column_exists(cr, 'account_tax', 'tax_code_id')
            and openupgrade.table_exists(cr, 'account_tax_code')):
        # we make an union to add tax without tax code but with base code
        openupgrade.logged_query(
            cr,
            """
            SELECT at.id as tax_id, application, afip_code, tax, type
            FROM account_tax at
            INNER JOIN account_tax_code as atc on at.tax_code_id = atc.id
            UNION
            SELECT at.id as tax_id, application, afip_code, tax, type
            FROM account_tax at
            INNER JOIN account_tax_code as atc on at.base_code_id = atc.id and
            at.tax_code_id is null
            """,
        )
        taxes_read = cr.fetchall()
        for tax_read in taxes_read:
            (tax_id, application, afip_code, tax, type) = tax_read
            domain = [
                ('application', '=', application),
                ('tax', '=', tax),
                ('type', '=', type),
            ]
            # because only vat and type tax should have afip_code
            if afip_code and tax == 'vat' and type == 'tax':
                domain += [('afip_code', '=', afip_code)]
            tax_group_ids = registry['account.tax.group'].search(cr, 1, domain)
            # we only assign tax group if we found one
            if len(tax_group_ids) == 1:
                registry['account.tax'].write(
                    cr, 1, tax_id, {'tax_group_id': tax_group_ids[0]})
Example #17
0
def migrate(env, version):
    if openupgrade.table_exists(env.cr,
                                "product_template_res_company_assignment_rel"):
        openupgrade.rename_tables(
            env.cr,
            [
                (
                    "product_template_res_company_assignment_rel",
                    "product_template_res_company_rel",
                ),
            ],
        )
        openupgrade.rename_columns(
            env.cr,
            {
                "product_template_res_company_rel": [
                    ("res_company_assignment_id", "res_company_id"),
                ],
            },
        )
    hooks.set_security_rule(env, "product.product_comp_rule")
    env.ref("stock.product_pulled_flow_comp_rule").write({
        "domain_force": ("['|', ('company_id', '=', False), ('company_id', "
                         "'in', company_ids)]"),
    })
    env.ref("stock.stock_location_route_comp_rule").write({
        "domain_force": ("['|', ('company_id', '=', False), ('company_id', "
                         "'in', company_ids)]"),
    })
Example #18
0
def migrate(cr, installed_version):
    openupgrade.load_data(cr, "l10n_it_intrastat_statement",
                          "migrations/13.0.1.0.0/noupdate_changes.xml")

    to_be_updated = (
        ("account_intrastat_statement_sale_section1", "invoice_id"),
        ("account_intrastat_statement_sale_section2", "invoice_id"),
        ("account_intrastat_statement_sale_section3", "invoice_id"),
        ("account_intrastat_statement_sale_section4", "invoice_id"),
        ("account_intrastat_statement_purchase_section1", "invoice_id"),
        ("account_intrastat_statement_purchase_section2", "invoice_id"),
        ("account_intrastat_statement_purchase_section3", "invoice_id"),
        ("account_intrastat_statement_purchase_section4", "invoice_id"),
    )

    if openupgrade.table_exists(cr, "account_invoice"):
        for table, column in to_be_updated:
            openupgrade.logged_query(
                cr,
                sql.SQL("""UPDATE {table} t
                SET {column} = ai.move_id
                FROM account_invoice ai
                WHERE t.{column} = ai.id and ai.move_id is NOT NULL""").format(
                    table=sql.Identifier(table),
                    column=sql.Identifier(column),
                ),
            )
Example #19
0
def fill_account_move_reverse_entry_id(env):
    all_moves = env['account.move'].search([])
    if openupgrade.table_exists(env.cr, 'account_move_reverse'):
        reversal_moves = all_moves.filtered(
            lambda m: m.auto_reverse and not m.reverse_entry_id)
        reversal_moves.write({'reverse_date': '2999-12-31'})
        env['ir.filters'].create({
            'name': 'To be reversed (undetermined date)',
            'model_id': 'account.move',
            'domain': [('auto_reverse', '=', True),
                       ('reverse_date', '=', '2999-12-31')],
        })
    else:
        installed_langs = env['res.lang'].search([])  # search only active
        for lang in installed_langs:
            reversal_text = env['ir.translation']._get_source(
                name=False, types='code', lang=lang.code,
                source='reversal of: ')
            reversal_moves = all_moves.filtered(
                lambda m: m.ref and m.ref.startswith(reversal_text))
            for move in reversal_moves:
                name = move.ref.partition(reversal_text)[2]
                origin = all_moves.filtered(lambda m: m.name == name)[0]
                if not origin.reverse_entry_id:
                    origin.reverse_entry_id = move.id
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(cr, 'res_partner_sector'):
        fill_res_partner_industry(cr)
        env['res.partner.industry']._parent_store_compute()
        update_res_partner_industry(cr)
        fill_res_partner_industry_secondary(cr)
def merge_stock_putaway_product(cr):
    if openupgrade.table_exists(cr, 'stock_product_putaway_strategy'):
        column_name = openupgrade.get_legacy_name('old_strat_id')
        openupgrade.logged_query(
            cr,
            sql.SQL(
                """INSERT INTO stock_fixed_putaway_strat (product_id, putaway_id,
                fixed_location_id, sequence,
                create_uid, create_date, write_uid, write_date, {})
            SELECT product_product_id, putaway_id, fixed_location_id, sequence,
                create_uid, create_date, write_uid, write_date, id
            FROM stock_product_putaway_strategy
            WHERE product_product_id IS NOT NULL""").format(
                    sql.Identifier(column_name)))
        # We put sequence + 1 for giving more priority by default to product
        # specific rules
        openupgrade.logged_query(
            cr,
            sql.SQL(
                """INSERT INTO stock_fixed_putaway_strat (product_id, putaway_id,
                fixed_location_id, sequence,
                create_uid, create_date, write_uid, write_date, {})
            SELECT pp.id, spps.putaway_id, spps.fixed_location_id,
                spps.sequence + 1, spps.create_uid, spps.create_date,
                spps.write_uid, spps.write_date, spps.id
            FROM stock_product_putaway_strategy spps
            JOIN product_template pt ON pt.id = spps.product_tmpl_id
            JOIN product_product pp ON pp.product_tmpl_id = pt.id""").format(
                    sql.Identifier(column_name)))
Example #22
0
def migrate(env, version):
    openupgrade.rename_fields(env, _field_renames)
    if openupgrade.table_exists(env.cr, "event_event_ticket"):
        openupgrade.rename_fields(env, _field_renames_event_sale)
    openupgrade.rename_xmlids(env.cr, _xmlid_renames_event_sale)
    rename_event_event_seats(env)
    fast_fill_kanban_state(env)
    avoid_default_in_event_event_stage_id(env)
Example #23
0
def migrate(env, version):
    if not openupgrade.table_exists(env.cr, 'account_followup_followup'):
        # This is not coming from account_followup migration
        return
    # Remove no update rules that no longer applies
    env.ref('account_credit_control.account_followup_comp_rule').unlink()
    env.ref('account_credit_control.account_followup_stat_by_partner_comp_rule'
            ).unlink()
Example #24
0
def migrate(env, version):
    """Thanks to no_version migration will be run on install as well."""
    cr = env.cr
    if not openupgrade.table_exists(cr, 'account_move_reconcile'):
        return  # This avoids errors when this module is installed on fresh DB
    assure_reconcile_ref_integrity(cr)
    migrate_reconcile(cr)
    invoice_recompute(env)
Example #25
0
def migrate(env, version):
    if not openupgrade.table_exists(env.cr, "document_quick_access_missing"):
        return
    integration_field_name = openupgrade.get_legacy_name(
        "document_quick_access_missing_id")
    if not openupgrade.column_exists(env.cr, "edi_exchange_record",
                                     integration_field_name):
        openupgrade.logged_query(
            env.cr,
            """
                    ALTER TABLE edi_exchange_record
                    ADD COLUMN %s numeric""" % integration_field_name,
        )
    backend = env.ref(
        "document_quick_access_folder_auto_classification.edi_backend")
    exchange_type = env.ref(
        "document_quick_access_folder_auto_classification.exchange_type")
    openupgrade.logged_query(
        env.cr,
        """
        INSERT INTO edi_exchange_record (
            identifier, type_id, backend_id, model, res_id, exchanged_on,
            edi_exchange_state,
            exchange_filename,
            create_date, create_uid, write_date, write_uid,
            {integration_field}
        )
        SELECT
            CONCAT('MIG_DOCUMENT_QUICK_ACCESS_FOLDER_', dqam.id),
            {exchange_type},
            {backend},
            dqam.model,
            dqam.res_id,
            dqam.create_date,
            case when dqam.state = 'pending' then 'input_processed_error'
                else 'input_processed'
            end,
            ia.name,
            dqam.create_date, dqam.create_uid, dqam.write_date, dqam.write_uid, dqam.id
        FROM document_quick_access_missing as dqam
            LEFT JOIN ir_attachment ia ON ia.id = dqam.attachment_id
        """.format(
            integration_field=integration_field_name,
            exchange_type=exchange_type.id,
            backend=backend.id,
        ),
    )
    openupgrade.logged_query(
        env.cr,
        """
        UPDATE ir_attachment at
        SET res_model = 'edi.exchange.record', res_id = eer.id,
            res_field = 'exchange_file'
        FROM document_quick_access_missing dqam
            INNER JOIN edi_exchange_record eer on eer.{integration_field} = dqam.id
        WHERE dqam.attachment_id = at.id
        """.format(integration_field=integration_field_name, ),
    )
Example #26
0
def migrate(env, version):
    cr = env.cr
    openupgrade.copy_columns(cr, _column_copies)
    openupgrade.rename_columns(cr, _column_renames)
    openupgrade.rename_fields(env, _field_renames)
    openupgrade.rename_xmlids(cr, xmlid_renames)
    if openupgrade.table_exists(cr, 'sale_order'):
        openupgrade.rename_fields(env, _field_renames_sale)
    if openupgrade.table_exists(cr, 'sale_layout_category'):
        fill_account_invoice_line_sections(cr)
    if openupgrade.table_exists(cr, 'account_move_reverse'):
        # module account_reversal
        openupgrade.rename_fields(env, _field_renames_account_reversal)
    if not openupgrade.column_exists(env.cr, 'res_company', 'incoterm_id'):
        openupgrade.logged_query(
            env.cr, """
            ALTER TABLE res_company ADD COLUMN incoterm_id INTEGER""",
        )
Example #27
0
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(
            cr,
            'account_account_history',
    ):
        _create_partner_history(cr)
    openupgrade.rename_models(cr, _model_renames)
    openupgrade.rename_tables(cr, _table_renames)
Example #28
0
def migrate(env, version):
    cr = env.cr
    if openupgrade.table_exists(env.cr, 'sale_quote_line'):
        openupgrade.rename_columns(cr, _column_renames)
        openupgrade.rename_fields(env, _field_renames)
        put_in_correct_module(cr, _white_list_fields)
        openupgrade.rename_models(cr, _model_renames)
        openupgrade.rename_tables(cr, _table_renames)
        fill_sale_order_template_line_sections(cr)
def migrate_account_analytic_distribution_pre(cr):
    """Prepare data for migrating OCA module."""
    # Check if the module was installed in previous version checking the
    # existence of one of its tables
    if openupgrade.table_exists(cr, 'account_analytic_distribution'):
        openupgrade.rename_tables(
            cr,
            [('account_analytic_distribution', None)],
        )
def rename_wizards(cr):
    if openupgrade.table_exists(cr, 'customer_activity_statement_wizard'):
        openupgrade.rename_tables(cr, [
            ('customer_activity_statement_wizard',
             'activity_statement_wizard'),
        ])
        openupgrade.rename_models(cr, [
            ('customer.activity.statement.wizard',
             'activity.statement.wizard'),
        ])
    if openupgrade.table_exists(cr, 'customer_outstanding_statement_wizard'):
        openupgrade.rename_tables(cr, [
            ('customer_outstanding_statement_wizard',
             'outstanding_statement_wizard'),
        ])
        openupgrade.rename_models(cr, [
            ('customer.outstanding.statement.wizard',
             'outstanding.statement.wizard'),
        ])