Receive this message everytime i try to export data from any module as a reason for fail. Running on AWS - T2 medium. Odoo 11 CE from BItnami
psycopg2.ProgrammingError: copy_from cannot be used with an asynchronous callback.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Receive this message everytime i try to export data from any module as a reason for fail. Running on AWS - T2 medium. Odoo 11 CE from BItnami
psycopg2.ProgrammingError: copy_from cannot be used with an asynchronous callback.
I have solved this issue in my deployment.
The error is has to do with the xml_id. Looks like it only affects Bitnami deployments and my guess is that is has to do with the way the postgres database is installed in Bitnami. For some reason when a psycopg2 copy instructions is executed the system attempts to do it a asynchronously.
This error happens when a record that is being exported has no xml_id. Odoo creates one and attempts to add it to the ir_model_data table. The copy_from instruction si trying to insert a new id into the table. As it fails returning the error mentioned here the export fails.
Fix:
Change the following in the file /opt/bitnami/apps/odoo/lib/odoo-11.0.post20180618-py3.6.egg/odoo/models.py
Line 37:
from contextlib import closing
to
from contextlib import closing, contextmanager
Lines 671 - 683
cr.copy_from(io.StringIO(
u'\n'.join(
u"%s\t%s\t%s\t%d" % (
modname,
record._name,
xids[record.id][1],
record.id,
)
for record in missing
)),
table='ir_model_data',
columns=fields,
)
to
@contextmanager
def _paused_thread():
try:
thread = psycopg2.extensions.get_wait_callback()
psycopg2.extensions.set_wait_callback(None)
yield
finally:
psycopg2.extensions.set_wait_callback(thread)
with _paused_thread():
cr.copy_expert("COPY ir_model_data (module, model, name, res_id) FROM STDIN",
io.StringIO(u''.join( #If you get an error use u'\n' here instead of u''
u"%s\t%s\t%s\t%d" % (
modname,
record._name,
xids[record.id][1],
record.id,
)
for record in missing
)
))
This will do a async bulk insert into the database of the missing xml_id's and the export will finish.
Hope this helps!
Hi,
Seems that such an issue is already reported in the GitHub: https://github.com/odoo/odoo/issues/24145
The one who posted the issue says he cannot reproduce the issue in the latest versions of the odoo v11. So get the latest version/code of the odoo v11 and see whether you are getting the same error or not.
Most probably you will not get the same issue with the latest V11.
Thanks
Create an account today to enjoy exclusive features and engage with our awesome community!
Registrar-se