From 213f026025ed2397372b6452e7e7298b285cae39 Mon Sep 17 00:00:00 2001 From: Robin Keunen Date: Fri, 2 Feb 2024 17:19:16 +0100 Subject: [PATCH] [FIX] stock_account: set display_type to cogs In v15, the lines were set to is_anglo_saxon_line == True in v16, field display_display is used. --- docsource/modules150-160.rst | 2 +- .../stock_account/16.0.1.1/pre-migration.py | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/stock_account/16.0.1.1/pre-migration.py diff --git a/docsource/modules150-160.rst b/docsource/modules150-160.rst index e0ef19e14b6..ffd781b3386 100644 --- a/docsource/modules150-160.rst +++ b/docsource/modules150-160.rst @@ -770,7 +770,7 @@ Module coverage 15.0 -> 16.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | stock | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| stock_account | Nothing to do | | +| stock_account | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | stock_dropshipping | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/stock_account/16.0.1.1/pre-migration.py b/openupgrade_scripts/scripts/stock_account/16.0.1.1/pre-migration.py new file mode 100644 index 00000000000..ec2f15f0230 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_account/16.0.1.1/pre-migration.py @@ -0,0 +1,33 @@ +# Copyright 2023 Coop IT Easy - Robin Keunen +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +def _account_move_line_fill_cogs_display_type(env): + """ + Fill the display type for journal items corresponding to Cost of Good Sold + lines (COGS) for customer invoices. + In v15, the lines were set to is_anglo_saxon_line == True, in v16 + field display_display is used. + + openupgrade account migration script already sets display_type + in _account_move_fast_fill_display_type (pre-migration) + + cf _stock_account_prepare_anglo_saxon_out_lines_vals + :param env: + :return: + """ + openupgrade.logged_query( + env.cr, + """ + UPDATE account_move_line + SET display_type = 'cogs' + WHERE is_anglo_saxon_line; + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _account_move_line_fill_cogs_display_type(env)