Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by legalsylvain
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
addons/point_of_sale/migrations/10.0.1.0.1/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters