Borealis
Borealis

Reputation: 1137

Empty tree view

I can't get the tree view to display any data at all even I can create entries with no problem and they appear in the database

Here is the view xml:

        <record id="view_invoice_lab_tree" model="ir.ui.view">
            <field name="name">lab.invoice.tree</field>
            <field name="model">lab.invoice</field>
            <field name="arch" type="xml">
                <tree string="Labs Invoices">
                   
                    <field name="name" string="invoice Number"/>
                    <field name="create_date"/>
                    <field name="patient_id"/>
                    <field name="amount_total"/>
                </tree>
            </field>
        </record>

Model Structure:

class LabOrderLine(models.Model):
    _name = 'lab.order.line'
    _description = 'labs Order Line'
    name = fields.Text(string='Description', required=True)
    order_id = fields.Many2one('lab.invoice', string='Invoice Reference', required=True, ondelete='cascade', index=True, copy=False)


    nameLab = fields.Many2one(
        string='Lab',
        comodel_name='medical.lab.patient',
        required=True,
        ondelete='cascade',
    )

    patient_id= fields.Many2one(
        'medical.patient',
        string='patient',
         related='nameLab.patient_id',
         readonly=True,
        required=True,
    )

class labinvoice (models.Model):
    _name = "lab.invoice"
    name = fields.Char(string='Invoice Reference',  default=lambda self: _('New'), store=True)
    order_line = fields.One2many('lab.order.line', 'order_id', string='Order Lines', copy=True,  )  
    nameLab = fields.Many2one('medical.lab.patient',related='order_line.nameLab',string='name Lab', store=True)
    patient_id = fields.Many2one('medical.patient',related='order_line.patient',string='name Patient', store=True, readonly=True )

I think the problem is with the One2many field

Upvotes: 2

Views: 592

Answers (2)

weinni2000
weinni2000

Reputation: 51

I had a similar problem, check if you have or had a field including the field name "active". By default it doesn't show fields not active.

Upvotes: 0

Charif DZ
Charif DZ

Reputation: 14721

One of the things that I had is maybe you have used a domain in the window action and afterwards, you removed the domain from the action.

Removing the domain line from your code will not remove the domain from the action in the database.

So if you defined a domain to remove you should use this

   <field name="domain">[]</field>

Same thing for context or any other field.

Hope this helps you

Upvotes: 3

Related Questions