diff --git a/addons/point_of_sale/migrations/10.0.1.0.1/openupgrade_analysis_work.txt b/addons/point_of_sale/migrations/10.0.1.0.1/openupgrade_analysis_work.txt index 3379bb7b2fce..eab93935e007 100644 --- a/addons/point_of_sale/migrations/10.0.1.0.1/openupgrade_analysis_work.txt +++ b/addons/point_of_sale/migrations/10.0.1.0.1/openupgrade_analysis_work.txt @@ -13,7 +13,7 @@ point_of_sale / pos.config / state (selection) : DEL r point_of_sale / pos.config / default_fiscal_position_id (many2one): NEW relation: account.fiscal.position point_of_sale / pos.config / iface_fullscreen (boolean) : DEL point_of_sale / pos.config / invoice_journal_id (many2one) : NEW relation: account.journal -# NOTHING TO DO +# Done: pre-migration. We set the invoice_journal_id with the journal_id value, because, default function return bad journal in multicompany context. We populate the value only if the column doesn't exist. (that is the case if the OCA module pos_invoice_journal is installed in previous version) point_of_sale / pos.order.line / pack_lot_ids (one2many) : NEW relation: pos.pack.operation.lot # NOTHING TO DO diff --git a/addons/point_of_sale/migrations/10.0.1.0.1/pre-migration.py b/addons/point_of_sale/migrations/10.0.1.0.1/pre-migration.py new file mode 100644 index 000000000000..b645e9c599c0 --- /dev/null +++ b/addons/point_of_sale/migrations/10.0.1.0.1/pre-migration.py @@ -0,0 +1,30 @@ +# coding: utf-8 +# Copyright (C) 2020 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade +from psycopg2 import ProgrammingError + + +def _populate_invoice_journal_id(env): + try: + # We try to create the new field. + # It will fail if pos_invoice_journal has been installed + openupgrade.logged_query( + env.cr, """ + ALTER TABLE pos_config + ADD column invoice_journal_id integer;""" + ) + except ProgrammingError: + return + openupgrade.logged_query( + env.cr, """ + UPDATE pos_config + SET invoice_journal_id = journal_id;""" + ) + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + _populate_invoice_journal_id(env) diff --git a/odoo/addons/openupgrade_records/lib/apriori.py b/odoo/addons/openupgrade_records/lib/apriori.py index d78c1351fffd..a36c9aaac100 100644 --- a/odoo/addons/openupgrade_records/lib/apriori.py +++ b/odoo/addons/openupgrade_records/lib/apriori.py @@ -63,6 +63,8 @@ ('website_sale_b2c', 'sale'), # used groups are in sale # OCA/manufacture ('mrp_production_unreserve', 'mrp'), + # OCA/pos + ('pos_invoice_journal', 'point_of_sale'), # OCA/purchase-workflow ('purchase_fiscal_position_update', 'purchase'), # OCA/sale-workflow