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

[v8] How to properly define a default function ?

By
PY
on 1/13/15, 4:18 AM 854 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

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

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: 1/13/15, 4:18 AM
Seen: 854 times
Last updated: 3/16/15, 8:10 AM