Skip to content

Commit

Permalink
Merge pull request #45 from Tecnativa/8.0-migration_sale_condition
Browse files Browse the repository at this point in the history
[ADD] sale_comment_template: add migration scripts
  • Loading branch information
pedrobaeza committed Feb 13, 2018
2 parents a8868ed + dce1b51 commit fc7b104
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
account-invoice-reporting
3 changes: 2 additions & 1 deletion sale_comment_template/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
"invoice_comment_template",
],
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
"data": ["sale_order_view.xml",
'base_comment_template_view.xml',
'views/report_saleorder.xml',
'security/ir.model.access.csv',
],
"category": "Sale",
"installable": True,
"active": False, }
}
32 changes: 32 additions & 0 deletions sale_comment_template/migrations/8.0.1.0.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - Vicent Cubells
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade


def migrate_comment_template(cr):
cr.execute(
"""
UPDATE sale_order so
SET comment_template1_id = bct.condition_template_id,
note1 = bct.text
FROM base_comment_template bct
WHERE bct.id = so.condition_template_id
AND bct.position = 'before_lines'
""")
cr.execute(
"""
UPDATE sale_order so
SET comment_template2_id = bct.condition_template_id,
note2 = bct.text
FROM base_comment_template bct
WHERE bct.id = so.condition_template_id
AND bct.position = 'after_lines'
""")


@openupgrade.migrate()
def migrate(cr, version):
if openupgrade.column_exists(cr, 'sale_order', 'condition_template_id'):
migrate_comment_template(cr)

0 comments on commit fc7b104

Please sign in to comment.