From c68f462c1c0666247b69267ea5e1a6ca34c4a191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miquel=20Ra=C3=AFch?= Date: Tue, 17 Dec 2024 18:32:39 +0100 Subject: [PATCH] [OU-IMP] point_of_sale: assure company_id is filled --- .../point_of_sale/15.0.1.0.1/pre-migration.py | 19 +++++++++++++++++++ .../15.0.1.0.1/upgrade_analysis_work.txt | 3 +++ 2 files changed, 22 insertions(+) diff --git a/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/pre-migration.py b/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/pre-migration.py index f8a9222c61c7..8436c11de3d4 100644 --- a/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/pre-migration.py +++ b/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/pre-migration.py @@ -47,6 +47,24 @@ def merge_pos_order_line_module(env): ) +def fill_pos_payment_method_company_id(env): + """required field""" + openupgrade.logged_query( + env.cr, + """UPDATE pos_payment_method ppm + SET company_id = aj.company_id + FROM account_journal aj + WHERE ppm.company_id IS NULL AND ppm.journal_id = aj.id""", + ) + openupgrade.logged_query( + env.cr, + """UPDATE pos_payment_method ppm + SET company_id = aa.company_id + FROM account_account aa + WHERE ppm.company_id IS NULL AND ppm.receivable_account_id = aa.id""", + ) + + @openupgrade.migrate() def migrate(env, version): merge_pos_order_return_module(env) @@ -74,3 +92,4 @@ def migrate(env, version): ALTER TABLE pos_config ADD COLUMN IF NOT EXISTS warehouse_id INTEGER """, ) + fill_pos_payment_method_company_id(env) diff --git a/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/upgrade_analysis_work.txt index 54a41a424b70..af4daeee7fa6 100644 --- a/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/point_of_sale/15.0.1.0.1/upgrade_analysis_work.txt @@ -86,6 +86,9 @@ point_of_sale / pos.payment / company_id (many2one) : is no point_of_sale / pos.payment.method / is_cash_count (boolean) : now a function # NOTHING TO DO +point_of_sale / pos.payment.method / company_id (many2one) : now required +# DONE: pre-migration: filled field if empty + point_of_sale / pos.payment.method / cash_journal_id (many2one) : DEL relation: account.journal point_of_sale / pos.payment.method / journal_id (many2one) : NEW relation: account.journal # DONE: pre-migration: renamed fields