# -*- coding: utf-8 -*-
"""
    configuration.py

"""
from trytond.model import fields, ModelSingleton, ModelSQL, ModelView

__all__ = ['EndiciaConfiguration']


class EndiciaConfiguration(ModelSingleton, ModelSQL, ModelView):
    """
    Configuration settings for Endicia.
    """
    __name__ = 'endicia.configuration'

    account_id = fields.Integer('Account Id')
    requester_id = fields.Char('Requester Id')
    passphrase = fields.Char('Passphrase')
    is_test = fields.Boolean('Is Test')

    @classmethod
    def __setup__(cls):
        super(EndiciaConfiguration, cls).__setup__()
        cls._error_messages.update({
            'endicia_credentials_required':
                'Endicia settings on endicia configuration are incomplete.',
        })

    def get_endicia_credentials(self):
        """Validate if endicia credentials are complete.
        """
        if not all([
            self.account_id,
            self.requester_id,
            self.passphrase
        ]):
            self.raise_user_error('endicia_credentials_required')

        return self

@@ -47,16 +47,44 @@
 py%0A%0A%22%22%22%0A
+from trytond import backend%0A
 from try
@@ -144,16 +144,60 @@
 odelView
+%0Afrom trytond.transaction import Transaction
 %0A%0A__all_
@@ -416,14 +416,11 @@
 lds.
-Intege
+Cha
 r('A
@@ -814,16 +814,16 @@
 lete.',%0A
-
         
@@ -826,16 +826,820 @@
     %7D)%0A%0A
+    @classmethod%0A    def __register__(cls, module_name):%0A        TableHandler = backend.get('TableHandler')%0A        cursor = Transaction().cursor%0A%0A        # Migration from 3.4.0.6 : Migrate account_id field to string%0A        if backend.name() == 'postgresql':%0A            cursor.execute(%0A                'SELECT pg_typeof(%22account_id%22) '%0A                'FROM endicia_configuration '%0A                'LIMIT 1',%0A            )%0A%0A            # Check if account_id is integer field%0A            is_integer = cursor.fetchone()%5B0%5D == 'integer'%0A%0A            if is_integer:%0A                # Migrate integer field to string%0A                table = TableHandler(cursor, cls, module_name)%0A                table.alter_type('account_id', 'varchar')%0A%0A        super(EndiciaConfiguration, cls).__register__(module_name)%0A%0A
     def 

Migrate account_id from integer field to char field