Migration tryton manuellement

Comment appliquer les migrations tryton très exactement

Dans le lien Migration — Tryton Documentation nous avons une séries de commande à faire. Mais ça ne va pas remplacer les modules tryton 6.0 que je possède en modules tryton 7.0, d’autant plus que tous ses modules sont téléchargés de manière manuelle, sans passer par une installation pip. En plus de cela les commandes données dans le topic migration se font comment exactement? J’ai du mal à savoir.

Je veux quitter de la version 6.0 de tryton à la version 7.0

Mes modules sont tous des versions 6.0.x

Du coup j’exécute les commandes migrations mises ici Migration — Tryton Documentation de la version 7.0 (BEFORE) avant la mise à jour (avant l’exécution de tryton-admin) et les commande AFTER après?.

Voici mes différents modules

Need help please

Avant d’appliquer les commandes de migration sur votre base de données, il faut avoir une version cible de Tryton fonctionnelle. C’est a dire avoir récupérer la version 7.0 de GNU Health.
Ensuite vous pourrez appliquer les commandes de migration de Tryton sur votre base de donnée.
Je ne connais pas GNU Health mais je suppose qu’il doit y avoir aussi des commandes de migration spécifique a leurs modules.

You need to install the 7.0 series before running any migration. This includes the server modules and all your custom modules.If you are downloading manually modules, you should redownload the modules for the specific version

The procedure should be something like:

  1. Backup your instalation (database, filestore and trytond instalation)
  2. Install the new server with custom modules
  3. Execute the before commands from migration
  4. Exeucte the migration (a.k.a run trytond-admin)
  5. Exeucte the after comands from migration

Enjoy your new tryton version.

Hope this helps!

  1. Backup Installation — OK
  2. Install the New Server

Here i Just reinstall gnuhealth and change the version 6.0 of tryton to 7.0.
i put all custom modules i do in the module directory and link this to tryton/modules

  1. BEFORE Command

I don’t have the account_payment module installed, so i execute the BEFORE command but got an error.

  1. Migration

When i execute the migration tyrton admin, i got this error

health_explo is a custom module

Please how i do to correct this error?

Sorry if my English isn”t correct

ThankS

You need to install a version of GNU Health that is compatible with the Tryton series 7.0.
I think it is the version 5.0 of GNU Health.

Be sure that your custom modules are compatible with Tryton 7.0.
Only very simple module can be compatible between different series, others need to be updated.

If you do not met the condition of a migration task, do not run it.

Also be sure to execute all the before migration tasks bewteen 6.0 and 7.0.

This is typical of health_explo version not being compatible with Tryton 7.0.

C’est vraiment très compliqué comme situation.

J’exécute la commande tryton-admin mais j’ai une erreur. Certainement avec un champ dans la base de donnée.

Contrairement aux modifications et erreurs dans les fichiers, je ne sais pas comment résoudre ce problème.

I suspect that an Integer field has been changed into Char field but without proper migration.
I suspect that this is in a GNU Health module because I can not recall any such change in standard Tryton.
You may have more information if you run trytond-admin with more verbosity like -vv.

J’ai essayé de regarder en utilisant -vv.

Vu que j’exécute le script trytond-admin, je ne sais pas comment trouver l’index à modifier.

S’il vous plait, vous aurez des solutions dessus?

The system tries to create an index for the gnuhealth.patient.exp.test but I could not find in Gnu Health where is defined this model. So I can not help for now.

C’est un module personnalisé que j’ai crée

Voici sa définition

class GnuHealthPatientExpTest(ModelSQL, ModelView):
    'Exp Test Request'
    __name__ = 'gnuhealth.patient.exp.test'

    name = fields.Many2One(
        'gnuhealth.exp.test_type', 'Test Type',
        required=True )
    date = fields.DateTime('Date' )
    state = fields.Selection([
        ('draft', 'Draft'),
        ('tested', 'Tested'),
        ('ordered', 'Ordered'),
        ('cancel', 'Cancel'),
        ], 'State', readonly=True )
    source_type = fields.Selection([
        ('patient', 'Patient'),
        ('other_source', 'Other')
        ], 'Source', 
        help='Sample source type.',
        sort=False )
    patient_id = fields.Many2One(
        'gnuhealth.patient', 'Patient',
        states={'invisible': (Eval('source_type') != 'patient')})
    other_source = fields.Char('Other', 
        states={'invisible': (Eval('source_type') != 'other_source')},
        help="Other sample source.")
    source_name = fields.Function(
        fields.Text('Source name'), 'get_source_name')

    def get_source_name(self, name):
        if self.is_patient():
            return self.patient_id and self.patient_id.rec_name or ''
        else:
            return (self.other_source or '')

    doctor_id = fields.Many2One(
        'gnuhealth.healthprofessional', 'Health prof.',
        help="Health professional who requests the exp test." )
    context = fields.Many2One(
        'gnuhealth.pathology', 'Context',
        help="Health context for this order. It can be a suspected or"
             " existing health condition, a regular health checkup, ...",)
    request = fields.Integer('Order', readonly=True)
    urgent = fields.Boolean('Urgent')

    @classmethod
    def __setup__(cls):
        super(GnuHealthPatientExpTest, cls).__setup__()
        cls._order.insert(0, ('date', 'DESC'))
        cls._order.insert(1, ('request', 'DESC'))
        cls._order.insert(2, ('name', 'ASC'))

    @staticmethod
    def default_date():
        return datetime.now()

    @staticmethod
    def default_source_type():
        return 'patient'

    @staticmethod
    def default_state():
        return 'draft'

    @staticmethod
    def default_doctor_id():
        return get_health_professional()

    
    @classmethod
    def contact(self, id):

        transaction = Transaction()
        cursor = transaction.connection.cursor()
        #cursor = conn2.cursor()
        f = cursor.execute("SELECT current_database()")
        database_name = cursor.fetchone()[0]
        #sql = "SELECT type, value FROM party_contact_mechanism JOIN party_party ON party_contact_mechanism.party = party_party.id JOIN gnuhealth_patient ON {} = gnuhealth_patient.id".format(id)
        sql1 = "SELECT name FROM gnuhealth_patient where gnuhealth_patient.id = {}".format(id)
        cursor.execute(sql1)
        data1 = cursor.fetchone()
        sql2 = "SELECT type, value FROM party_contact_mechanism WHERE party = {}".format(data1[0])
        cursor.execute(sql2)
        data2 = cursor.fetchall()
        #print("Les différentes données ", data2[0][0])

        list_phone = []
        for item in data2 :
            if item[0] == "phone" :
                list_phone.append(item[1])

        return ("/ ".join(list_phone))
    
    
    @classmethod
    def generate_code(cls, **pattern):
        Config = Pool().get('gnuhealth.sequences')
        pool = Pool()
        ExpTest = pool.get("gnuhealth.patient.exp.test")
        records = ExpTest.search([], order=[('id', 'DESC')], limit=1)
        request = records[0].id + 1 if records else None
        config = Config(1)
        sequence = config.get_multivalue(
            'exp_request_sequence', **pattern)
        if request:
            return request
        else :
            return 1

    @classmethod
    def create(cls, vlist):
        vlist = [x.copy() for x in vlist]
        for values in vlist:
            values["request"] = cls.generate_code()
            if not values.get('name'):
                values['name'] = cls.generate_code()

        return super(GnuHealthPatientExpTest, cls).create(vlist)

    @classmethod
    def copy(cls, tests, default=None):
        if default is None:
            default = {}
        default = default.copy()
        default['request'] = None
        default['date'] = cls.default_date()
        return super(GnuHealthPatientExpTest, cls).copy(
            tests, default=default)

    def is_patient(self):
        return (self.source_type == 'patient')

    def is_other_source(self):
        return (self.source_type == 'other_source')

You can not set the _rec_name field (default name) to a field that is not a Char.

So either you set _rec_name to a different value or you must rename and migration the name field.