Odoo Help


How to get duplicate in One2many form

on 5/19/14, 7:28 AM 2,973 views

How to get duplicate in One2many form, ex, A is a parent form, it has one one2many field, this one2many field has 5 fields, like name, age, dept, supervisor, shift. In this case shift and supervisor will entered by the user click on the Add New Items button in the first form, this two values needed for next 4 records while clicking  the button Save&New, How to do that.

Bui The Do
On 4/15/16, 9:29 PM

I added more clear for reviews of Prakash. To one2many autoloading after clicking on the button, you add option for the field options="{'reload_on_button': true}".


<field name="x_design_content_building" options="{'reload_on_button': true}" string="Building data">


        <field name="x_bulding_name" string="Building name" />

        <field name="x_is_multifloor_building" string="Multifloor" />

        <button name="duplicate" type="object" groups="base.group_sale_salesman" string="Duplicate"/>






| 5 5 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 5/23/14, 8:12 AM

Create a button in the one2many form and override the copy method.

Example In one2many form,

Xml File

  <button name="duplicate"  type="object" string="Duplicate Line"/>

Python File

_name = 'table.name.line'

 def duplicate(self, cr, uid, ids, context=None):
        res = self.pool.get('table.name.line').copy(cr, uid, ids[0], default=None, context=context)
       return  res



This works only if the parent object has been saved (and thus child objects as well). The children don't have an ID before they have been saved, and in one2many relationship they are saved only when the parent is saved.

Miku Laitinen
on 9/1/14, 5:26 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

1 follower(s)


Asked: 5/19/14, 7:28 AM
Seen: 2973 times
Last updated: 4/15/16, 9:29 PM