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

Pass context in one2many field

By
Ivan
on 8/19/13, 10:01 AM 2,574 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"
       nolabel="1"
       on_change="save_location_id(move_lines)"
       context="{'address_out_id': partner_id,
                 'picking_type': 'out',
                 'form_view_ref':'view_move_picking_form',
                 'tree_view_ref':'view_move_picking_tree',
                 '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() ?

Xsias
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.

Ivan
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.

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

0 follower(s)

Stats

Asked: 8/19/13, 10:01 AM
Seen: 2574 times
Last updated: 3/16/15, 8:10 AM