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

object has no attribute '_ids'

By
Clément TheSecond
on 4/30/15, 5:51 AM 3,157 views

Here's my model :

 from openerp import models, fields, api, tools

class Searches(models.Model):

	_name = 'user.search'

	search = fields.Char('Searches made by users',required=True)

	nb_searches = fields.Integer('Number of searches for this phrase',required=True)

	def a_function(sef,cr,uid,context=None):
		return None


And when I try to search in it :

self.search(cr, uid, []) 

I've got the following error :

AttributeError: 'user.search' object has no attribute '_ids'

What's wrong ? The user_search table have an 'id' attribute ... I don't what what I did wrong.

0
Clément TheSecond
On 5/3/15, 2:21 PM

I've found the answer :

I had put a field called 'search' like this :

search = fields.Char(....)

And it seams that Odoo doesn't really apreciate that we call a field 'search', I changed it by 'search_sentence' and it worked perfectly.

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 4/30/15, 6:18 AM

Reference: https://github.com/nbessi/odoo_new_api_guideline/blob/master/source/environment.rst

Now  Seach function returns directly a RecordSet:

  ids = self.search([])  


You can do a search using env:

self.env['user.search'].search([]) 

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)

Stats

Asked: 4/30/15, 5:51 AM
Seen: 3157 times
Last updated: 5/3/15, 2:21 PM