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.

0

My onchange function giving error "ProgrammingError: can't adapt type 'browse_record'" when I include WHERE clouse in the query or else it work fine. Please help me out....!!!

By
Rokon Uddin
on 9/21/14, 1:40 AM 2,600 views

 onchange_storage_device(self, cr, uid, ids, storage_type, context=None):
        if storage_type:
            storage_type = self.pool.get('archive.storage.type').browse(cr, uid, storage_type, context=context)
            cr.execute("""select  max(CAST(nullif(split_part(name, '-', 2), '') AS integer)) from archive_storage WHERE storage_device= %d""", (storage_type,))


            sn = cr.fetchone()[0]
            return {'value': {'name': storage_type.name + str( "%05d"% sn+1)}}
        return {'value': {}}

Query engine does not recognize orm class, and you passed storage_type in params, it should rather be the id viz storage_type.id

Serpent Consulting Services Pvt. Ltd.
on 9/21/14, 2:19 PM
1
Shokri Alnajjar
On 9/21/14, 2:43 AM

Try to put storage_type.id instead of storage_type at the end of your statement like this

cr.execute("""select  max(CAST(nullif(split_part(name, '-', 2), '') AS integer)) from archive_storage WHERE storage_device= %d""", (storage_type.id,))

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: 9/21/14, 1:40 AM
Seen: 2600 times
Last updated: 3/16/15, 8:10 AM