Simple recipe to add drag-n-drop to wizard form

(Richard PALO) #1

In the wizard I’m working on, I currently have the start form creating a list of selected lines via a single field with mode=“tree” which is nice.
But I would like to be able to rearrange the order of these records for treatment (much like invoice lines on the invoice form)…
Is there a simple recipe (or example) to enable this drag-n-drop functionality?

In the doc I find only these mentions:

It is a tree if there is a field_childs defined and this tree will have drag and drop activated if the field_childs and the parent field are defined in the view.


sequence: The name of the field that is used for sorting. This field must be an integer and it will be updated to match the new sort order when the user uses Drag and Drop on list rows.

So do I need to create a specific view for this field (?) or is this something that can be inlined in my view form xml?

(Sergi Almacellas Abellana) #2

You must add an integer field on the model and use this field as name of the sequence attribute for sorting.

Then the client will automatically the value of this field depending on the order set by drag and drop

(Richard PALO) #3

If I’m sorting invoice records, are you suggesting that I need to add a sequence on Invoice()?
Can’t do that because it would be persistent which is illogical for GUI wizard pre-processing.

Is it possible to make fields.One2Many(), for example, use a local non-persistent sequence for temporal ordering (that is, can depends= be used for something like this)?

(Nicolas Évrard) #4

You could have another model which wouldn’t be persistent with a sequence and a M2O to account.invoice.