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

Module: Expenses

Entity: hr.expense

Compute Method: _compute_nb_attachment

Inputs Method Outputs
attachment_data = self.env['ir.attachment']._read_group(
            [('res_model', '=', 'hr.expense'), ('res_id', 'in', self.ids)],
            ['res_id'],
            ['__count'],
        )
attachment = dict(attachment_data)
for expense in self:
            expense.nb_attachment = attachment.get(expense._origin.id, 0)

Back to entity