def migrate(env, version): cr = env.cr openupgrade.copy_columns(cr, column_copies) openupgrade.float_to_integer(cr, 'procurement_rule', 'route_sequence') openupgrade.float_to_integer(cr, 'stock_location_path', 'route_sequence') openupgrade.rename_xmlids(env.cr, xmlid_renames) warning_update_module_names_partial(cr)
def migrate(cr, version): # delete_views(cr) openupgrade.copy_columns(cr, column_copies) logged_query( cr, """ UPDATE infrastructure_database set contract_id = Null """)
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")
def migrate(env, version): cr = env.cr openupgrade.rename_columns(cr, column_renames) openupgrade.rename_fields(env, field_renames) openupgrade.copy_columns(cr, column_copies) openupgrade.rename_tables(cr, table_renames) map_order_state(cr)
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)
def migrate(env, version): openupgrade.copy_columns(env.cr, COLUMN_COPIES) openupgrade.rename_xmlids(env.cr, _xmlid_renames) openupgrade.rename_xmlids(env.cr, _portal_xmlid_renames) openupgrade.rename_xmlids(env.cr, _portal_sale_xmlid_renames) xml_ids_to_remove = [ 'sale_payment.orders_followup', 'sale.portal_personal_contact', ] for xml_id in xml_ids_to_remove: try: with env.cr.savepoint(): env.ref(xml_id).unlink() except Exception: pass openupgrade.update_module_moved_fields( env.cr, 'sale.order', ['procurement_group_id'], 'sale', 'sale_stock', ) openupgrade.add_fields(env, [ ('amt_invoiced', 'sale.order.line', 'sale_order_line', 'monetary', False, 'sale'), ('amt_to_invoice', 'sale.order.line', 'sale_order_line', 'monetary', False, 'sale'), ])
def handle_account_asset_disposal_migration(env): """Take care of potentially installed `account_asset_disposal` module. In this phase we rename stuff for adapting to the new data structure. """ cr = env.cr if not openupgrade.column_exists(cr, 'account_asset', 'disposal_move_id'): return openupgrade.copy_columns(cr, {'account_asset': [('state', None, None)]}) openupgrade.rename_columns(cr, {'account_asset': [('disposal_move_id', None)]}) openupgrade.map_values( cr, openupgrade.get_legacy_name('state'), 'state', [('disposed', 'removed')], table='account_asset', ) openupgrade.rename_fields( env, [ ('account.asset', 'account_asset', 'disposal_date', 'date_remove'), ('account.asset.profile', 'account_asset_profile', 'account_loss_id', 'account_residual_value_id'), ], )
def migrate(env, version): migrate_sale_layout(env) openupgrade.copy_columns(env.cr, column_copies) cleanup_modules(env.cr) warning_update_module_names_partial(env.cr) sale_expense_update_module_names_partial(env.cr) migrate_account_invoice_shipping_address(env.cr)
def migrate(env, version): copy_global_rules(env) delete_quants_for_consumable(env) openupgrade.update_module_moved_fields( env.cr, 'stock.move', ['has_tracking'], 'mrp', 'stock', ) openupgrade.update_module_moved_fields( env.cr, 'stock.move', ['quantity_done'], 'mrp', 'stock', ) openupgrade.rename_fields(env, [ ('stock.quant', 'stock_quant', 'qty', 'quantity'), ]) openupgrade.copy_columns( env.cr, { 'stock_picking': [ ('state', None, None), ], }, ) openupgrade.map_values( env.cr, openupgrade.get_legacy_name('state'), 'state', [('partially_available', 'assigned')], table='stock_picking', )
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 """)
def migrate(env, version): openupgrade.copy_columns(env.cr, COLUMN_COPIES) try: with env.cr.savepoint(): env.ref('sale_timesheet.duplicate_field_xmlid').unlink() except Exception: pass
def migrate(env, version): cr = env.cr openupgrade.rename_models(cr, models_to_rename) openupgrade.rename_tables(cr, tables_to_rename) openupgrade.rename_xmlids(cr, xmlids_to_rename) openupgrade.copy_columns(cr, columns_to_copy) create_contract_records(cr)
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)
def migrate(cr, version): openupgrade.copy_columns(cr, column_copies) openupgrade.rename_tables(cr, table_renames) openupgrade.rename_columns(cr, column_renames) openupgrade.rename_xmlids(cr, xmlid_renames) # Removing transient tables to get rid of warnings openupgrade.drop_columns(cr, column_drops)
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, )
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'""")
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)
def migrate(cr, version): # 9.0 introduces a constraint enforcing this cr.execute("update account_account set reconcile=True " "where type in ('receivable', 'payable')") openupgrade.rename_tables(cr, table_renames) openupgrade.rename_columns(cr, column_renames) openupgrade.copy_columns(cr, column_copies) migrate_properties(cr)
def migrate(env, version): fill_project_project_inherits_values(env) openupgrade.copy_columns(env.cr, column_copies) compute_project_task_rating_last_value(env) openupgrade.set_xml_ids_noupdate_value( env, 'project', ['ir_cron_rating_project', 'rating_project_request_email_template'], True)
def migrate(env, version): openupgrade.copy_columns(env.cr, _column_copies) openupgrade.rename_models(env.cr, _model_renames) openupgrade.rename_tables(env.cr, _table_renames) openupgrade.rename_fields(env, _field_renames) openupgrade.rename_columns(env.cr, _column_renames) openupgrade.rename_xmlids(env.cr, _xmlid_renames) assure_stock_rule_company_is_correct(env)
def migrate(env, version): openupgrade.copy_columns(env.cr, _column_copies) openupgrade.map_values( env.cr, openupgrade.get_legacy_name('type'), 'type', [('datetime', 'date')], table='survey_question', )
def migrate(env, version): openupgrade.copy_columns(env.cr, _column_copies) openupgrade.map_values( env.cr, openupgrade.get_legacy_name('measure_type'), 'measure_type', [('time', 'working_time')], table='uom_category', )
def migrate(env, version): cr = env.cr openupgrade.copy_columns(cr, column_copies) openupgrade.rename_fields(env, field_renames) # This should be run before table renames openupgrade.rename_columns(env.cr, column_renames) openupgrade.rename_tables(env.cr, table_renames) map_order_state(cr) purchase_invoice_lines(cr)
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) if openupgrade.column_exists(env.cr, 'sale_order', 'requested_date'): # from sale_order_dates module openupgrade.rename_fields(env, _field_renames_order_dates) fill_sale_order_line_sections(env.cr)
def migrate(env, version): openupgrade.copy_columns(env.cr, _column_copies) openupgrade.rename_models(env.cr, _model_renames) openupgrade.rename_tables(env.cr, _table_renames) openupgrade.rename_fields(env, _field_renames) openupgrade.rename_columns(env.cr, _column_renames) openupgrade.rename_xmlids(env.cr, _xmlid_renames) assure_stock_rule_company_is_correct(env) fill_inventory_line_categ(env) prefill_stock_picking_type_sequence_code(env)
def copy_date_end_date_start_columns(env): openupgrade.copy_columns( env.cr, { "product_pricelist_item": [ ("date_end", None, None), ("date_start", None, None), ] }, )
def migrate(cr, version): openupgrade.copy_columns(cr, column_copies) openupgrade.rename_tables(cr, table_renames) openupgrade.rename_columns(cr, column_renames) openupgrade.rename_xmlids(cr, xmlid_renames) cr.execute( '''update ir_module_module set state='to install' where name='project_timesheet' and state in ('uninstalled', 'to remove') and exists (select id from ir_module_module where name='hr_timesheet' and state in ('to upgrade', 'to_install', 'installed'))''')
def migrate(env, version): cr = env.cr # copy columns good practice in pre-mig script format of colum_spec should # be: { Table_name_in_db : [( old_column_name , new_column_name, type)] # defaults of new columname are fetchable via method get_legacy_name openupgrade.copy_columns( cr, { 'account_analytic_account': [ ('account_type', None, None), ], })
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, )
def migrate(cr, version): # 9.0 introduces a constraint enforcing this cr.execute("update account_account set reconcile=True " "where type in ('receivable', 'payable')") openupgrade.rename_tables(cr, table_renames) openupgrade.rename_columns(cr, column_renames) openupgrade.copy_columns(cr, column_copies) migrate_properties(cr) install_account_tax_python(cr) map_account_tax_type(cr) map_account_tax_template_type(cr) remove_account_moves_from_special_periods(cr)
def migrate(env, version): openupgrade.copy_columns(env.cr, column_copies) # account_tax_cash_basis was merged with account, so there is no module # entry anymore to check if it was installed. Check one of its columns # instead. if openupgrade.column_exists(env.cr, 'account_tax', 'use_cash_basis'): openupgrade.rename_columns(env.cr, {'account_tax': [('use_cash_basis', None)]}) openupgrade.delete_record_translations(env.cr, 'account', [ 'mail_template_data_notification_email_account_invoice', 'email_template_edi_invoice' ])