تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1350 أدوات العرض

Hello,

in odoo16e in Osoo sh, I want to get info from an external database, in odoo sh i have postgresql (14.12) and the database that i want to get info, has postgresql (9.6.19)

I'm trying using psycopg2, in my odoo local i can access successfully, but not in odoo sh, i get this error: connection to server at "xxx.xx.xxx.xxx", port xxxx failed: FATAL: unrecognized configuration parameter "jit" 


my odoo local has postgresql (16.3)


My code is: 

import psycopg2

from odoo import api, fields, models,


class ZkMachine(models.Model): 

​_name = 'zk.machine'

​ def try_connection(self):

​ db_params = {

​ 'dbname': self.database,

​ 'user': self.user_name,

​ 'password': self.password,

​ 'host': self.name,

​ 'port': self.port_no

​ }

​ dsn = f"dbname={db_params['dbname']} user={db_params['user']} password={db_params['password']} host={db_params['host']} port={db_params['port']}"

​ try:

​ conn = psycopg2.connect(dsn)

​ if conn:

​ msg = f'Te has conectado exitosamente a {self.database}'

​ conn.close()

​ except psycopg2.Error as e:

​ msg = f"No se ha podido establecer la conexión: {e}"

​ return self._message_user('danger', msg)

​ except Exception as ex:

​ msg = f"Error desconocido: {ex}"

​ return self._message_user('danger', msg)


Could someone help me to solve this??


Thx in advance

الصورة الرمزية
إهمال
أفضل إجابة

Hi,

As per the information given the error you're encountering in Odoo SH happens because Odoo SH's PostgreSQL client (psycopg2) is newer (supporting PostgreSQL 14 features like JIT), while your target external PostgreSQL server is 9.6, which does not recognize newer parameters like jit.


This issue arises not from your code, but from the PostgreSQL client's default settings when connecting, which may try to use features that don't exist in PostgreSQL 9.6.


To solve this issue you need to disable JIT explicitly when making the connection. 


Hope it helps.



الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
سبتمبر 21
4261
2
أبريل 24
10514
4
أبريل 25
3649
0
فبراير 25
1340
2
يناير 25
7772