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

How to get duplicate in One2many form

By
sridhar
on 5/19/14, 7:28 AM 1,847 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.

0
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}".

Example:

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

    <tree>

        <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"/>

    </tree>

</field>

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
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

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

1 follower(s)

Stats

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