Odoo Help


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.


V 7 Read method error ?

Ahmed elbarbary
on 3/4/15, 6:35 AM 301 views

I want to get the opportunity state in the BOQ projects because I have fields in BOQ want to be shown only in quotation state so I need to get the opportunity state in the BOQ project ,


Now I have this method to return the opportunity state but I have an issue with ids is that must be boq_project_id ? how can I get the boq_project_id because that method rasie ana error :

2015-03-04 10:08:16,893 2372 ERROR EXD-SA openerp.sql_db: bad query: SELECT boq_projects."opportunity_id",boq_projects.id FROM "boq_projects" WHERE boq_projects.id IN ('lang', 'crm_stage', 'tz', 'uid') ORDER BY id.


If I replace the ids with any boq_project id such as : 260 then every thing working good and method return the state successfully.


Could anyone tell me what is the error in my method ?


class boq_projects(osv.osv):

    _name = "boq.projects"

    _description = "BoQ Projects"



    def _opportunity_state(self, cr, uid, ids, context=None):


        reads = self.read(cr, uid, ids, ['opportunity_id'], context)

        opp_id = reads['opportunity_id'][0]

        print opp_id, '@@@@@@@@@@@@@@@@@@@'

        lead_obj = self.pool.get('crm.lead')

        lead = lead_obj.read(cr, uid, opp_id, ['state'])

        print lead,'@@@@@@@@@@@@@@@@@@@'

        return lead['state']




    _columns = {






        'boq_state' : fields.char('state'),




    _defaults = {

        'boq_state': _opportunity_state









| 5 3 8
Pondicherry, India
On 3/4/15, 6:47 AM

Hi, try this code:


def _opportunity_state(self, cr, uid, ids, context=None):

        res = {}
        for record in self.read(cr, uid, ids, ['opportunity_id'], context=context):

        res[record['state']] = 'some_value'

        return res

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

1 follower(s)


Asked: 3/4/15, 6:35 AM
Seen: 301 times
Last updated: 3/16/15, 8:10 AM