Odoo Help


How to insert value to a one2many field using context from xml?

Sebin Siby
on 5/26/16, 2:03 AM 1,250 views

<record id="view_stock_quant_tree_inherit" model="ir.ui.view">

    <field name="name">stock.quant.tree.inherit</field>

    <field name="model">stock.quant</field>

    <field name="inherit_id" ref="stock.view_stock_quant_tree"/>

    <field name="arch" type="xml">


            <xpath expr="//field[@name='inventory_value']" position="after">

                <button name="%(act_stock_move)d" type="action" context="{'default_location_id': location_id, 'product_id': product_id, 'default_move_lines': [(0, 0, {'product_id':product_id, 'product_uom_qty': 10})]}" string="Move Stock"/>





<record id="act_stock_move" model="ir.actions.act_window">

    <field name="name">New Stock Move</field>

    <field name="res_model">stock.picking</field>

    <field name="view_id" ref="stock.view_picking_form"/>

    <field name="target">new</field>


Can I do something like this??

I just want to create a stock move which will move the selected product from one location to other??

I am unable to set the field "move_lines" which is a one2many field.

Can anyone help me?

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

1 follower(s)


Asked: 5/26/16, 2:03 AM
Seen: 1250 times
Last updated: 9/6/16, 9:49 AM