Skip to Content
Menu
This question has been flagged
1 Reply
3285 Views

Hi,


I would have 2 models of the following


class Table(modes.Models):
    _name = 'mymodule.table'
    name = name = fields.Char(
        required=True,
        string='Table Name',
        help='Table Name',
    )
    table_lines = field.One2many(
        'mymodule.table.line',
        'table_id',
        string='Lines'
    )


class TableLine(models.Model):
    _name = 'mymodule.table.line'
    name = fields.Char(
        required=True,
        string='Name',
        help='Line Name',
    )
    data = fields.Char(
        required=True,
        string='Data',
        help='Data',
    )
table_id = fields.Many2one(
'mymodule.table',
ondelete='cascade',
string='Table'
)

   
How could I create a form which has a tree/list view of my TableLine items and able to set them in order?

 

Avatar
Discard
Author Best Answer

I just found out that, I need to add an attribute my TableLine model.

sequence = fields.Integer(
string="Sequence",
help='Set the order by sequence'
)

 and then in the tree view of this model


<!-- Tree view for TableLine settings -->
<record id="table_line_tree" model="ir.ui.view">
<field name="name">Table Lines</field>
<field name="model">mymodule.table.line</field>
<field name="arch" type="xml">
<tree>
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="data"/>
</tree>
</field>
</record>        


This should do the trick.

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 19
4383
1
Jun 24
366
4
Apr 20
8947
1
Nov 15
5337
1
Oct 15
8248