mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-23 05:22:08 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
41
odoo-bringout-oca-ocb-account/account/models/kpi_provider.py
Normal file
41
odoo-bringout-oca-ocb-account/account/models/kpi_provider.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class KpiProvider(models.AbstractModel):
|
||||
_inherit = 'kpi.provider'
|
||||
|
||||
@api.model
|
||||
def get_account_kpi_summary(self):
|
||||
grouped_moves_to_report = self.env['account.move']._read_group(
|
||||
fields.Domain.OR([
|
||||
[('state', '=', 'draft')],
|
||||
[('state', '=', 'posted'), ('checked', '=', False)],
|
||||
[('state', '=', 'posted'), ('journal_id.type', '=', 'bank'), ('statement_line_id.is_reconciled', '=', False)],
|
||||
]),
|
||||
['journal_id'],
|
||||
['journal_id:count'],
|
||||
)
|
||||
|
||||
FieldsSelection = self.env['ir.model.fields.selection'].with_context(lang=self.env.user.lang)
|
||||
journal_type_names = {x.value: x.name for x in FieldsSelection.search([
|
||||
('field_id.model', '=', 'account.journal'),
|
||||
('field_id.name', '=', 'type'),
|
||||
])}
|
||||
|
||||
count_by_type = {}
|
||||
for journal_id, count in grouped_moves_to_report:
|
||||
journal_type = journal_id.type
|
||||
count_by_type[journal_type] = count_by_type.get(journal_type, 0) + count
|
||||
|
||||
return [{
|
||||
'id': f'account_journal_type.{journal_type}',
|
||||
'name': journal_type_names[journal_type],
|
||||
'type': 'integer',
|
||||
'value': count,
|
||||
} for journal_type, count in count_by_type.items()]
|
||||
|
||||
@api.model
|
||||
def get_kpi_summary(self):
|
||||
result = super().get_kpi_summary()
|
||||
result.extend(self.get_account_kpi_summary())
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue