mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
forward port latest changes from 11.0
This commit is contained in:
committed by
ps-tubtim
parent
06f8b54ea3
commit
2c8c39f91c
@@ -0,0 +1,38 @@
|
||||
# Copyright 2019 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
__name__ = "Upgrade to 12.0.2.0.0"
|
||||
|
||||
|
||||
def update_purchase_id_column(cr):
|
||||
cr.execute("""SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_name='account_move_line' AND
|
||||
column_name='purchase_id'""")
|
||||
if not cr.fetchone():
|
||||
_logger.info("""Add column purchase_id to account_move_line""")
|
||||
cr.execute(
|
||||
"""
|
||||
ALTER TABLE account_move_line ADD COLUMN purchase_id integer;
|
||||
""")
|
||||
_logger.info("""Updating values for purchase_id in account_move_line""")
|
||||
cr.execute(
|
||||
"""
|
||||
UPDATE account_move_line aml
|
||||
SET purchase_id = pol.order_id
|
||||
FROM purchase_order_line AS pol
|
||||
WHERE aml.purchase_line_id = pol.id
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def migrate(cr, version):
|
||||
if not version:
|
||||
return
|
||||
update_purchase_id_column(cr)
|
||||
Reference in New Issue
Block a user