Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

ProgrammingError: can't adapt type 'document.directory'

By
David Verove
on 11/7/14, 10:03 AM 3,558 views

Hello,

I get the following error when accessing a property of object document.directory :

 

dir_file_obj = self.pool.get('document.directory').browse(cr, uid, doc_id, context=context)

_logger.info("16 : %r", dir_file_obj.path) 

if dir_file_obj.path:

 

In log :

2014-11-07 10:12:47,085 18941 ERROR dev openerp.sql_db: Programming error: can't adapt type 'document.directory', in query  SELECT document_directory."create_uid",document_directory."domain",document_directory."create_date",document_directory."ressource_type_id",document_directory."resource_field",document_directory."inode",document_directory."company_id",document_directory."write_uid",document_directory."parent_id",document_directory."resource_find_all",document_directory."ressource_parent_type_id",document_directory."write_date",document_directory."path",document_directory."ressource_tree",document_directory."user_id",document_directory."ressource_id",document_directory."type",document_directory."id",document_directory."name" FROM "document_directory"

                    WHERE document_directory.id IN %s AND (TRUE)
                    ORDER BY name

(...)

2014-11-07 14:57:23,975 2324 ERROR dev openerp.addons.base.ir.ir_cron: Call of self.pool.get('import_dossier').batch_import(cr, uid, *(False,)) failed in Job 9
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_cron.py", line 138, in _callback
    getattr(model, method_name)(cr, uid, *args)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/odoo/addons/documents_aneosys/import_dossier.py", line 130, in batch_import
    self.traite_fichiers(cr, uid, root, files, context)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 237, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/odoo/addons/documents_aneosys/import_dossier.py", line 228, in traite_fichiers
    _logger.info("16 : %r", dir_file_obj.path)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 760, in __get__
    self.determine_value(record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 853, in determine_value
    record._prefetch_field(self)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 235, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3169, in _prefetch_field
    result = records.read(list(fnames), load='_classic_write')
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 235, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3114, in read
    self._read_from_database(stored)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 235, in wrapper
    return new_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 3226, in _read_from_database
    cr.execute(query, [tuple(sub_ids)] + rule_params)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
  File "/usr/lib/python2.7/dist-packages/psycopg2/extensions.py", line 129, in getquoted
    pobjs = [adapt(o) for o in self._seq]
ProgrammingError: can't adapt type 'document.directory'

 

I can't access any property except id, is it a bug from v8?

Thanks,

David

0
David Verove
On 11/7/14, 10:31 AM

Found, the error was from doc_id, which is an external key, I fixed it with : 

 

dir_file_obj = self.pool.get('document.directory').browse(cr, uid, doc_id.id, context=context)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/7/14, 10:03 AM
Seen: 3558 times
Last updated: 3/16/15, 8:10 AM