Odoo Help

0

[v8] How to properly define a default function ?

By
PY
on 1/13/15, 4:18 AM 1,111 views

Hi there !

I try to make a v7 module working in v8. The only issue I have for now is the default values.

In model A, I have a one2many field, with a default value set to a function call. The function create records of the linked object B, then return their ids. I checked with psql, the records of B are indeed created, but the id of A is not passed to them. In consequence, when I try to create a record of A, B are created, but I cant see them, nor edit them in the "one2many_list" of A's form view.

And this is weird, since it worked back in v7. I tried the new-style approach, passing the function name to a "default" argument of the one2many field definition, and removing the "_defaults" part, but no luck with that. Not working neither.

Any help ?

EDIT

By the way, what is the proper syntax of a new-style default function ? What decorator should I put ? What should it return ? A list of ids ? A list of tuples (id, name) ? Thanks !

0
Ahmed M.Elmubarak
On 1/14/15, 6:53 AM

Hi, check this, https://github.com/odoo/odoo/blob/8.0/addons/stock/stock.py#L1796 I think it is working as usual ....

Never mind, in fact, I have came with another approach. Default function was working fine, it's just other things that won't work.

PY
on 1/15/15, 4:17 AM

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

Question tools

1 follower(s)

Stats

Asked: 1/13/15, 4:18 AM
Seen: 1111 times
Last updated: 3/16/15, 8:10 AM