Search code examples
pythonodooodoo-13

Trying to limit One2Many field to only records of the same company


Basically, I want to put a domain on this field:

   line_ids = fields.One2many(
        "hr.payslip.line",
        "slip_id",
        string="Payslip Lines",
        readonly=True,
        domain=[("company_id", "=", self.company_id.id)],
    )

But I'm getting:

 domain=[("company_id", "=", self.company_id.id)],
NameError: name 'self' is not defined

Solution

  • I figured Odoo have a perfect solution for this, the attribute: check_company=True