diff --git a/project_report/report/project_revenue_custom_report.py b/project_report/report/project_revenue_custom_report.py index 25a9a8f..8b4f5ca 100755 --- a/project_report/report/project_revenue_custom_report.py +++ b/project_report/report/project_revenue_custom_report.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import fields, models, tools - +from odoo import api, fields, models, tools class ProjectRevenueCustomReport(models.Model): @@ -223,4 +222,23 @@ class ProjectRevenueCustomReport(models.Model): ) res )""" % (self._table,)) + @api.model + def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True): + res = super(ProjectRevenueCustomReport, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy) + #print("resssssss", res) + #accounts = self.env['account.analytic.account'] + for line in res: + if 'unit_amount' in line and 'pro_hourly_rate' in line and 'id' in line: + line['actual_revenue'] = line['pro_hourly_rate'] * line['unit_amount'] + if 'unit_amount' in line and 'timesheet_cost' in line and 'id' in line: + line['actual_cost'] = line['timesheet_cost'] * line['unit_amount'] + if 'overall_budgeted_revenue' in line and 'budgeted_hours' in line and 'id' in line: + if line['budgeted_hours'] > 0: + line['overall_hourly_rate'] = line['overall_budgeted_revenue'] / line['budgeted_hours'] + if 'pro_hourly_rate' in line and 'budgeted_hours' in line and 'id' in line: + if line['budgeted_hours'] > 0: + line['pro_hourly_rate'] = line['budgeted_revenue'] / line['budgeted_hours'] + if 'actual_revenue' in line and 'actual_cost' in line and 'expenses_amt' in line and 'id' in line: + line['profit_amt'] = line['actual_revenue'] - line['actual_cost'] - line['expenses_amt'] + return res