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_same_receipt_expense_ids
| Inputs | Method | Outputs |
|---|---|---|
|
+ self.same_receipt_expense_ids = [Command.clear()] + expenses_with_attachments = self.filtered(lambda expense: expense.attachment_ids) + if not expenses_with_attachments: + return + expenses_groupby_checksum = dict(self.env['ir.attachment']._read_group(domain=[ + ('res_model', '=', 'hr.expense'), + ('checksum', 'in', expenses_with_attachments.attachment_ids.mapped('checksum'))], + groupby=['checksum'], + aggregates=['res_id:array_agg'], + )) + for expense in expenses_with_attachments: + same_receipt_ids = set() + for attachment in expense.attachment_ids: + same_receipt_ids.update(expenses_groupby_checksum[attachment.checksum]) + same_receipt_ids.remove(expense.id) + + expense.same_receipt_expense_ids = [Command.set(list(same_receipt_ids))] |
|
