From c8ab0c7219f3ba96200dcca0a8cdcf24adfe74ff Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 12 May 2021 16:26:40 +0200 Subject: [PATCH 01/28] [13.0][OU-MIG] l10n_ch --- .../migrations/13.0.10.0/noupdate_changes.xml | 10 ------ .../migrations/13.0.11.0/noupdate_changes.xml | 2 +- .../openupgrade_analysis_work.txt} | 21 +++++++++--- .../migrations/13.0.11.0/post-migration.py | 33 +++++++++++++++++++ .../migrations/13.0.11.0/pre-migration.py | 10 ++++++ .../openupgrade/doc/source/modules120-130.rst | 2 +- 6 files changed, 62 insertions(+), 16 deletions(-) delete mode 100644 addons/l10n_ch/migrations/13.0.10.0/noupdate_changes.xml rename addons/l10n_ch/migrations/{13.0.10.0/openupgrade_analysis.txt => 13.0.11.0/openupgrade_analysis_work.txt} (90%) create mode 100644 addons/l10n_ch/migrations/13.0.11.0/post-migration.py create mode 100644 addons/l10n_ch/migrations/13.0.11.0/pre-migration.py 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/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index cb05f67f3e34..1cbc566555e4 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -251,7 +251,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ |l10n_ca | | +----------------------------------------------+-------------------------------------------------+ -|l10n_ch | | +|l10n_ch | Done | +----------------------------------------------+-------------------------------------------------+ |l10n_cl | | +----------------------------------------------+-------------------------------------------------+ From 4b8db610627fca6eed776d93caadb1217567e262 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 27 Apr 2023 18:24:54 +0200 Subject: [PATCH 02/28] [OU-FIX] purchase: set date_approve in all the confirmed orders If there's no double approval, all the previous orders will be ignored. TT42662 --- addons/purchase/migrations/13.0.1.2/post-migration.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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): From c08b82ae7769fb797f10e9687ab74a0885b45b21 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 23 May 2023 12:00:02 +0200 Subject: [PATCH 03/28] [ADD] rename l10n_nl_mis_reports to mis_template_financial_report --- odoo/addons/openupgrade_records/lib/apriori.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index f06074d3b64e..fd9cf3ad789f 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -30,6 +30,8 @@ 'sale_product_classification': 'product_abc_classification_sale', # OCA/stock-logistics-warehouse 'stock_putaway_product_form': 'stock_putaway_product_template', + # OCA/l10n-netherlands -> OCA/account-financial-reporting + 'l10n_nl_mis_reports': 'mis_template_financial_report', } merged_modules = { From 29cbcff1b80127ba5cc66a298725bfe8af47d848 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 23 May 2023 12:52:32 +0200 Subject: [PATCH 04/28] [FIX] pin CI ubuntu to ubuntu-22.04 --- .github/workflows/documentation.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index ac7d25693435..60b643d00f01 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" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c273a48b3610..32111d1294bd 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" From 06fec9fc2e0a9f0336b9092099ccfc6707895014 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 23 May 2023 15:26:19 +0200 Subject: [PATCH 05/28] [FIX] install vatnumber separately --- .github/workflows/documentation.yml | 2 ++ .github/workflows/test.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 60b643d00f01..78238bd66d60 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -31,6 +31,8 @@ jobs: 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/test.yml b/.github/workflows/test.yml index 32111d1294bd..32b607aa54b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 From 4dbc3b00e587f3d64cfd964a685f2bddd1b499ad Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 31 Aug 2023 10:03:37 +0200 Subject: [PATCH 06/28] [FIX] base: correctly parse utf8 html module descriptions Apparently `lxml.html.document_fromstring` (and possibly other `lxml.html` loaders) parses byte-strings as latin1 regardless of their actual encoding, maybe because python2, maybe because there's a super legacy html4 parser underlying it. Either way that means ever since loading `static/description/index.html` files was added 10 years ago (4bf6a7ea4c1703a02aa547db477ad7162ac1378c) `_get_desc` has been loading these files in latin1 rather than the utf8 most people would expect. Add an explicit decoding phase to try and load html description files in UTF8. Fall back to latin1 in case there are description files which are genuinely in latin1, or even just some random-ass broken stuff which very much isn't utf8 (the extended-ascii encodings -- of which latin1 is one -- will happily accept and mangle any input as every byte value is valid, utf8 is a lot more structured). Closes #127846 closes odoo/odoo#133708 Signed-off-by: Xavier Morel (xmo) --- odoo/addons/base/models/ir_module.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 285eb51b80a5..3952ac30ddf8 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -178,7 +178,11 @@ def _get_desc(self): if path: with tools.file_open(path, 'rb') as desc_file: doc = desc_file.read() - html = lxml.html.document_fromstring(doc) + try: + contents = doc.decode('utf-8') + except UnicodeDecodeError: + contents = doc + html = lxml.html.document_fromstring(contents) for element, attribute, link, pos in html.iterlinks(): if element.get('src') and not '//' in element.get('src') and not 'static/' in element.get('src'): element.set('src', "/%s/static/description/%s" % (module.name, element.get('src'))) From 51d375603d68ac65881fa5b0a096a8f3c1fa616d Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 1 Sep 2023 09:24:28 +0200 Subject: [PATCH 07/28] [FIX] base: encoding guessing of html module descriptions I missed a critical issue in #133708: various users had discovered they could already fix description issues by adding an XML declaration to their document which is very cool (though technically not really valid). What is a lot less cool is that lxml gets *extremely* unhappy when asked to parse *strings* with an encoding declaration, raising a ValueError, so the purported fix breaks on any module which does that, which seems to include a lot of OCA modules. Gate the encoding guessing by bailing if the document has an XML declaration, in which case we just assume the author knows what they're doing and we leave them alone. For extra safety, check the encoding declaration in ascii and utf16. Could also have checked for BOMs, but lxml seems to not care about them overly much (in fact it seems to prefer them decoded which is odd). closes odoo/odoo#133900 Reported-by: @rezak400 Signed-off-by: Xavier Morel (xmo) --- odoo/addons/base/models/ir_module.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 3952ac30ddf8..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 = ( + ' Date: Thu, 25 May 2023 17:09:26 +0200 Subject: [PATCH 08/28] [IMP] core: ease testing upgrade scripts in custom modules Upgrade (aka migration) scripts are a core part of Odoo, allowing database manipulations for modules during version changes. Any module, including custom ones can run upgrade scripts, even if the `--upgrade-path` flag (and with it, the `odoo.upgrade` sub-module) is not present. Currently only the "standard" modules benefit of easy upgrade script testing. Any custom modules that want to run tests of their upgrades have to import the tests in the usual `tests` folder, which is not ideal. Therefore, to allow TDD and programmatic testing of upgrade scripts in custom modules, the test discovery is here modified to also parse the module's `migrations` and `upgrades` sub-modules for tests. closes odoo/odoo#122569 Signed-off-by: Christophe Simonis (chs) --- odoo/modules/module.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/odoo/modules/module.py b/odoo/modules/module.py index 354f796f495e..4ab2cbf8f241 100644 --- a/odoo/modules/module.py +++ b/odoo/modules/module.py @@ -467,13 +467,7 @@ def get_test_modules(module): feed unittest.TestLoader.loadTestsFromModule() """ # Try to import the module results = _get_tests_modules('odoo.addons', module) - - try: - importlib.import_module('odoo.upgrade.%s' % module) - except ImportError: - pass - else: - results += list(_get_upgrade_test_modules(module)) + results += list(_get_upgrade_test_modules(module)) return results @@ -501,16 +495,26 @@ def _get_tests_modules(path, module): return result def _get_upgrade_test_modules(module): - upg = importlib.import_module("odoo.upgrade") - for path in map(Path, upg.__path__): - for test in (path / module / "tests").glob("test_*.py"): - spec = importlib.util.spec_from_file_location(f"odoo.upgrade.{module}.tests.{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__): + for test in path.glob("tests/test_*.py"): + spec = importlib.util.spec_from_file_location(f"{upg.__name__}.tests.{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): From 4f74a9338264dfc6da3c1a171c1501ff59a36652 Mon Sep 17 00:00:00 2001 From: mle Date: Thu, 23 Nov 2023 08:42:37 +0100 Subject: [PATCH 09/28] [OU-IMP] l10n_es: Handle fiscal positions renaming --- .../l10n_es/migrations/13.0.4.0/pre-migration.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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..1ef2caed9e64 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,18 @@ 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_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 +92,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) From f468503c88234adf026830fd653cec861aa17144 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 27 Nov 2023 09:15:21 +0100 Subject: [PATCH 10/28] [OU-FIX] account_check_printing: Proper SQL string The formatting should be done regularly, or the value that will be used will be literally `openupgrade_legacy_13_0_check_number`. TT46186 --- .../migrations/13.0.1.0/post-migration.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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') + ) ) From 8d44dea88cbb1aaa3cbf133058ce0eac34fb7967 Mon Sep 17 00:00:00 2001 From: Robin Keunen Date: Tue, 28 Nov 2023 16:32:06 +0100 Subject: [PATCH 11/28] [13.0][OU-ADD] stock_picking_responsible: merged into stock --- .../migrations/13.0.1.1/post-migration.py | 57 +++++++++++++++++++ .../addons/openupgrade_records/lib/apriori.py | 2 + 2 files changed, 59 insertions(+) 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..bc39a6bd5ef6 100644 --- a/addons/stock/migrations/13.0.1.1/post-migration.py +++ b/addons/stock/migrations/13.0.1.1/post-migration.py @@ -185,6 +185,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( + f""" + 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, + f""" + 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([]) @@ -411,6 +467,7 @@ def migrate(env, version): 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/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index fd9cf3ad789f..9e5b57c9207a 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -30,6 +30,8 @@ 'sale_product_classification': 'product_abc_classification_sale', # OCA/stock-logistics-warehouse 'stock_putaway_product_form': 'stock_putaway_product_template', + # OCA/stock-logistics-workflow + 'stock_picking_responsible': 'stock', # OCA/l10n-netherlands -> OCA/account-financial-reporting 'l10n_nl_mis_reports': 'mis_template_financial_report', } From ae58fbf438d9d0ae02bd92ff906bb6d4dae3b7c6 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 30 Nov 2023 11:46:09 +0100 Subject: [PATCH 12/28] [OU-FIX] stock_picking_responsible: Moved to merged_modules It was put on renamed_modules. --- odoo/addons/openupgrade_records/lib/apriori.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index 9e5b57c9207a..51859affe4b6 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -30,8 +30,6 @@ 'sale_product_classification': 'product_abc_classification_sale', # OCA/stock-logistics-warehouse 'stock_putaway_product_form': 'stock_putaway_product_template', - # OCA/stock-logistics-workflow - 'stock_picking_responsible': 'stock', # OCA/l10n-netherlands -> OCA/account-financial-reporting 'l10n_nl_mis_reports': 'mis_template_financial_report', } @@ -114,6 +112,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 From bb1942b61f3372a9047ac57ac061b87fe939dbc3 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Fri, 1 Dec 2023 22:03:32 +0100 Subject: [PATCH 13/28] [OU-IMP] l10n_es: Include REAGyP fiscal position mapping This one was introduced in 14.0 in Odoo core, but already present in l10n_es_extra_data in 12.0, so let's rename it here for having everything in the same place. --- addons/l10n_es/migrations/13.0.4.0/pre-migration.py | 1 + 1 file changed, 1 insertion(+) 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 1ef2caed9e64..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 @@ -63,6 +63,7 @@ def rename_food_taxes_and_fiscal_positions_xmlids(env): ("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"), From ba8f44e54aec5fcce9169b7d13bf4be53af340d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B4nio=20Neto?= Date: Sat, 9 Dec 2023 14:49:55 -0300 Subject: [PATCH 14/28] [IMP] apriori: merge account_reconciliation_widget_partial --- odoo/addons/openupgrade_records/lib/apriori.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index 51859affe4b6..cb84e964d7fb 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -67,6 +67,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 From df203082459ffb80f9c8382bdd315763fd3cf008 Mon Sep 17 00:00:00 2001 From: Kaynnan Lemes Date: Wed, 21 Feb 2024 16:03:16 -0300 Subject: [PATCH 15/28] [ADD] apriori: Change name of quality_control_team to quality_control_team_oca --- odoo/addons/openupgrade_records/lib/apriori.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index cb84e964d7fb..5827e8a4d7df 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -23,6 +23,7 @@ 'quality_control': 'quality_control_oca', 'quality_control_mrp': 'quality_control_mrp_oca', 'quality_control_stock': 'quality_control_stock_oca', + 'quality_control_team': 'quality_control_team_oca', # OCA/margin-analysis 'product_pricelist_margin': 'product_pricelist_simulation', # OCA/product-attribute From 019ab57509fea4e8436fa71ede6e845195bb4688 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 1 Mar 2024 16:53:38 +0100 Subject: [PATCH 16/28] [IMP] pos_journal_image V12 module renamed into 'pos_payment_method_image' in V13 --- odoo/addons/openupgrade_records/lib/apriori.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index 5827e8a4d7df..08f7cfdada04 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -26,6 +26,8 @@ 'quality_control_team': 'quality_control_team_oca', # OCA/margin-analysis 'product_pricelist_margin': 'product_pricelist_simulation', + # OCA/pos + 'pos_journal_image': 'pos_payment_method_image', # OCA/product-attribute 'product_pricelist_print_website_sale': 'product_pricelist_direct_print_website_sale', 'sale_product_classification': 'product_abc_classification_sale', From 94ceaac0ad6c592d354632ada4f54faab0c3ccf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 4 Apr 2024 18:15:29 +0200 Subject: [PATCH 17/28] [OU-IMP] base: vacuum of transient models --- odoo/addons/base/migrations/13.0.1.3/pre-migration.py | 1 + 1 file changed, 1 insertion(+) 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) From ef23c50a5c86a67466efa9b75b69ca4c5a66526a Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 8 Apr 2024 23:46:46 +0200 Subject: [PATCH 18/28] [FIX] account: don't set exclude_from_invoice_tab for type entry --- addons/account/migrations/13.0.1.1/post-migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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..38e1561e7ebc 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( From 72198f089c6e95c273fc083fc17eb1adf32cdbd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 28 May 2024 15:53:16 +0200 Subject: [PATCH 19/28] [OU-FIX] pos_sale: do not delete point_of_sale.pos_config_main In the analysis, the record point_of_sale.pos_config_main appears to be deleted. It's true that it is not overridden in the 13.0 version. But this record is not deleted, it still exists as it main definition is in the module point_of_sale. In 12.0 the field crm_team_id is added to point_of_sale.pos_config_main and in 13.0 this field rely only on the _get_default function defined in the pos.config model in pos_sale. There is no need to delete point_of_sale.pos_config_main, and there is no need to modify the crm_team_id value of this record. As this may have been modified by the users. --- .../migrations/13.0.1.0/openupgrade_analysis_work.txt | 6 +++++- addons/pos_sale/migrations/13.0.1.0/post-migration.py | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) 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) From 465294f306ea81d96471b62be19380f7cbad503e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Wed, 5 Jun 2024 14:44:00 +0200 Subject: [PATCH 20/28] [IMP] apriori: edi_oca -> edi --- odoo/addons/openupgrade_records/lib/apriori.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index 08f7cfdada04..507e3156501f 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -9,6 +9,8 @@ 'payment_ogone': 'payment_ingenico', # OCA/delivery-carrier 'delivery_carrier_label_ups': 'delivery_ups_oca', + # OCA/edi + 'edi_oca': 'edi', # OCA/event 'website_event_filter_selector': 'website_event_filter_city', # OCA/hr From 031564b76f4bc71742f85185afe23dada2e22901 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Sun, 28 Jul 2024 12:24:30 +0200 Subject: [PATCH 21/28] [FIX] website: also use company logo when website.logo is False --- addons/website/migrations/13.0.1.0/post-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..2cf796974043 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 From 20f618b06f3fdd277fa5096cfe4a93a76d9c6528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Mon, 30 Sep 2024 00:19:27 +0200 Subject: [PATCH 22/28] [OU-FIX] mrp: remove_tables_fks requires list --- addons/mrp/migrations/13.0.2.0/pre-migration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 1818ae139c873a0e8b2bc24c0d38a8aee836e4fa Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Thu, 3 Oct 2024 20:38:46 +0200 Subject: [PATCH 23/28] [IMP] account: assign tag tags of parent taxes to repartition lines --- .../migrations/13.0.1.1/post-migration.py | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) 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 38e1561e7ebc..3f2f2e4abb80 100644 --- a/addons/account/migrations/13.0.1.1/post-migration.py +++ b/addons/account/migrations/13.0.1.1/post-migration.py @@ -851,13 +851,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( @@ -944,14 +952,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') From 5c8d504cb9671a73b38c94fdc5704956b8d3a1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20-=20Le=20Filament?= <30716308+remi-filament@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:59:40 +0200 Subject: [PATCH 24/28] [OU-ADD] product_email_template --- .../migrations/13.0.1.0/post-migration.py | 21 +++++++++++++++++++ .../openupgrade/doc/source/modules120-130.rst | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 addons/product_email_template/migrations/13.0.1.0/post-migration.py 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/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index 6269cd9ced50..5d61257f5b16 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -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 | +----------------------------------------------+-------------------------------------------------+ From 9dae22571301c5037cede51d6052e69f18e98fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sun, 28 Jul 2024 16:16:03 +0200 Subject: [PATCH 25/28] [FIX] account: reversed_entry_id migration was reversed --- .../13.0.1.1/openupgrade_analysis_work.txt | 5 +++-- .../account/migrations/13.0.1.1/post-migration.py | 14 ++++++++++++-- .../account/migrations/13.0.1.1/pre-migration.py | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) 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 3f2f2e4abb80..33eb4c2eee35 100644 --- a/addons/account/migrations/13.0.1.1/post-migration.py +++ b/addons/account/migrations/13.0.1.1/post-migration.py @@ -581,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 + """ ) 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) From 6bdff4a37daa9f1a5ab4cd1697649bc1bdcc223a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Fri, 28 Feb 2025 12:40:21 +0100 Subject: [PATCH 26/28] [FIX] github workflows actions --- .github/workflows/documentation.yml | 4 ++-- .github/workflows/flake.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 78238bd66d60..f69cbb7ef77c 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -23,10 +23,10 @@ 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 diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index 8655919a6272..2c017bac99c2 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -13,10 +13,10 @@ 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 + - uses: actions/checkout@v4 - name: Configuration run: pip install flake8==3.4.1 - name: Flake8 Script diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 32b607aa54b1..8c8afabb3c1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 From 26ab36f14a9b764d579f82d3eb7ad0356fd31f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Fri, 28 Feb 2025 12:48:55 +0100 Subject: [PATCH 27/28] [FIX] python 3.7 is deprecated for flake, update flake version --- .github/workflows/flake.yml | 9 ++++++--- addons/stock/migrations/13.0.1.1/post-migration.py | 4 ++-- addons/website/migrations/13.0.1.0/post-migration.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml index 2c017bac99c2..44c67fc5b9b0 100644 --- a/.github/workflows/flake.yml +++ b/.github/workflows/flake.yml @@ -15,10 +15,10 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: 3.7 + 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/addons/stock/migrations/13.0.1.1/post-migration.py b/addons/stock/migrations/13.0.1.1/post-migration.py index bc39a6bd5ef6..5a9a769f1c44 100644 --- a/addons/stock/migrations/13.0.1.1/post-migration.py +++ b/addons/stock/migrations/13.0.1.1/post-migration.py @@ -195,7 +195,7 @@ def map_stock_picking_responsible_responsible_id_to_user_id(env): return env.cr.execute( - f""" + """ SELECT distinct rp.id, rp.name, rp.company_id, @@ -225,7 +225,7 @@ def map_stock_picking_responsible_responsible_id_to_user_id(env): # map responsible_id to user_id openupgrade.logged_query( env.cr, - f""" + """ WITH partner_user AS ( SELECT sp.id AS picking_id, rp.id AS partner_id, 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 2cf796974043..8d0928b604a0 100644 --- a/addons/website/migrations/13.0.1.0/post-migration.py +++ b/addons/website/migrations/13.0.1.0/post-migration.py @@ -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]), From 6fd9313849138551eeada2005a401c2f7b50e61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Thu, 26 Jun 2025 14:35:06 +0200 Subject: [PATCH 28/28] [OU-FIX] stock: convert responsible_id to company_dependent --- .../13.0.1.1/openupgrade_analysis_work.txt | 2 +- .../migrations/13.0.1.1/post-migration.py | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) 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 5a9a769f1c44..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( @@ -462,6 +523,7 @@ 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)