From 24fa1995f150f01eedefc1c9854b3279d5f9906f Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 18 Nov 2024 17:58:22 +0100 Subject: [PATCH] [OU-IMP] more review followups --- .../scripts/account/17.0.1.2/end-migration.py | 13 -- .../account/17.0.1.2/post-migration.py | 125 ++++++++++++ .../scripts/account/17.0.1.2/pre-migration.py | 182 +++--------------- .../17.0.1.2/upgrade_analysis_work.txt | 26 +-- .../account/tests/data_account_migration.py | 19 ++ .../account/tests/test_account_migration.py | 34 ++++ 6 files changed, 212 insertions(+), 187 deletions(-) delete mode 100644 openupgrade_scripts/scripts/account/17.0.1.2/end-migration.py create mode 100644 openupgrade_scripts/scripts/account/tests/data_account_migration.py create mode 100644 openupgrade_scripts/scripts/account/tests/test_account_migration.py diff --git a/openupgrade_scripts/scripts/account/17.0.1.2/end-migration.py b/openupgrade_scripts/scripts/account/17.0.1.2/end-migration.py deleted file mode 100644 index 6bf5e52c90d0..000000000000 --- a/openupgrade_scripts/scripts/account/17.0.1.2/end-migration.py +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from openupgradelib import openupgrade - - -def _res_partner_bank_computation(env): - partner_banks = env["res.partner.bank"].with_context(active_test=False).search([]) - partner_banks._compute_display_account_warning() - - -@openupgrade.migrate() -def migrate(env, version): - _res_partner_bank_computation(env) diff --git a/openupgrade_scripts/scripts/account/17.0.1.2/post-migration.py b/openupgrade_scripts/scripts/account/17.0.1.2/post-migration.py index 5e18569ff92b..a9586265d79b 100644 --- a/openupgrade_scripts/scripts/account/17.0.1.2/post-migration.py +++ b/openupgrade_scripts/scripts/account/17.0.1.2/post-migration.py @@ -12,6 +12,100 @@ ] +COA_MAPPING = { + "l10n_ae.uae_chart_template_standard": "ae", + "l10n_ar.l10nar_base_chart_template": "ar_base", + "l10n_ar.l10nar_ex_chart_template": "ar_ex", + "l10n_ar.l10nar_ri_chart_template": "ar_ri", + "l10n_at.l10n_at_chart_template": "at", + "l10n_au.l10n_au_chart_template": "au", + "l10n_be.l10nbe_chart_template": "be_comp", + "l10n_bg.l10n_bg_chart_template": "bg", + "l10n_bo.bo_chart_template": "bo", + "l10n_br.l10n_br_account_chart_template": "br", + "l10n_ca.ca_en_chart_template_en": "ca_2023", + "l10n_ch.l10nch_chart_template": "ch", + "l10n_cl.cl_chart_template": "cl", + "l10n_cn.l10n_chart_china_small_business": "cn", + "l10n_co.l10n_co_chart_template_generic": "co", + "l10n_cr.account_chart_template_0": "cr", + "l10n_cz.cz_chart_template": "cz", + "l10n_de.l10n_de_chart_template": "de_skr03", + "l10n_de.l10n_chart_de_skr04": "de_skr04", + "l10n_de_skr03.l10n_de_chart_template": "de_skr03", + "l10n_de_skr04.l10n_chart_de_skr04": "de_skr04", + "l10n_dk.dk_chart_template": "dk", + "l10n_do.do_chart_template": "do", + "l10n_dz.l10n_dz_pcg_chart_template": "dz", + "l10n_ec.l10n_ec_ifrs": "ec", + "l10n_ee.l10nee_chart_template": "ee", + "l10n_eg.egypt_chart_template_standard": "eg", + "l10n_es.account_chart_template_assoc": "es_assec", + "l10n_es.account_chart_template_common": "es_common", + "l10n_es.account_chart_template_full": "es_full", + "l10n_es.account_chart_template_pymes": "es_pymes", + "l10n_et.l10n_et": "et", + "l10n_fi.fi_chart_template": "fi", + "l10n_fr.l10n_fr_pcg_chart_template": "fr", + "l10n_generic_coa.configurable_chart_template": "generic_coa", + "l10n_gr.l10n_gr_chart_template": "gr", + "l10n_gt.cuentas_plantilla": "gt", + "l10n_hk.l10n_hk_chart_template": "hk", + "l10n_hn.cuentas_plantilla": "hn", + "l10n_hr.l10n_hr_chart_template_rrif": "hr", + "l10n_hr.l10n_hr_euro_chart_template": "hr", + "l10n_hr_kuna.l10n_hr_kuna_chart_template_rrif": "hr_kuna", + "l10n_hu.hungarian_chart_template": "hu", + "l10n_id.l10n_id_chart": "id", + "l10n_ie.l10n_ie": "ie", + "l10n_il.il_chart_template": "il", + "l10n_in.indian_chart_template_standard": "in", + "l10n_it.l10n_it_chart_template_generic": "it", + "l10n_jp.l10n_jp1": "jp", + "l10n_jp.l10n_jp_chart_template": "jp", + "l10n_ke.l10nke_chart_template": "ke", + "l10n_kz.l10nkz_chart_template": "kz", + "l10n_lt.account_chart_template_lithuania": "lt", + "l10n_lu.lu_2011_chart_1": "lu", + "l10n_lv.chart_template_latvia": "lv", + "l10n_ma.l10n_ma_chart_template": "ma", + "l10n_mn.mn_chart_1": "mn", + "l10n_mx.mx_coa": "mx", + "l10n_my.l10n_my_chart_template": "my", + "l10n_mz.l10n_mz_chart_template": "mz", + "l10n_nl.l10nnl_chart_template": "nl", + "l10n_no.no_chart_template": "no", + "l10n_nz.l10n_nz_chart_template": "nz", + "l10n_pa.l10npa_chart_template": "pa", + "l10n_pe.pe_chart_template": "pe", + "l10n_ph.l10n_ph_chart_template": "ph", + "l10n_pk.l10n_pk_chart_template": "pk", + "l10n_pl.pl_chart_template": "pl", + "l10n_pt.pt_chart_template": "pt", + "l10n_ro.ro_chart_template": "ro", + "l10n_rs.l10n_rs_chart_template": "rs", + "l10n_sa.sa_chart_template_standard": "sa", + "l10n_se.l10nse_chart_template": "se", + "l10n_se.l10nse_chart_template_K2": "se_K2", + "l10n_se.l10nse_chart_template_K3": "se_K3", + "l10n_sg.sg_chart_template": "sg", + "l10n_si.gd_chart": "si", + "l10n_sk.sk_chart_template": "sk", + "l10n_syscohada.syscohada_chart_template": "syscohada", + "l10n_th.chart": "th", + "l10n_tr.chart_template_common": "tr", + "l10n_tr.l10n_tr_chart_template": "tr", + "l10n_tw.l10n_tw_chart_template": "tw", + "l10n_ua.l10n_ua_ias_chart_template": "ua_ias", + "l10n_ua.l10n_ua_psbo_chart_template": "ua_psbo", + "l10n_uk.l10n_uk": "uk", + "l10n_uy.uy_chart_template": "uy", + "l10n_ve.ve_chart_template_amd": "ve", + "l10n_vn.vn_template": "vn", + "l10n_za.default_chart_template": "za", +} + + def _am_update_invoice_pdf_report_file(env): openupgrade.logged_query( env.cr, @@ -395,6 +489,35 @@ def _force_install_account_payment_term_module_module(env): ) +def _map_chart_template_id_to_chart_template( + env, model_table, coa_m2o="chart_template_id", coa_name_column="chart_template" +): + """ + In tables that used to refer to a chart template in the database, set the new + column identitying the COA by the name of its localization module with the + `l10n_` prefix removed (usually the country's iso code) + """ + env.cr.execute( + f"""SELECT m.id, CONCAT(imd.module, '.', imd.name) + FROM {model_table} m + JOIN ir_model_data imd + ON imd.model='account.chart.template' + AND m.{coa_m2o} = imd.res_id + WHERE m.{coa_m2o} IS NOT NULL + AND CONCAT(imd.module, '.', imd.name) IN %s + """, + (tuple(COA_MAPPING),), + ) + chart_id2name = [(_id, COA_MAPPING[xmlid]) for _id, xmlid in env.cr.fetchall()] + openupgrade.map_values( + env.cr, + coa_m2o, + coa_name_column, + chart_id2name, + table=model_table, + ) + + @openupgrade.migrate() def migrate(env, version): _account_payment_term_migration(env) @@ -408,3 +531,5 @@ def migrate(env, version): _am_update_invoice_pdf_report_file(env) _onboarding_state_migration(env) _account_tax_group_migration(env) + _map_chart_template_id_to_chart_template(env, "res_company") + _map_chart_template_id_to_chart_template(env, "account_report") diff --git a/openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py index 4142edbef0a7..1da54c872d1a 100644 --- a/openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py +++ b/openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py @@ -13,99 +13,6 @@ ), ] -COA_MAPPING = { - "l10n_ae.uae_chart_template_standard": "ae", - "l10n_ar.l10nar_base_chart_template": "ar_base", - "l10n_ar.l10nar_ex_chart_template": "ar_ex", - "l10n_ar.l10nar_ri_chart_template": "ar_ri", - "l10n_at.l10n_at_chart_template": "at", - "l10n_au.l10n_au_chart_template": "au", - "l10n_be.l10nbe_chart_template": "be_comp", - "l10n_bg.l10n_bg_chart_template": "bg", - "l10n_bo.bo_chart_template": "bo", - "l10n_br.l10n_br_account_chart_template": "br", - "l10n_ca.ca_en_chart_template_en": "ca_2023", - "l10n_ch.l10nch_chart_template": "ch", - "l10n_cl.cl_chart_template": "cl", - "l10n_cn.l10n_chart_china_small_business": "cn", - "l10n_co.l10n_co_chart_template_generic": "co", - "l10n_cr.account_chart_template_0": "cr", - "l10n_cz.cz_chart_template": "cz", - "l10n_de.l10n_de_chart_template": "de_skr03", - "l10n_de.l10n_chart_de_skr04": "de_skr04", - "l10n_de_skr03.l10n_de_chart_template": "de_skr03", - "l10n_de_skr04.l10n_chart_de_skr04": "de_skr04", - "l10n_dk.dk_chart_template": "dk", - "l10n_do.do_chart_template": "do", - "l10n_dz.l10n_dz_pcg_chart_template": "dz", - "l10n_ec.l10n_ec_ifrs": "ec", - "l10n_ee.l10nee_chart_template": "ee", - "l10n_eg.egypt_chart_template_standard": "eg", - "l10n_es.account_chart_template_assoc": "es_assec", - "l10n_es.account_chart_template_common": "es_common", - "l10n_es.account_chart_template_full": "es_full", - "l10n_es.account_chart_template_pymes": "es_pymes", - "l10n_et.l10n_et": "et", - "l10n_fi.fi_chart_template": "fi", - "l10n_fr.l10n_fr_pcg_chart_template": "fr", - "l10n_generic_coa.configurable_chart_template": "generic_coa", - "l10n_gr.l10n_gr_chart_template": "gr", - "l10n_gt.cuentas_plantilla": "gt", - "l10n_hk.l10n_hk_chart_template": "hk", - "l10n_hn.cuentas_plantilla": "hn", - "l10n_hr.l10n_hr_chart_template_rrif": "hr", - "l10n_hr.l10n_hr_euro_chart_template": "hr", - "l10n_hr_kuna.l10n_hr_kuna_chart_template_rrif": "hr_kuna", - "l10n_hu.hungarian_chart_template": "hu", - "l10n_id.l10n_id_chart": "id", - "l10n_ie.l10n_ie": "ie", - "l10n_il.il_chart_template": "il", - "l10n_in.indian_chart_template_standard": "in", - "l10n_it.l10n_it_chart_template_generic": "it", - "l10n_jp.l10n_jp1": "jp", - "l10n_jp.l10n_jp_chart_template": "jp", - "l10n_ke.l10nke_chart_template": "ke", - "l10n_kz.l10nkz_chart_template": "kz", - "l10n_lt.account_chart_template_lithuania": "lt", - "l10n_lu.lu_2011_chart_1": "lu", - "l10n_lv.chart_template_latvia": "lv", - "l10n_ma.l10n_ma_chart_template": "ma", - "l10n_mn.mn_chart_1": "mn", - "l10n_mx.mx_coa": "mx", - "l10n_my.l10n_my_chart_template": "my", - "l10n_mz.l10n_mz_chart_template": "mz", - "l10n_nl.l10nnl_chart_template": "nl", - "l10n_no.no_chart_template": "no", - "l10n_nz.l10n_nz_chart_template": "nz", - "l10n_pa.l10npa_chart_template": "pa", - "l10n_pe.pe_chart_template": "pe", - "l10n_ph.l10n_ph_chart_template": "ph", - "l10n_pk.l10n_pk_chart_template": "pk", - "l10n_pl.pl_chart_template": "pl", - "l10n_pt.pt_chart_template": "pt", - "l10n_ro.ro_chart_template": "ro", - "l10n_rs.l10n_rs_chart_template": "rs", - "l10n_sa.sa_chart_template_standard": "sa", - "l10n_se.l10nse_chart_template": "se", - "l10n_se.l10nse_chart_template_K2": "se_K2", - "l10n_se.l10nse_chart_template_K3": "se_K3", - "l10n_sg.sg_chart_template": "sg", - "l10n_si.gd_chart": "si", - "l10n_sk.sk_chart_template": "sk", - "l10n_syscohada.syscohada_chart_template": "syscohada", - "l10n_th.chart": "th", - "l10n_tr.chart_template_common": "tr", - "l10n_tr.l10n_tr_chart_template": "tr", - "l10n_tw.l10n_tw_chart_template": "tw", - "l10n_ua.l10n_ua_ias_chart_template": "ua_ias", - "l10n_ua.l10n_ua_psbo_chart_template": "ua_psbo", - "l10n_uk.l10n_uk": "uk", - "l10n_uy.uy_chart_template": "uy", - "l10n_ve.ve_chart_template_amd": "ve", - "l10n_vn.vn_template": "vn", - "l10n_za.default_chart_template": "za", -} - _l10n_generic_coa_tax_group_xmlid = [ "l10n_generic_coa.tax_group_15", ] @@ -139,52 +46,28 @@ def _map_account_report_filter_account_type(env): ) -def _map_chart_template_id_to_chart_template( - env, model, coa_m2o="chart_template_id", coa_str="chart_template" -): - openupgrade.logged_query( - env.cr, - f""" - ALTER TABLE {model} - ADD COLUMN {coa_str} character varying; - """, - ) - env.cr.execute( - f"""SELECT m.id AS m_id, CONCAT(imd.module, '.', imd.name) AS coa_xml_id - FROM {model} m - JOIN ir_model_data imd - ON imd.model='account.chart.template' - AND m.{coa_m2o} = imd.res_id - WHERE m.{coa_m2o} IS NOT NULL - """ - ) - for line in env.cr.dictfetchall(): - if line["coa_xml_id"] in COA_MAPPING: - openupgrade.logged_query( - env.cr, - f""" - UPDATE {model} - SET {coa_str} = '{COA_MAPPING[line['coa_xml_id']]}' - WHERE id = {line['m_id']} - """, - ) - - def _generic_coa_rename_xml_id(env): """ Since the removal of account.chart.template we need to rename some xml_id like tax or tax.group in order to avoid duplication """ + _dummy, template_id = env["ir.model.data"]._xmlid_to_res_model_res_id( + "l10n_generic_coa.configurable_chart_template", + ) + if not template_id: + return env.cr.execute( - """SELECT id, name FROM res_company WHERE chart_template = 'generic_coa'""" + f""" + SELECT id FROM res_company + WHERE chart_template_id={template_id} + """ ) xmlids_renames = [] - for company_id, _ in env.cr.fetchall(): - if company_id == env.company.id: - for tax_group_xmlid in _l10n_generic_coa_tax_group_xmlid: - new_xmlid = f"account.{company_id}_" + tax_group_xmlid.split(".")[1] - xmlids_renames.append((tax_group_xmlid, new_xmlid)) + for (company_id,) in env.cr.fetchall(): + for tax_group_xmlid in _l10n_generic_coa_tax_group_xmlid: + new_xmlid = f"account.{company_id}_" + tax_group_xmlid.split(".")[1] + xmlids_renames.append((tax_group_xmlid, new_xmlid)) for tax_xmlid in _l10n_generic_coa_tax_xmlid: old_xmlid = f"l10n_generic_coa.{company_id}_" + tax_xmlid.split(".")[1] new_xmlid = f"account.{company_id}_" + tax_xmlid.split(".")[1] @@ -193,14 +76,11 @@ def _generic_coa_rename_xml_id(env): def _convert_account_tax_description(env): - openupgrade.rename_columns(env.cr, {"account_tax": [("description", None)]}) - openupgrade.logged_query(env.cr, "ALTER TABLE account_tax ADD description JSONB") - openupgrade.logged_query( - env.cr, - f"""UPDATE account_tax - SET description = {'en_US': {openupgrade.get_legacy_name('description')}} - """, + openupgrade.copy_columns(env.cr, {"account_tax": [("description", None, None)]}) + openupgrade.rename_columns( + env.cr, {"account_tax": [("description", "invoice_label")]} ) + convert_column_translatable(env.cr, "account_tax", "invoice_label", "jsonb") def _am_create_delivery_date_column(env): @@ -261,7 +141,7 @@ def _account_report_update_figure_type(env): env.cr, old_column, "figure_type", - {"none": "string"}, + [("none", "string")], False, "account_report_column", ) @@ -269,7 +149,7 @@ def _account_report_update_figure_type(env): env.cr, old_column, "figure_type", - {"none": "string"}, + [("none", "string")], False, "account_report_expression", ) @@ -300,31 +180,25 @@ def _account_tax_repartition_line_merge_repartition_lines_m2o(env): ) -def _res_partner_bank_create_column(env): - openupgrade.logged_query( - env.cr, - """ - ALTER TABLE res_partner_bank - ADD COLUMN IF NOT EXISTS has_iban_warning BOOLEAN, - ADD COLUMN IF NOT EXISTS has_money_transfer_warning BOOLEAN; - """, - ) - - def _pre_create_early_pay_discount_computation(env): """Avoid triggering the computed method and fill the corresponding value from companies. """ openupgrade.logged_query( - env.cr, "ALTER TABLE res_company ADD early_pay_discount_computation VARCHAR" + env.cr, + """ + ALTER TABLE account_payment_term + ADD COLUMN IF NOT EXISTS early_pay_discount_computation VARCHAR + """, ) openupgrade.logged_query( env.cr, """ UPDATE account_payment_term apt - SET early_pay_discount_computation = com.early_pay_discount_computation + SET early_pay_discount_computation = rc.early_pay_discount_computation FROM res_company rc WHERE apt.company_id = rc.id + AND apt.early_pay_discount_computation IS NULL """, ) @@ -332,8 +206,6 @@ def _pre_create_early_pay_discount_computation(env): @openupgrade.migrate() def migrate(env, version): _map_account_report_filter_account_type(env) - _map_chart_template_id_to_chart_template(env, "res_company") - _map_chart_template_id_to_chart_template(env, "account_report") _generic_coa_rename_xml_id(env) # Drop triagram index on name column of account.account # to avoid error when loading registry, it will be recreated @@ -344,12 +216,10 @@ def migrate(env, version): """, ) openupgrade.rename_fields(env, _fields_renames) - convert_column_translatable(env.cr, "account_tax", "description", "jsonb") _convert_account_tax_description(env) _am_create_delivery_date_column(env) _am_create_incoterm_location_column(env) _am_uniquify_name(env) _account_report_update_figure_type(env) _account_tax_repartition_line_merge_repartition_lines_m2o(env) - _res_partner_bank_create_column(env) _pre_create_early_pay_discount_computation(env) diff --git a/openupgrade_scripts/scripts/account/17.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/account/17.0.1.2/upgrade_analysis_work.txt index a7ebff7df77d..5b0d88e56fb7 100644 --- a/openupgrade_scripts/scripts/account/17.0.1.2/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/account/17.0.1.2/upgrade_analysis_work.txt @@ -140,6 +140,9 @@ account / account.move / delivery_date (date) : NEW is account / account.move / incoterm_location (char) : NEW hasdefault: compute # DONE: pre-migration: Pre-create the column for not triggering the method. Modules modifying the computation (sale_stock and purchase_stock) will fill the value. More info at https://github.com/odoo/odoo/pull/118954 +account / account.move / invoice_payment_term_id (many2one): now a function +# NOTHING TO DO: inverse function added, compute function unchanged + account / account.move / invoice_pdf_report_file (binary): NEW attachment: True # DONE: post-migration: update message_main_attachment_id with res_field and res_id of each invoice, see '_link_invoice_documents' in 'account.move.send' @@ -149,6 +152,9 @@ account / account.move / rating_ids (one2many) : NEW re account / account.move / send_and_print_values (json) : NEW # NOTHING TO DO: This field is for storing transient data to indicate that the invoice is "programmed" to be sent, which is a new feature, so empty is OK. +account / account.move / show_update_fpos (boolean) : NEW +# NOTHING TO DO: Used in UI + account / account.move.line / discount_percentage (float) : DEL # NOTHING TO DO: Auxiliary field for Early Payment discounts from payment terms that seems unused. @@ -246,7 +252,7 @@ account / account.report / active (boolean) : NEW ha account / account.report / chart_template (selection) : NEW selection_keys: function account / account.report / chart_template_id (many2one) : DEL relation: account.chart.template -# DONE: map chart_template_id > chart_template in pre-migration +# DONE: map chart_template_id > chart_template in post-migration account / account.report / default_opening_date_filter (selection): selection_keys is now '['last_month', 'last_quarter', 'last_tax_period', 'last_year', 'this_month', 'this_quarter', 'this_tax_period', 'this_year', 'today']' ('['last_month', 'last_quarter', 'last_year', 'this_month', 'this_quarter', 'this_year', 'today']') # NOTHING TO DO: new feature @@ -361,7 +367,7 @@ account / res.company / account_discount_income_allocation_id account / res.company / chart_template (selection) : NEW selection_keys: function account / res.company / chart_template_id (many2one) : DEL relation: account.chart.template -# DONE: map chart_template_id > chart_template in pre-migration +# DONE: map chart_template_id > chart_template in post-migration account / res.company / display_invoice_amount_total_words (boolean): NEW # NOTHING TO DO: new feature @@ -381,12 +387,8 @@ account / res.company / property_stock_valuation_account_id (m account / res.company / rating_ids (one2many) : NEW relation: rating.rating account / res.partner.bank / activity_user_id (many2one) : not related anymore account / res.partner.bank / activity_user_id (many2one) : now a function -# NOTHING TO DO - account / res.partner.bank / has_iban_warning (boolean) : NEW isfunction: function, stored account / res.partner.bank / has_money_transfer_warning (boolean): NEW isfunction: function, stored -# DONE create column in pre-migration and compute using orm in end-migration - account / res.partner.bank / message_main_attachment_id (many2one): DEL relation: ir.attachment account / res.partner.bank / rating_ids (one2many) : NEW relation: rating.rating account / res.partner.bank / related_moves (one2many) : NEW relation: account.move @@ -430,18 +432,6 @@ DEL ir.model.access: account.access_account_tax_template DEL ir.model.access: account.access_product_template_account_manager DEL ir.model.constraint: account.constraint_account_account_code_company_uniq DEL ir.model.constraint: account.constraint_account_fiscal_position_account_account_src_dest_uniq -DEL ir.model.constraint: account.constraint_account_fiscal_position_tax_tax_src_dest_uniq -DEL ir.model.constraint: account.constraint_account_group_check_length_prefix -DEL ir.model.constraint: account.constraint_account_journal_code_company_uniq -DEL ir.model.constraint: account.constraint_account_journal_group_uniq_name -DEL ir.model.constraint: account.constraint_account_move_line_check_accountable_required_fields -DEL ir.model.constraint: account.constraint_account_move_line_check_amount_currency_balance_sign -DEL ir.model.constraint: account.constraint_account_move_line_check_credit_debit -DEL ir.model.constraint: account.constraint_account_move_line_check_non_accountable_fields_null -DEL ir.model.constraint: account.constraint_account_payment_check_amount_not_negative -DEL ir.model.constraint: account.constraint_account_payment_method_name_code_unique -DEL ir.model.constraint: account.constraint_account_reconcile_model_name_unique -DEL ir.model.constraint: account.constraint_account_report_line_code_uniq DEL ir.model.constraint: account.constraint_account_tax_name_company_uniq DEL ir.model.constraint: account.constraint_account_tax_template_name_company_uniq DEL ir.model.constraint: account_sequence.constraint_account_move_unique_name diff --git a/openupgrade_scripts/scripts/account/tests/data_account_migration.py b/openupgrade_scripts/scripts/account/tests/data_account_migration.py new file mode 100644 index 000000000000..93e36da1c10b --- /dev/null +++ b/openupgrade_scripts/scripts/account/tests/data_account_migration.py @@ -0,0 +1,19 @@ +env = locals().get("env") +# create payment term that triggers installation of account_payment_term +env["account.payment.term"].create( + { + "name": "Openupgrade test term", + "line_ids": [ + ( + 0, + 0, + { + "value": "balance", + "days": 10, + "end_month": True, + "days_after": 5, + }, + ), + ], + } +) diff --git a/openupgrade_scripts/scripts/account/tests/test_account_migration.py b/openupgrade_scripts/scripts/account/tests/test_account_migration.py new file mode 100644 index 000000000000..1fec33cb330b --- /dev/null +++ b/openupgrade_scripts/scripts/account/tests/test_account_migration.py @@ -0,0 +1,34 @@ +from odoo.tests import TransactionCase, tagged + +from odoo.addons.openupgrade_framework import openupgrade_test + + +@openupgrade_test +class TestAccountMigration(TransactionCase): + def test_account_payment_term_installation(self): + """ + Test that the extra payment term we add triggers installation of + account_payment_term + """ + module = self.env["ir.module.module"].search( + [("name", "=", "account_payment_term")] + ) + self.assertEqual(module.state, "to install") + + +@openupgrade_test +@tagged("post_install") +class TestAccountMigrationPost(TransactionCase): + def test_account_payment_term_migration(self): + """ + Test that the extra payment term we add is migrated correctly + """ + term = self.env["account.payment.term"].search( + [ + ("name", "=", "Openupgrade test term"), + ] + ) + self.assertEqual( + term.line_ids.days_next_month, + "5", + )