Odoo Help

3

1
4 Answers
2
Avatar

Nicolas Bessi Switzerland

--Nicolas Bessi--

1640
| 5 7 10
Lausanne, Switzerland
--Nicolas Bessi--
Nicolas Bessi Switzerland
2/7/13, 8:48 AM

As far as I know this feature is not supported. You have to implement fnct_search of you function field, but I never try to do it on a one2many field and can not guarantee it works.

1
Thibaut DIRLIK France
2/7/13, 9:39 AM

As said by @nbessi, you have to define fnct_search which will let you do what you want. By definition, you can't store a one2many, it doesn't make any sense.

0
Yug Faa Morocco
2/8/13, 7:16 AM

I had edit this syntax to :

'user_ids': fields.function(
        _get_marche_users, string='Chefs',
        type='one2many', readonly=True,
        relation='res.users', multi='marche_users',
        fnct_search=_users_search)

the function _get_marche_users get users ids by intelligence and it works.

I know that the function _users_search must return this syntax :

[('id','in',res)]

and res is a list

I formulate now the question : res is it the table of ids of users that returned by the function _get_marche_users ? Really I need a full example, I grep the code and I have a big problem in a interresting project I don't found the documentation, just the prototype that's not sufficient, and I can't understand the source code so a help please I will be so grateful for you

1 Comment
Camptocamp SA Switzerland
2/28/13, 4:08 PM

A function search needs to return the ids of for the object, not for the relation object.

In your case, you must return ids of the object having Chefs lets say it is a Restaurant

So you have to search first for res.user ids matching a name. Then check if those ids are included in your Restaurant.

And for Restaurant that match this condition, you add it's id in your res list

0
Nhomar Hernandez Mexico
2/7/13, 8:57 AM

Hello.

Please try this:

The function related, must always return an iterable, if in some case it can return None it will explode,

If you try a Python console:

>>> None[1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object has no attribute '__getitem__'
>>>

See, i'm obtaining almost the same error becasue the ORM is not capable to manage a value of a type different to what it is specting, can you try and tell me the result.

Regards.

BTW: It should be cool if you can share branch wih your module to see all the py file, regards.

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now