Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: HR Contract Document

Entity: hr.contract

Compute Method: _compute_document_ids

Inputs Method Outputs
IrAttachment = self.env["ir.attachment"]
attachments = IrAttachment.search(
            [("res_model", "=", self._name), ("res_id", "in", self.ids)]
        )
result = dict.fromkeys(self.ids, IrAttachment)
for attachment in attachments:
            result[attachment.res_id] |= attachment
for employee in self:
            employee.document_ids = result[employee.id]
            employee.documents_count = len(employee.document_ids)

Back to entity