Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.
Module: Project Expenses
Entity: project.project
Compute Method: _compute_expenses_count
| Inputs | Method | Outputs |
|---|---|---|
|
- if not self.analytic_account_id: - self.expenses_count = 0 - return - query = self.env['hr.expense']._search([]) - query.add_where( - SQL( - "%s && %s", - [str(account_id) for account_id in self.analytic_account_id.ids], - self.env['hr.expense']._query_analytic_accounts(), - ) - ) - query_string, query_param = query.select( - r"""DISTINCT id, (regexp_matches(jsonb_object_keys(hr_expense.analytic_distribution), '\d+', 'g'))[1]::int as account_id""" - ) - query_string = f""" - SELECT account_id, count(id) FROM - ({query_string}) distribution - GROUP BY account_id - """ - self._cr.execute(query_string, query_param) - data = {res['account_id']: res['count'] for res in self._cr.dictfetchall()} - for project in self: - project.expenses_count = data.get(project.analytic_account_id.id, 0) |
|
