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

Ordering Line Items

By
Gavin Yap
on 3/31/16, 11:14 PM 199 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?

 

0
Gavin Yap
On 4/1/16, 5:30 AM

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.

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: 3/31/16, 11:14 PM
Seen: 199 times
Last updated: 4/1/16, 5:30 AM