"""QWeb PDF: migration audit report for fusion_accounting_assets.""" from odoo import api, models class FusionAssetsMigrationAuditReport(models.AbstractModel): _name = "report.fusion_accounting_assets.migration_audit_template" _description = "Fusion Assets Migration Audit" @api.model def _get_report_values(self, docids, data=None): wizards = self.env['fusion.migration.wizard'].browse(docids) if docids else self.env['fusion.migration.wizard'] Asset = self.env['fusion.asset'] company_stats = [] for company in self.env['res.company'].search([]): assets = Asset.search([('company_id', '=', company.id)]) by_state = {} for state in ('draft', 'running', 'paused', 'disposed'): by_state[state] = sum(1 for a in assets if a.state == state) total_cost = sum(a.cost for a in assets) total_book = sum(a.book_value for a in assets) total_dep = sum(a.total_depreciated for a in assets) company_stats.append({ 'company': company, 'count': len(assets), 'by_state': by_state, 'total_cost': total_cost, 'total_book_value': total_book, 'total_depreciated': total_dep, }) return { 'doc_ids': docids, 'doc_model': 'fusion.migration.wizard', 'docs': wizards, 'company_stats': company_stats, }