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

Sort-Order for Custom-Module

By
Jack
on 11/3/16, 9:06 AM 109 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?


2
Ameera PP
On 11/4/16, 1:10 AM

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>


0
Jack
On 11/4/16, 6:18 AM

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.


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

Ameera PP
on 11/5/16, 1:20 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: 11/3/16, 9:06 AM
Seen: 109 times
Last updated: 11/7/16, 1:28 AM