diff --git a/purchase.py b/purchase.py index e0befa8b2c..9edbc969f3 100644 --- a/purchase.py +++ b/purchase.py @@ -3,12 +3,12 @@ "Purchase" from trytond.osv import fields, OSV -from decimal import Decimal -import datetime from trytond.netsvc import LocalService from trytond.report import CompanyReport from trytond.wizard import Wizard, WizardOSV -from trytond.sql_db import table_handler +from trytond.backend import TableHandler +from decimal import Decimal +import datetime _STATES = { 'readonly': "state != 'draft'", @@ -834,14 +834,13 @@ class PurchaseLine(OSV): def init(self, cursor, module_name): super(PurchaseLine, self).init(cursor, module_name) - table = table_handler(cursor, self._table, self._name, module_name) + table = TableHandler(cursor, self._table, self._name, module_name) # Migration from 1.0 comment change into note - if 'comment' in table.table: + if table.column_exist('comment'): cursor.execute('UPDATE "' + self._table + '" ' \ 'SET note = comment') - cursor.execute('ALTER TABLE "' + self._table + '" ' \ - 'DROP COLUMN comment') + table.drop_column('comment', exception=True) def default_type(self, cursor, user, context=None): return 'line'