Skip to content

Commit

Permalink
[FIX] sale_order_type: avoid exceptions in migration 8.0.1.1.0
Browse files Browse the repository at this point in the history
Fixes a rare corner case where 'sale_type' field might not exist.
  • Loading branch information
Cristian Moncho committed Nov 22, 2017
1 parent 4c1325d commit 998d689
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sale_order_type/migrations/8.0.1.1.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@
# Copyright 2017 Lorenzo Battistini - Agile Business Group
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import SUPERUSER_ID
from datetime import datetime
import logging

from openerp import SUPERUSER_ID

_logger = logging.getLogger(__name__)


def migrate(cr, version):
if not version:
return
cr.execute("""
SELECT 1 FROM information_schema.columns
WHERE table_name=%s and column_name=%s;
""", ('res_partner', 'sale_type'))
if not cr.rowcount:
_logger.error("Can't find 'sale_type' field, skipping...")
return
cr.execute(
"SELECT id, sale_type FROM res_partner WHERE sale_type IS NOT NULL")
partners = cr.fetchall()
Expand Down

0 comments on commit 998d689

Please sign in to comment.