diff --git a/project_report/report/project_budget_amt_analysis.py b/project_report/report/project_budget_amt_analysis.py index 5c42a29..35a5b26 100755 --- a/project_report/report/project_budget_amt_analysis.py +++ b/project_report/report/project_budget_amt_analysis.py @@ -23,19 +23,18 @@ class BudgetAmtAnalysis(models.Model): tools.drop_view_if_exists(self._cr, self._table) self._cr.execute(""" CREATE OR REPLACE VIEW %s AS ( - SELECT min(AAL.id) as id, + SELECT + row_number() OVER() AS id, PRO.id AS project_id, PRO.partner_id AS partner_id, AAL.employee_id AS employee_id, PRO.budgeted_revenue AS budgeted_revenue, SO.amount_total AS actual_revenue - --sum(AAL.amount) AS budgeted_revenue - --sum(-1 * AAL.amount) AS actual_revenue FROM project_project PRO LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.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 - WHERE AAL.amount < 0.0 AND AAL.project_id IS NOT NULL AND PRO.active = 't' AND PRO.allow_timesheets = 't' + LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id + WHERE PRO.active = 't' AND PRO.allow_timesheets = 't' group by Pro.id, PRO.partner_id, AAL.employee_id, Pro.budgeted_revenue, so.amount_total )""" % (self._table,)) diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py index 2dd44ba..d5fbdb6 100755 --- a/project_report/report/project_budget_hrs_analysis.py +++ b/project_report/report/project_budget_hrs_analysis.py @@ -23,19 +23,17 @@ class BudgetHrsAnalysis(models.Model): tools.drop_view_if_exists(self._cr, self._table) self._cr.execute(""" CREATE OR REPLACE VIEW %s AS ( - SELECT min(AAL.id) as id, + SELECT row_number() OVER() AS id, PRO.id AS project_id, PRO.partner_id AS partner_id, AAL.employee_id AS employee_id, - --sum(SOL.product_uom_qty) As budgeted_hours, PRO.budgeted_hours AS budgeted_hours, sum(AAL.unit_amount) AS actual_hours FROM project_project PRO - --LEFT JOIN sale_order_line SOL ON PRO.sale_line_id = SOL.id - --LEFT JOIN sale_order SO ON PRO.sale_order_id = SO.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 - WHERE AAL.amount < 0.0 AND AAL.project_id IS NOT NULL AND PRO.active = 't' AND PRO.allow_timesheets = 't' + LEFT JOIN account_analytic_line AAL ON AAL.account_id = AA.id and AAL.project_id = PRO.id + --WHERE AAL.amount < 0.0 AND AAL.project_id IS NOT NULL AND + Where PRO.active = 't' AND PRO.allow_timesheets = 't' group by Pro.id, PRO.partner_id, AAL.employee_id, AAL.unit_amount,PRO.budgeted_hours )""" % (self._table,))