migration script to 11.0.2.0.0

This commit is contained in:
hveficent
2019-01-24 14:38:45 +01:00
parent 8b4969ed5c
commit 770784cb4b
2 changed files with 44 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
# 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 11.0.2.0.0"
def update_purchase_id_column(cr):
""" The objective of this hook is to default to false all values of field
'done' of mail.activity
"""
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)

View File

@@ -58,10 +58,11 @@
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath
expr="//field[@name='line_ids']/tree//field[@name='partner_id']" position="after">
<xpath expr="//field[@name='line_ids']/tree//field[@name='partner_id']" position="after">
<field name="purchase_line_id" context="{'po_line_info': True}"
groups="account_move_line_purchase_info.group_account_move_purchase_info"/>
<field name="purchase_id"
groups="account_move_line_purchase_info.group_account_move_purchase_info"/>
</xpath>
</field>
</record>