Odoo Help

2

10
4 答案
6
Mohamed Magdy 埃及
2014/6/2 上午2:17

I wish this may help you:

    <field name="test" nolabel="1" context="{'default_product_id': active_id, 'default_only_with_stock': True}">

Regards,

1 备注
Cyrus Waithaka 肯尼亚
2015/11/21 下午6:28

This worked like a charm. adding default_ before the field name eg default_product_id instead of product_id. Same can also be used to pass context in "create and edit" pop up as seen in the hr_expense.view_expenses_form view where groups_ref fields are set by context. if you try to create a new user from the expense form, some access right groups are automatically set.

2
DNTQ 越南
2013/4/2 上午7:33

Pls. try with line <field name="test" nolabel="1" context="{'product_id': active_id, 'only_with_stock': True}" options="{"always_reload": True}">

1 备注
Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午7:39

sorry, no difference...

2
头像

Stefan Reisich 德国

--Stefan Reisich--
Rove.design GmbH
861
| 7 7 10
Pfungstadt, 德国
--Stefan Reisich--


Stefan Reisich 德国
2013/4/5 上午11:21

I have found the solution. The right way is indeed:

<field name="test" nolabel="1" context="{'product_id': active_id, 'only_with_stock': True}">

but there is a bug in OpenERP 7. The context is not passed. The bug is fixed and needs to be released. You can see and follow the fix here:

https://code.launchpad.net/~openerp-dev/openerp-web/7.0-opw-584668-cpa

On this page you can see the modifications and fix it youself until the oficial fix is released.

1 备注
Sathors 厄瓜多尔
2014/9/5 下午12:55

I have tried to download this branch and use it as my web folder, updated all the modules of my database, but it doesn't resolve the problem... Am I supposed to install all of OpenERP once more ?

1
头像

Andreas Brueckl 奥地利

--Andreas Brueckl--

5571
| 8 8 9
Vienna, 奥地利
--Andreas Brueckl--
OpenERP Consulting and Development
Andreas Brueckl 奥地利
2013/3/29 上午4:21

With the line

<field name="test" nolabel="1" context="{'product_id': id, 'only_with_stock': True}">

you try to set the "product_id" to id. In this case the field id must be part of your view. Try to add an invisible field with the id:

<field name="id" invisible="1"/>
11 注释
Cyril Gaspard (GEM) 法国
2013/3/29 上午10:05

Hi, you can use active_id instead of id, with active_id, no need to add a field id invisible. Bye

Rove.design GmbH, Stefan Reisich 德国
2013/3/30 下午2:54

both not working... :-(

Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午4:31

I thought id was right because id is given in the URL...

Andreas Brueckl 奥地利
2013/4/2 上午6:05

Strange, the view is correct, since I saw this also in the account-addon. The problem must be in the function. You should remove method=True from the definition since this was only for v6.0. what is the value of the context within your function?

Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午6:18

my function test is working well. It has the product_id in the context. The problem is the context is not passed to the fields <field name="stock_real"/> and <field name="stock_virtual"/>.

Andreas Brueckl 奥地利
2013/4/2 上午6:21

try to remove method=True. Please update your question, because there you are using the field "test" and not "stock_real"

Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午6:33

I'm sorry, I have tested it again. My function test don't get's the product_id passed in the context too. As you can see above the product_id is added to the context from ids. So the search in my function test is working well but because the product_id is not passed from <field name="test" nolabel="1" context="{'product_id': id( or active_id), 'only_with_stock': True}">, the sub fields <field name="stock_real"/> and <field name="stock_virtual"/> don't has the product_id in their context...

Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午6:38

method=True removed. Has no effect too... :-(

Andreas Brueckl 奥地利
2013/4/2 上午6:39

Ok. I would just try <field name="stock_real" context="{'product_id': parent.id}"/>

Rove.design GmbH, Stefan Reisich 德国
2013/4/2 上午6:46

no, don't work too. I even have tried <field name="stock_real" context="{'product_id': 49}"/> with no effect...

Andreas Brueckl 奥地利
2013/4/2 上午6:56

Then I do not have any ideas. Maybe it is not possible in that special case where the fields of one2many objects are also function fields which require the context

提问
Writer
Keep Informed
2 关注者(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