This question has been flagged

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?

Avatar
Discard

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

Author

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

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.