Odoo Help


Pass context in one2many field

on 8/19/13, 10:01 AM 3,550 views

Hello everyone! I faced following problem with o2m field: I have field in Stock Picking form named Last Selected Location(last_selected_location). This field passed into move_lines via context:

<field name="move_lines"
       context="{'address_out_id': partner_id,
                 'picking_type': 'out',
                 'default_location_id': last_source_location_id,
                 'default_location_dest_id': last_dest_location_id}"/>

I want to pass value in Stock Move and set it in location fields. When user select another value in Stock Move form it saves value in Stock Picking form. It works good when I press Save & Close button, but didn't work on Save & New button. When clicked Save & New button in location fields substituted old value even when it changed in Stock Picking. Maybe it happens because context does not update. How shall I fix it?

I'm not sure about what i will say but, have you tried to update the context in the save_location_id() ?

on 8/20/13, 5:55 AM

No. In save_location_id() just taken values from last row in o2m field and returns it in Stock Picking form.

on 8/20/13, 6:57 AM

I think that (maybe) when you click on "Save & New" button it doesn't re-call the context, because it's only reloading the create pop-in. I'm not an expert with this context's use. Sorry.

Maybe you can try a default in the .py to search the value of the location in the stock picking and pre-fill the move location field with this value.

on 8/20/13, 7:49 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.


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

0 follower(s)


Asked: 8/19/13, 10:01 AM
Seen: 3550 times
Last updated: 9/8/17, 7:38 AM