Skip to Content
Menu
This question has been flagged
2 Replies
5509 Views

Hi,

for Products we added new relation to a custom Model ("Text-Line"). So in ech Product a user can add many single Text-Lines.

now the user should be able to "resort" the associated Text-Lines. For this reason we added a Integer Field "SortOrder" to the Model "Text-Line". In the Listview of the Textlines the User should be able to Move a Text-Line Up/Down with an arrow.

Is there any simple way in Odoo (or do you know any already existing Module/Addon) that uses such functionality to change the position/sorting of a related Module?


Avatar
Discard
Best Answer

Hi Jack,

Define field in py file as:

class TextLine(models.Model):
    _name = 'Text-Line'   

   _order = 'sequence'

    sequence = fields.Integer(string='Sequence', default=1)

In the tree view of Text-Line in Products form: (text_line is the field defined in product form)

<field name="text_line" mode="tree,kanban"

   <tree string="Text Lines" >   

          <field name="sequence" widget="handle"/>

  </tree>

</field>


Avatar
Discard
Author Best Answer

i tried that and the sqeunce field was added to the model. In DB the field increments correctly.


BUT: in the treeview the widget="handle" only adds an empty row. i can not drag/drop each row. if i click on that cell it opens a popup with the data of the text-line-Model.


UPDATE: myMistake --> in edit-view it works perfect.


Avatar
Discard

ok... if it worked, please vote for it(tick the correct answer..it will help others to find the correct solution)