Allow to duplicate rows in a One2Many field

Some users asked me to implement a tool to duplicate rows in a one2many field (sale lines, purhcase lines, …). Of course I can do it myself through a button or something else but I’m wondering if someone else had had the same need and if do you think that would be nice to include the duplicate option in the ‘right-click’ menu when it is a one2many.
In addition, I just noticed that is not allowed to execute any action except ‘copy’ if you select more than one row in a one2many, I suppose that it’s a framework limitation no? Or which is the reason?

What is the use case?

This will be very tricky because you can not call duplicate on a unsaved record. But also nothing guarantee that the copied records will still be attached to the parent record (except if value is forced).

It is an implementation detail. Indeed I think nothing prevent to improve the code to remove this constraint.

For example, on sales department, they sometimes have sales with a lot of lines of different types (line, subtotal, title,…) and the lines usually follow the same structure so they want to create the first ones and after that duplicate it and modify just the product, the title or whatever.

Anyway I know that’s not necessary at all but I just thought that this feature maybe was something that more people needed so it could be a good improvement.

We use something similar at price_list. We created a action (duplicate lines) that you push selecting the lines to duplicate. That action creates new lines at price_list_lines belonging at the same list price. Its very useful and it reduce the possibility of error.

Then you should probably add some way to add this structure in a bunch to ease the introduction of lines.

Probably a wizard that asks for the type of structure (if there is more than one structure type needed) and then ask for additional details.

For me this will be what will speed up the introduction of lines.

I remeber we developed a wizard to ease the introduction of multiple lines by adding a template and allowing to the variants quantity on a grid so we create all the lines with quantities set in a buch. This was a great speed up as there where between 10 and 30 variants per template.

There is also the product attribute that allow to generate lines using Cartesian product.

This seems a use case for product kit.

Indeed I’ve never understood which is the usage of this attribute. Could you give some use case for it?

But product kits does not allow to set titles nor subtotals. Which I think is the current case:

You may define product as factor and quantity. So it will create a line for each product for the quantity.