diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py index ffaee73..d29cff4 100755 --- a/project_report/report/project_budget_hrs_analysis.py +++ b/project_report/report/project_budget_hrs_analysis.py @@ -15,8 +15,7 @@ class BudgetHrsAnalysis(models.Model): project_id = fields.Many2one('project.project', string='Project', readonly=True) partner_id = fields.Many2one('res.partner', string='Client', readonly=True) employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True) - project_budgeted_hours = fields.Float("Project Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum") - cons_budgeted_hours = fields.Float("Consultant Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum") + budgeted_hours = fields.Float("Budgeted Hours", digits=(16, 2), readonly=True, group_operator="sum") actual_hours = fields.Float("Actual Hours", digits=(16, 2), readonly=True, group_operator="sum") def init(self): @@ -25,19 +24,21 @@ class BudgetHrsAnalysis(models.Model): self._cr.execute(""" CREATE OR REPLACE VIEW %s AS ( SELECT row_number() OVER() AS id, - Pro.id AS project_id, - Pro.partner_id AS partner_id, - Pro_emp.budgeted_qty AS cons_budgeted_hours, - Pro.budgeted_hours AS project_budgeted_hours, - AAL.employee_id as employee_id, + PRO.id AS project_id, + PRO.partner_id AS partner_id, + AAL.employee_id AS employee_id, + CASE + WHEN Pro_emp.id is null THEN Pro.budgeted_hours + ELSE Pro_emp.budgeted_qty + END AS budgeted_hours, sum(AAL.unit_amount) AS actual_hours - from project_project Pro - left JOIN project_sale_line_employee_map Pro_emp ON Pro_emp.project_id = Pro.id + FROM project_project PRO + Left JOIN project_sale_line_employee_map Pro_emp ON Pro_emp.project_id = Pro.id LEFT JOIN account_analytic_account AA ON Pro.analytic_account_id = AA.id LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = Pro.id and AAL.employee_id = Pro_emp.employee_id Where PRO.active = 't' - group by Pro.id, PRO.partner_id, AAL.employee_id, AAL.unit_amount, PRO.budgeted_hours, Pro_emp.budgeted_qty + group by Pro.id, Pro_emp.id, PRO.partner_id, AAL.employee_id, AAL.unit_amount )""" % (self._table,)) diff --git a/project_report/report/project_budget_hrs_analysis_views.xml b/project_report/report/project_budget_hrs_analysis_views.xml index 44a0a52..ae29b1e 100755 --- a/project_report/report/project_budget_hrs_analysis_views.xml +++ b/project_report/report/project_budget_hrs_analysis_views.xml @@ -7,7 +7,7 @@ - + @@ -18,7 +18,7 @@ project.budget.hrs.report - +