diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ac7d25693435..f69cbb7ef77c 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -10,7 +10,7 @@ on: jobs: documentation: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: DB: "openupgrade" DB_USERNAME: "odoo" @@ -23,14 +23,16 @@ jobs: PGUSER: "odoo" steps: - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Configuration run: | sudo apt update sudo apt install libldap2-dev nodejs libxml2-dev libxslt1-dev libevent-dev libsasl2-dev expect unixodbc-dev expect-dev python3-lxml python3-simplejson python3-serial python3-yaml python3-passlib python3-psycopg2 python3-werkzeug + pip install wheel + pip install --no-build-isolation vatnumber==1.2 pip install -r requirements.txt pip install sphinx - name: OpenUpgrade Docs diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index 8655919a6272..44c67fc5b9b0 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -13,12 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: 3.7 - - uses: actions/checkout@v2 + python-version: 3.8 + - uses: actions/checkout@v4 - name: Configuration - run: pip install flake8==3.4.1 + run: pip install flake8==4.0.1 - name: Flake8 Script run: | flake8 odoo/openupgrade --max-line-length=120 @@ -27,4 +27,7 @@ jobs: # only flake8 migration scripts from the openupgrade project, presumably # identifiable by using the openupgrade helpers flake8 --max-line-length=120 scripts $(find . \( -name 'pre-*.py' -or -name 'post-*.py' -or -name 'end-*.py' \) -exec grep -q openupgrade {} \; -print) - flake8 addons/*/migrations/*/tests/ --max-line-length=120 + if ls addons/*/migrations/*/tests/ > /dev/null 2>&1; then + flake8 addons/*/migrations/*/tests/ --max-line-length=120 --filename=__init__.py --ignore=F401 + flake8 addons/*/migrations/*/tests/ --max-line-length=120 --exclude=__init__.py + fi diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c273a48b3610..8c8afabb3c1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: DB: "openupgrade" DB_USERNAME: "odoo" @@ -23,7 +23,7 @@ jobs: PGUSER: "odoo" steps: - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.7 - name: Configure Postgres @@ -50,7 +50,7 @@ jobs: # Line below may fail quite often due to Travis bug: # - git reset -q --hard $TRAVIS_COMMIT # Install Python requirements of target release - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Configuration run: | sudo apt update @@ -58,6 +58,8 @@ jobs: - name: Requirements Installation run: | sudo npm install -g less less-plugin-clean-css + pip install wheel + pip install --no-build-isolation vatnumber==1.2 pip install -q -r requirements.txt # don't use pypi's openupgradelib, but the one from source to avoid choking # on unreleased features in openupgradelib diff --git a/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt b/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt index dab7a73ecc71..2cab0a60e09b 100644 --- a/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt +++ b/addons/account/migrations/13.0.1.1/openupgrade_analysis_work.txt @@ -331,8 +331,9 @@ account / account.move / matched_percentage (float) : DEL account / account.move / reverse_entry_id (many2one) : DEL relation: account.move account / account.move / reversed_entry_id (many2one) : NEW relation: account.move account / account.invoice / refund_invoice_id (many2one) : DEL relation: account.invoice -# DONE: pre-migration: renamed fields -# DONE: post-migration: used refund_invoice_id to fill reversed_entry_id in case is empty +# DONE: pre-migration: lift FK constraint in reverse_entry_id +# DONE: post-migration: used refund_invoice_id to fill reverse_entry_id in case is empty (for invoices transformed to moves) +# DONE: post-migration: used reverse_entry_id to fill reversed_entry_id in case is empty account / account.move / tax_type_domain (char) : DEL # NOTHING TO DO: renamed to invoice_filter_type_domain, but still is non stored diff --git a/addons/account/migrations/13.0.1.1/post-migration.py b/addons/account/migrations/13.0.1.1/post-migration.py index 17cff2137863..33eb4c2eee35 100644 --- a/addons/account/migrations/13.0.1.1/post-migration.py +++ b/addons/account/migrations/13.0.1.1/post-migration.py @@ -296,7 +296,11 @@ def migration_invoice_moves(env): env.cr, """ UPDATE account_move_line SET exclude_from_invoice_tab = TRUE - WHERE old_invoice_line_id IS NULL""", + FROM account_move + WHERE old_invoice_line_id IS NULL + AND account_move_line.move_id=account_move.id + AND account_move.type <> 'entry' + """, ) # 4th. Adding all the missing lines openupgrade.logged_query( @@ -577,14 +581,24 @@ def migration_voucher_moves(env): def fill_account_move_reversed_entry_id(env): + # copy refund_invoice_id to reverse_entry_id openupgrade.logged_query( env.cr, """ UPDATE account_move am - SET reversed_entry_id = am2.id + SET reverse_entry_id = am2.id FROM account_invoice ai JOIN account_invoice ai2 ON ai.refund_invoice_id = ai2.id JOIN account_move am2 ON am2.old_invoice_id = ai2.id - WHERE am.reversed_entry_id IS NULL AND am.old_invoice_id = ai.id""" + WHERE am.reverse_entry_id IS NULL AND am.old_invoice_id = ai.id""" + ) + # copy reverse_entry_id to reversed_entry_id (the relation is reversed in 13.0) + openupgrade.logged_query( + env.cr, """ + UPDATE account_move am + SET reversed_entry_id = am2.id + FROM account_move am2 + WHERE am.reversed_entry_id IS NULL AND am2.reverse_entry_id = am.id + """ ) @@ -847,13 +861,21 @@ def create_account_tax_repartition_lines(env): def move_tags_from_taxes_to_repartition_lines(env): openupgrade.logged_query( env.cr, """ + WITH RECURSIVE tax2parent(tax_id, parent_id) AS ( + SELECT id, id FROM account_tax + UNION ALL + SELECT rel.child_tax, rel.parent_tax + FROM account_tax_filiation_rel rel + JOIN tax2parent ON tax2parent.parent_id=rel.child_tax + ) INSERT INTO account_account_tag_account_tax_repartition_line_rel ( account_tax_repartition_line_id, account_account_tag_id) SELECT atrl.id, atat.account_account_tag_id FROM account_tax_account_tag atat + JOIN tax2parent ON atat.account_tax_id=tax2parent.parent_id JOIN account_tax_repartition_line atrl ON - (atat.account_tax_id = atrl.invoice_tax_id OR - atat.account_tax_id = atrl.refund_tax_id) + (tax2parent.tax_id = atrl.invoice_tax_id OR + tax2parent.tax_id = atrl.refund_tax_id) ON CONFLICT DO NOTHING""" ) openupgrade.logged_query( @@ -940,14 +962,22 @@ def assign_account_tags_to_move_lines(env): # move lines with taxes openupgrade.logged_query( env.cr, """ + WITH RECURSIVE tax2child(tax_id, child_id) AS ( + SELECT id, id FROM account_tax + UNION ALL + SELECT rel.parent_tax, rel.child_tax + FROM account_tax_filiation_rel rel + JOIN tax2child ON tax2child.child_id=rel.parent_tax + ) INSERT INTO account_account_tag_account_move_line_rel ( account_move_line_id, account_account_tag_id) SELECT aml.id, aat_atr_rel.account_account_tag_id FROM account_move_line aml JOIN account_move am ON aml.move_id = am.id JOIN account_move_line_account_tax_rel amlatr ON amlatr.account_move_line_id = aml.id + JOIN tax2child ON amlatr.account_tax_id=tax2child.child_id JOIN account_tax_repartition_line atrl ON ( - atrl.invoice_tax_id = amlatr.account_tax_id AND atrl.repartition_type = 'base') + atrl.invoice_tax_id = tax2child.tax_id AND atrl.repartition_type = 'base') JOIN account_account_tag_account_tax_repartition_line_rel aat_atr_rel ON aat_atr_rel.account_tax_repartition_line_id = atrl.id WHERE aml.old_invoice_line_id IS NOT NULL AND am.type in ('out_invoice', 'in_invoice') diff --git a/addons/account/migrations/13.0.1.1/pre-migration.py b/addons/account/migrations/13.0.1.1/pre-migration.py index e57abf7cdd66..33ac7e9afa59 100644 --- a/addons/account/migrations/13.0.1.1/pre-migration.py +++ b/addons/account/migrations/13.0.1.1/pre-migration.py @@ -34,7 +34,6 @@ _field_renames = [ ('account.move', 'account_move', 'amount', 'amount_total'), - ('account.move', 'account_move', 'reverse_entry_id', 'reversed_entry_id'), ] _field_sale_renames = [ @@ -340,6 +339,7 @@ def migrate(env, version): fill_account_move_line(env) create_res_partner_ranks(env) delete_fk_constraints(env) + openupgrade.lift_constraints(env.cr, "account_move", "reverse_entry_id") fill_account_move_commercial_partner_id(env) set_account_move_currency_id_required(env) add_helper_invoice_move_rel(env) diff --git a/addons/account_check_printing/migrations/13.0.1.0/post-migration.py b/addons/account_check_printing/migrations/13.0.1.0/post-migration.py index b90e6aa7ba04..aa5494abf061 100644 --- a/addons/account_check_printing/migrations/13.0.1.0/post-migration.py +++ b/addons/account_check_printing/migrations/13.0.1.0/post-migration.py @@ -8,10 +8,12 @@ def map_account_payment_check_number(env): openupgrade.logged_query( env.cr, """ UPDATE account_payment - SET check_number = '' || %s + SET check_number = %s::VARCHAR WHERE %s IS NOT NULL - """, (openupgrade.get_legacy_name('check_number'), - openupgrade.get_legacy_name('check_number')) + """ % ( + openupgrade.get_legacy_name('check_number'), + openupgrade.get_legacy_name('check_number') + ) ) diff --git a/addons/l10n_ch/migrations/13.0.10.0/noupdate_changes.xml b/addons/l10n_ch/migrations/13.0.10.0/noupdate_changes.xml deleted file mode 100644 index 8f5ee930052c..000000000000 --- a/addons/l10n_ch/migrations/13.0.10.0/noupdate_changes.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - Plan comptable 2015 (Suisse) - - - diff --git a/addons/l10n_ch/migrations/13.0.11.0/noupdate_changes.xml b/addons/l10n_ch/migrations/13.0.11.0/noupdate_changes.xml index d02760aa67f1..30ef448020f4 100644 --- a/addons/l10n_ch/migrations/13.0.11.0/noupdate_changes.xml +++ b/addons/l10n_ch/migrations/13.0.11.0/noupdate_changes.xml @@ -5,6 +5,6 @@ - 1 + diff --git a/addons/l10n_ch/migrations/13.0.10.0/openupgrade_analysis.txt b/addons/l10n_ch/migrations/13.0.11.0/openupgrade_analysis_work.txt similarity index 90% rename from addons/l10n_ch/migrations/13.0.10.0/openupgrade_analysis.txt rename to addons/l10n_ch/migrations/13.0.11.0/openupgrade_analysis_work.txt index 7aec03d6efad..31245fefdb38 100644 --- a/addons/l10n_ch/migrations/13.0.10.0/openupgrade_analysis.txt +++ b/addons/l10n_ch/migrations/13.0.11.0/openupgrade_analysis_work.txt @@ -1,14 +1,20 @@ ---Models in module 'l10n_ch'--- ---Fields in module 'l10n_ch'--- l10n_ch / account.invoice / l10n_ch_isr_number (char) : DEL -l10n_ch / account.invoice / l10n_ch_isr_sent (boolean) : DEL -l10n_ch / account.journal / invoice_reference_model (False): NEW selection_keys: ['ch', 'euro', 'odoo'], mode: modify l10n_ch / account.move / l10n_ch_isr_number (char) : NEW isfunction: function, stored +l10n_ch / account.invoice / l10n_ch_isr_sent (boolean) : DEL l10n_ch / account.move / l10n_ch_isr_sent (boolean) : NEW hasdefault +# DONE: post-migration: moved fields from invoice to move + +l10n_ch / account.journal / invoice_reference_model (False): NEW selection_keys: ['ch', 'euro', 'odoo'], mode: modify +# NOTHING TO DO: new feature + l10n_ch / res.bank / l10n_ch_postal_chf (char) : DEL l10n_ch / res.bank / l10n_ch_postal_eur (char) : DEL l10n_ch / res.partner.bank / l10n_ch_isr_subscription_chf (char): NEW l10n_ch / res.partner.bank / l10n_ch_isr_subscription_eur (char): NEW +# DONE: post-migration: moved fields from bank to partner bank + ---XML records in module 'l10n_ch'--- DEL account.account.tag: l10n_ch.vat_tag_200 DEL account.account.tag: l10n_ch.vat_tag_220 @@ -34,6 +40,13 @@ DEL account.account.tag: l10n_ch.vat_tag_415 DEL account.account.tag: l10n_ch.vat_tag_420 DEL account.account.tag: l10n_ch.vat_tag_dedouanement NEW account.account.template: l10n_ch.ch_coa_1101 +# NOTHING TO DO + +account.chart.template: l10n_ch.l10nch_chart_template (noupdate switched) +# DONE: pre-migration: switched noupdate + +NEW account.fiscal.position.template: l10n_ch.fiscal_position_template_1 (noupdate) +NEW account.tax.group: l10n_ch.tax_group_tva_100 NEW account.tax.report.line: l10n_ch.account_tax_report_line_calc_impot NEW account.tax.report.line: l10n_ch.account_tax_report_line_calc_impot_base NEW account.tax.report.line: l10n_ch.account_tax_report_line_calc_impot_chiffre @@ -70,11 +83,11 @@ NEW account.tax.report.line: l10n_ch.account_tax_report_line_chtax_900 NEW account.tax.report.line: l10n_ch.account_tax_report_line_chtax_910 NEW account.tax.report.line: l10n_ch.account_tax_report_line_chtax_autres_mouv NEW account.tax.report.line: l10n_ch.account_tax_report_line_chtax_solde +NEW account.tax.template: l10n_ch.vat_100_import_invest NEW account.tax.template: l10n_ch.vat_other_movements_900 NEW account.tax.template: l10n_ch.vat_other_movements_910 -NEW ir.actions.act_window: account.action_move_out_invoice_type -DEL ir.actions.act_window: account.action_invoice_tree1 NEW ir.ui.view: l10n_ch.isr_partner_bank_tree NEW ir.ui.view: l10n_ch.isr_partner_property_bank_tree NEW ir.ui.view: l10n_ch.setup_bank_account_wizard_inherit DEL ir.ui.view: l10n_ch.isr_res_bank_form +# NOTHING TO DO diff --git a/addons/l10n_ch/migrations/13.0.11.0/post-migration.py b/addons/l10n_ch/migrations/13.0.11.0/post-migration.py new file mode 100644 index 000000000000..bf26f4bb7031 --- /dev/null +++ b/addons/l10n_ch/migrations/13.0.11.0/post-migration.py @@ -0,0 +1,33 @@ +# Copyright 2021 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def move_from_invoices_to_moves(env): + openupgrade.logged_query( + env.cr, """ + UPDATE account_move am + SET l10n_ch_isr_number = ai.l10n_ch_isr_number, + l10n_ch_isr_sent = ai.l10n_ch_isr_sent + FROM account_invoice ai + WHERE am.old_invoice_id = ai.id""", + ) + + +def move_from_bank_to_partner_bank(env): + openupgrade.logged_query( + env.cr, """ + UPDATE res_partner_bank rpb + SET l10n_ch_isr_subscription_chf = rb.l10n_ch_postal_chf, + l10n_ch_isr_subscription_eur = rb.l10n_ch_postal_eur + FROM res_bank rb + WHERE rpb.bank_id = rb.id""", + ) + + +@openupgrade.migrate() +def migrate(env, version): + move_from_invoices_to_moves(env) + move_from_bank_to_partner_bank(env) + openupgrade.load_data( + env.cr, "l10n_ch", "migrations/13.0.11.0/noupdate_changes.xml") diff --git a/addons/l10n_ch/migrations/13.0.11.0/pre-migration.py b/addons/l10n_ch/migrations/13.0.11.0/pre-migration.py new file mode 100644 index 000000000000..b8f2225cfc38 --- /dev/null +++ b/addons/l10n_ch/migrations/13.0.11.0/pre-migration.py @@ -0,0 +1,10 @@ +# Copyright 2021 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.set_xml_ids_noupdate_value( + env, "l10n_ch", ["l10nch_chart_template"], False, + ) diff --git a/addons/l10n_es/migrations/13.0.4.0/pre-migration.py b/addons/l10n_es/migrations/13.0.4.0/pre-migration.py index 81fb33bd1f43..bd2d24f8f302 100644 --- a/addons/l10n_es/migrations/13.0.4.0/pre-migration.py +++ b/addons/l10n_es/migrations/13.0.4.0/pre-migration.py @@ -47,7 +47,7 @@ def set_account_move_number_to_invoice_number(env): ) -def rename_food_taxes_xmlids(env): +def rename_food_taxes_and_fiscal_positions_xmlids(env): renames = [ ("account_tax_template_p_iva0_a", "account_tax_template_p_iva0_s_bc"), ("account_tax_template_p_iva5_a", "account_tax_template_p_iva5_bc"), @@ -59,6 +59,19 @@ def rename_food_taxes_xmlids(env): ("account_tax_template_s_iva0_a", "account_tax_template_s_iva0b"), ("account_tax_template_s_iva5_a", "account_tax_template_s_iva5b"), ("account_tax_template_s_req0625", "account_tax_template_s_req062"), + ("fptt_extra_0a", "fptt_extra_0b"), + ("fptt_extra_5a", "fptt_extra_5b"), + ("fptt_intra_0a", "fptt_intra_0b"), + ("fptt_intra_5a", "fptt_intra_5b"), + ("fptt_reagyp_a_0a_2", "fptt_reagyp_a_4b_4"), + ("fptt_recargo_0a", "fptt_recargo_0b"), + ("fptt_recargo_0a_2", "fptt_recargo_0b_2"), + ("fptt_recargo_5a", "fptt_recargo_5b"), + ("fptt_recargo_5a_2", "fptt_recargo_5b_2"), + ("fptt_recargo_buy_0a", "fptt_recargo_buy_0b"), + ("fptt_recargo_buy_0a_2", "fptt_recargo_buy_0b_2"), + ("fptt_recargo_buy_5a", "fptt_recargo_buy_5b"), + ("fptt_recargo_buy_5a_2", "fptt_recargo_buy_5b_2"), ] companies = env["res.company"].with_context(active_test=False).search([]) for old, new in renames: @@ -80,4 +93,4 @@ def migrate(env, version): if openupgrade.column_exists( env.cr, "account_invoice", "invoice_number"): set_account_move_number_to_invoice_number(env) - rename_food_taxes_xmlids(env) + rename_food_taxes_and_fiscal_positions_xmlids(env) diff --git a/addons/mrp/migrations/13.0.2.0/pre-migration.py b/addons/mrp/migrations/13.0.2.0/pre-migration.py index 7abb9f5c998e..ac622d5f5def 100644 --- a/addons/mrp/migrations/13.0.2.0/pre-migration.py +++ b/addons/mrp/migrations/13.0.2.0/pre-migration.py @@ -88,7 +88,7 @@ def mapped_reservation_state(env): @openupgrade.migrate() def migrate(env, version): - openupgrade.remove_tables_fks(env.cr, 'mrp_bom_line_product_attribute_value_rel') + openupgrade.remove_tables_fks(env.cr, ['mrp_bom_line_product_attribute_value_rel']) openupgrade.rename_models(env.cr, _model_renames) if openupgrade.table_exists(env.cr, 'mrp_subproduct'): openupgrade.rename_tables(env.cr, _mrp_subproduct_table_renames) diff --git a/addons/pos_sale/migrations/13.0.1.0/openupgrade_analysis_work.txt b/addons/pos_sale/migrations/13.0.1.0/openupgrade_analysis_work.txt index a50092e2564f..0bd29820eebd 100644 --- a/addons/pos_sale/migrations/13.0.1.0/openupgrade_analysis_work.txt +++ b/addons/pos_sale/migrations/13.0.1.0/openupgrade_analysis_work.txt @@ -21,4 +21,8 @@ DEL crm.team: pos_sale.pos_sales_team [renamed to sales_team module] (noupdate) # NOTHING TO DO: renamed xmlids in sales_team DEL pos.config: point_of_sale.pos_config_main (noupdate) -# DONE: post-migration: Try to delete record +# NOTHING TO DO: point_of_sale.pos_config_main still exists in module + point_of_sale. Now the module pos_sale does not add a value for + crm_team_id in the xml file, it only rely on the default value + defined with a function in the model pos.config. The value set in + previous version should no be modified. diff --git a/addons/pos_sale/migrations/13.0.1.0/post-migration.py b/addons/pos_sale/migrations/13.0.1.0/post-migration.py index 23f10057b4a9..7c1ad46597ce 100644 --- a/addons/pos_sale/migrations/13.0.1.0/post-migration.py +++ b/addons/pos_sale/migrations/13.0.1.0/post-migration.py @@ -26,9 +26,4 @@ def _map_crm_team_id(env): def migrate(env, version): openupgrade.load_data( env.cr, "pos_sale", "migrations/13.0.1.0/noupdate_changes.xml") - openupgrade.delete_records_safely_by_xml_id( - env, [ - "point_of_sale.pos_config_main", - ] - ) _map_crm_team_id(env) diff --git a/addons/product_email_template/migrations/13.0.1.0/post-migration.py b/addons/product_email_template/migrations/13.0.1.0/post-migration.py new file mode 100644 index 000000000000..57a3ec9dab51 --- /dev/null +++ b/addons/product_email_template/migrations/13.0.1.0/post-migration.py @@ -0,0 +1,21 @@ +# Copyright 2024 Le Filament +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def update_product_template_mail_model(env): + """ + Mail template model has changed from product.template to account.move in v13 + """ + account_move_model = env["ir.model"].search([("model", "=", "account.move")]) + mail_template_ids = env["product.template"].search( + [("email_template_id", "!=", False)] + ).mapped("email_template_id") + mail_template_ids.filtered(lambda t: t.model == 'product.template').write( + {"model_id": account_move_model.id} + ) + + +@openupgrade.migrate() +def migrate(env, version): + update_product_template_mail_model(env) diff --git a/addons/purchase/migrations/13.0.1.2/post-migration.py b/addons/purchase/migrations/13.0.1.2/post-migration.py index 0fe50e0f8ffb..e591ed26d77f 100644 --- a/addons/purchase/migrations/13.0.1.2/post-migration.py +++ b/addons/purchase/migrations/13.0.1.2/post-migration.py @@ -15,16 +15,16 @@ def move_fields_from_invoice_to_moves(env): def change_type_purchase_order_date_approve(env): - openupgrade.logged_query( - env.cr, """ + query = """ UPDATE purchase_order po SET date_approve = mm.date FROM mail_message mm WHERE mm.subtype_id = %s AND mm.model = 'purchase.order' - AND mm.res_id = po.id""", - (env.ref('purchase.mt_rfq_approved').id, ), - ) + AND mm.res_id = po.id + AND date_approve IS NULL""" + openupgrade.logged_query(env.cr, query, (env.ref('purchase.mt_rfq_approved').id,)) + openupgrade.logged_query(env.cr, query, (env.ref('purchase.mt_rfq_confirmed').id,)) def fill_account_move_purchase_order_rel_table(env): diff --git a/addons/stock/migrations/13.0.1.1/openupgrade_analysis_work.txt b/addons/stock/migrations/13.0.1.1/openupgrade_analysis_work.txt index c27d28b2c6c2..7fe53d48686b 100644 --- a/addons/stock/migrations/13.0.1.1/openupgrade_analysis_work.txt +++ b/addons/stock/migrations/13.0.1.1/openupgrade_analysis_work.txt @@ -19,7 +19,7 @@ stock / product.putaway / name (char) : DEL re # NOTHING TO DO: model removed stock / product.template / responsible_id (many2one) : not stored anymore -# NOTHING TO DO: non stored +# DONE: post-migration: convert to company_dependent (filling ir_property) stock / res.company / stock_mail_confirmation_template_id (many2one): NEW relation: mail.template, hasdefault stock / res.company / stock_move_email_validation (boolean): NEW hasdefault diff --git a/addons/stock/migrations/13.0.1.1/post-migration.py b/addons/stock/migrations/13.0.1.1/post-migration.py index 12d0f60f8833..fe135131d60b 100644 --- a/addons/stock/migrations/13.0.1.1/post-migration.py +++ b/addons/stock/migrations/13.0.1.1/post-migration.py @@ -11,6 +11,67 @@ def _get_main_company(cr): return cr.fetchone() +def product_template_responsible_id_to_company_dependent(env): + """Usually for such cases, openupgrade.convert_to_company_dependent() should + normally be used, but that function does not seem to support converting + a field to company-dependent without changing its name at the same time. + moreover, it stores boolean values even when they are false (what odoo + does not), and it creates values for all companies, which does not make + sense when a record is linked to a particular company only. + """ + responsible_id_field_id = (env.ref("stock.field_product_template__responsible_id").id,) + # this many2one property stores its value in the value_reference column + openupgrade.logged_query( + env.cr, + """ + insert into ir_property ( + company_id, fields_id, value_reference, name, res_id, type + ) + select + company_id, + %(field_id)s, + 'res.users,' || responsible_id, + 'responsible_id', + 'product.template,' || id, + 'many2one' + from product_template + where + company_id is not null + and responsible_id is not null + order by id + """, + {"field_id": responsible_id_field_id}, + ) + # for product.template records that are not linked to a company, create an + # ir.property record for each company. + openupgrade.logged_query( + env.cr, + """ + insert into ir_property ( + company_id, + fields_id, + value_reference, + name, + res_id, + type + ) + select + rc.id, + %(field_id)s, + 'res.users,' || pt.responsible_id, + 'responsible_id', + 'product.template,' || pt.id, + 'many2one' + from product_template as pt + inner join res_company as rc on + pt.company_id is null and + pt.responsible_id is not null + order by pt.id, rc.id + """, + {"field_id": responsible_id_field_id}, + ) + + def fill_company_id(cr): # stock.move.line openupgrade.logged_query( @@ -185,6 +246,62 @@ def map_stock_location_usage(env): ) +def map_stock_picking_responsible_responsible_id_to_user_id(env): + """ + responsible_id (partner_id) field in stock_picking_responsible is replaced by user_id (res.users) + We create a deactivated user for partners without user and then + map the partner to their user in the stock picking. + """ + if not openupgrade.column_exists(env.cr, "stock_picking", "responsible_id"): + return + + env.cr.execute( + """ + SELECT distinct rp.id, + rp.name, + rp.company_id, + rp.email + FROM stock_picking sp + JOIN res_partner rp ON rp.id = sp.responsible_id + LEFT JOIN res_users ru ON rp.id = ru.partner_id + WHERE ru.id IS NULL + """ + ) + partners_wo_user = env.cr.fetchall() + + user_vals_list = [] + for partner_id, name, company_id, email in partners_wo_user: + login = email if email else name + login = openupgrade.get_legacy_name(login).replace(" ", "_") + user_vals_list.append({ + "login": login, + "partner_id": partner_id, + "company_id": company_id, + "active": False, + }) + + if user_vals_list: + env["res.users"].create(user_vals_list) + + # map responsible_id to user_id + openupgrade.logged_query( + env.cr, + """ + WITH partner_user AS ( + SELECT sp.id AS picking_id, + rp.id AS partner_id, + ru.id AS user_id + FROM stock_picking sp + JOIN res_partner rp ON rp.id = sp.responsible_id + LEFT join res_users ru ON rp.id = ru.partner_id) + UPDATE stock_picking + SET user_id = partner_user.user_id + FROM partner_user + WHERE stock_picking.id = partner_user.picking_id; + """ + ) + + def fill_stock_picking_type_sequence_code(env): """Deduce sequence code from current sequence pattern """ picking_types = env["stock.picking.type"].with_context(active_text=False).search([]) @@ -406,11 +523,13 @@ def update_sml_index(env): @openupgrade.migrate() def migrate(env, version): main_company = _get_main_company(env.cr) + product_template_responsible_id_to_company_dependent(env) fill_company_id(env.cr) fill_stock_putaway_rule_location_in_id(env) fill_propagate_date_minimum_delta(env) fill_stock_inventory_start_empty(env) map_stock_location_usage(env) + map_stock_picking_responsible_responsible_id_to_user_id(env) fill_stock_picking_type_sequence_code(env) handle_stock_scrap_sequence(env, main_company) map_stock_locations(env, main_company) diff --git a/addons/website/migrations/13.0.1.0/post-migration.py b/addons/website/migrations/13.0.1.0/post-migration.py index 323c62a03c33..8d0928b604a0 100644 --- a/addons/website/migrations/13.0.1.0/post-migration.py +++ b/addons/website/migrations/13.0.1.0/post-migration.py @@ -16,7 +16,7 @@ def _fill_website_logo(env): """ default_logo = env["website"]._default_logo() for website in env["website"].search([]): - if website.logo == default_logo: + if not website.logo or website.logo == default_logo: website.logo = website.company_id.logo @@ -48,7 +48,7 @@ def _set_data_anchor_xml_attribute(env): ) for view in website_views: doc = fromstring(view.arch_db) - links = doc.cssselect("a[href^=\#]:not([href=\#])") + links = doc.cssselect(r"a[href^=\#]:not([href=\#])") if links: replacement = { "selector": ", ".join([link.attrib["href"] for link in links]), diff --git a/odoo/addons/base/migrations/13.0.1.3/pre-migration.py b/odoo/addons/base/migrations/13.0.1.3/pre-migration.py index b7aa4c743ba0..fdca6b25788b 100644 --- a/odoo/addons/base/migrations/13.0.1.3/pre-migration.py +++ b/odoo/addons/base/migrations/13.0.1.3/pre-migration.py @@ -799,6 +799,7 @@ def migrate(env, version): env.cr, apriori.renamed_modules.items()) openupgrade.update_module_names( env.cr, apriori.merged_modules.items(), merge_modules=True) + openupgrade.clean_transient_models(env.cr) openupgrade.copy_columns(env.cr, column_copies) openupgrade.rename_columns(env.cr, column_renames) openupgrade.rename_fields(env, field_renames, no_deep=True) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 285eb51b80a5..ac9a3056b8ac 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -148,6 +148,12 @@ def get_transforms(self): ('to install', 'To be installed'), ] +XML_DECLARATION = ( + ' OCA/account-financial-reporting + 'l10n_nl_mis_reports': 'mis_template_financial_report', } merged_modules = { @@ -65,6 +72,7 @@ # OCA/account-reconcile 'account_set_reconcilable': 'account', 'bank_statement_foreign_currency': 'account', + 'account_reconciliation_widget_partial': 'account', # OCA/e-commerce 'website_sale_category_description': 'website_sale', # OCA/event @@ -110,6 +118,8 @@ 'stock_picking_report_custom_description': 'stock', # OCA/stock-logistics-warehouse 'sale_stock_info_popup': 'sale_stock', + # OCA/stock-logistics-workflow + 'stock_picking_responsible': 'stock', # OCA/timesheet 'sale_timesheet_existing_project': 'sale_timesheet', # OCA/web diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 4e9514d431c6..03f0214448f9 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -467,13 +467,7 @@ def get_test_modules(module, openupgrade_prefix=None): feed unittest.TestLoader.loadTestsFromModule() """ # Try to import the module results = _get_tests_modules('odoo.addons', module, openupgrade_prefix) - - try: - importlib.import_module('odoo.upgrade.%s' % module) - except ImportError: - pass - else: - results += list(_get_upgrade_test_modules(module, openupgrade_prefix)) + results += list(_get_upgrade_test_modules(module, openupgrade_prefix)) return results @@ -509,20 +503,29 @@ def _get_upgrade_test_modules(module, openupgrade_prefix=None): if openupgrade_prefix is None: openupgrade_prefix = '' name = openupgrade_prefix + '.tests' - upg = importlib.import_module("odoo.upgrade") - for path in map(Path, upg.__path__): - if openupgrade_prefix: - tests = (path / module / openupgrade_prefix[1:] / "tests").glob("test_*.py") - else: - tests = (path / module / "tests").glob("test_*.py") - for test in tests: - spec = importlib.util.spec_from_file_location(f"odoo.upgrade.{module}{name}.{test.stem}", test) - if not spec: - continue - pymod = importlib.util.module_from_spec(spec) - sys.modules[spec.name] = pymod - spec.loader.exec_module(pymod) - yield pymod + upgrade_modules = ( + f"odoo.upgrade.{module}", + f"odoo.addons.{module}.migrations", + f"odoo.addons.{module}.upgrades", + ) + for module_name in upgrade_modules: + try: + upg = importlib.import_module(module_name) + except ImportError: + continue + for path in map(Path, upg.__path__): + if openupgrade_prefix: + tests = path.glob(openupgrade_prefix[1:] + "/tests/test_*.py") + else: + tests = path.glob("tests/test_*.py") + for test in tests: + spec = importlib.util.spec_from_file_location(f"{upg.__name__}{name}.{test.stem}", test) + if not spec: + continue + pymod = importlib.util.module_from_spec(spec) + sys.modules[spec.name] = pymod + spec.loader.exec_module(pymod) + yield pymod class OdooTestResult(unittest.result.TestResult): diff --git a/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index 534eb2ff5456..5d61257f5b16 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -257,7 +257,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ |l10n_ca | | +----------------------------------------------+-------------------------------------------------+ -|l10n_ch | | +|l10n_ch | Done | +----------------------------------------------+-------------------------------------------------+ |l10n_cl | | +----------------------------------------------+-------------------------------------------------+ @@ -533,7 +533,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ |product | Done | +----------------------------------------------+-------------------------------------------------+ -|product_email_template | | +|product_email_template | Done | +----------------------------------------------+-------------------------------------------------+ |product_expiry | Nothing to do | +----------------------------------------------+-------------------------------------------------+