diff --git a/project_report/report/project_budget_amt_analysis.py b/project_report/report/project_budget_amt_analysis.py index 70b411c..b304e68 100755 --- a/project_report/report/project_budget_amt_analysis.py +++ b/project_report/report/project_budget_amt_analysis.py @@ -32,6 +32,10 @@ class BudgetAmtAnalysis(models.Model): end_date = fields.Date(string='End Date', readonly=True) timesheet_date = fields.Date(string='Timesheet Date', readonly=True) timesheet_sdatetime = fields.Datetime(string='Timesheet Start Time', readonly=True) + unit_amount = fields.Float('Timesheet Hours') + timesheet_cost = fields.Float('Timesheet Cost') + profit_per = fields.Float(string='Porfit Percentage', digits=(16, 2)) + profit_amt = fields.Float(string='Profit Amount', digits=(16, 2)) #budgeted_revenue = fields.Float("Budgeted Revenue", digits=(16, 2), readonly=True, group_operator="sum") #actual_revenue = fields.Float("Actual Revenue", digits=(16, 2), readonly=True, group_operator="sum") @@ -40,7 +44,9 @@ class BudgetAmtAnalysis(models.Model): tools.drop_view_if_exists(self._cr, self._table) self._cr.execute(""" CREATE OR REPLACE VIEW %s AS ( - SELECT ROW_NUMBER() OVER() as id, project_id, parentproject as parent_project, start_date, end_date, timesheet_date, timesheet_sdatetime, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from ( + SELECT ROW_NUMBER() OVER() as id, project_id, parentproject as parent_project, + start_date, end_date, timesheet_date, timesheet_sdatetime, unit_amount, timesheet_cost, partner_id, employee_id, amount_type, + profit_per, profit_amt, pricing_type, project_type, revenue from ( SELECT pro.id AS project_id, (select project_id from project_subproject_rel as par where pro.id=par.id limit 1) as parentproject, @@ -49,10 +55,14 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, pro_emp.employee_id AS employee_id, 'Budgeted Revenue' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, null::date AS timesheet_date, null::timestamp AS timesheet_sdatetime, + 0.0 as unit_amount, + 0.0 as timesheet_cost, pro_emp.cost AS revenue FROM project_project pro Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id @@ -66,18 +76,23 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, AAL.employee_id AS employee_id, 'Actual Cost' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, AAL.date AS timesheet_date, AAL.start_datetime AS timesheet_sdatetime, - (sum(AAL.unit_amount) * pro_emp.employee_price) AS revenue + AAL.unit_amount as unit_amount, + emp.timesheet_cost as timesheet_cost, + (AAL.unit_amount * pro_emp.employee_price) AS revenue 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 + LEFT JOIN hr_employee emp on AAL.employee_id = emp.id WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate' and PRO.project_type in ('hours_in_consultant', 'hours_no_limit') - group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.employee_price + --group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.employee_price, AAL.unit_amount union SELECT pro.id AS project_id, @@ -87,16 +102,21 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, AAL.employee_id AS employee_id, 'Actual Revenue' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, AAL.date AS timesheet_date, AAL.start_datetime AS timesheet_sdatetime, - (sum(AAL.unit_amount) * pro.hourly_rate) AS revenue + AAL.unit_amount as unit_amount, + emp.timesheet_cost as timesheet_cost, + (AAL.unit_amount * pro.hourly_rate) AS revenue FROM project_project PRO 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 + LEFT JOIN hr_employee emp on AAL.employee_id = emp.id WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_no_limit' - group by pro.id, aal.employee_id, aal.date, aal.unit_amount, aal.start_datetime + --group by pro.id, aal.employee_id, aal.date, aal.unit_amount, aal.start_datetime, AAL.unit_amount union SELECT pro.id AS project_id, @@ -106,10 +126,14 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, null::int AS employee_id, 'Budgeted Revenue' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, null::date AS timesheet_date, null::timestamp AS timesheet_sdatetime, + 0.0 as unit_amount, + 0.0 as timesheet_cost, pro.budgeted_revenue AS revenue FROM project_project pro --Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id @@ -123,17 +147,22 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, AAL.employee_id AS employee_id, 'Actual Revenue' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, AAL.date AS timesheet_date, AAL.start_datetime AS timesheet_sdatetime, - (sum(AAL.unit_amount) * pro_emp.price_unit) AS revenue + AAL.unit_amount as unit_amount, + emp.timesheet_cost as timesheet_cost, + (AAL.unit_amount * pro_emp.price_unit) AS revenue 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 + LEFT JOIN hr_employee emp on AAL.employee_id = emp.id WHERE PRO.active = 't' and AAL.employee_id is not null and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant' - group by pro.id, aal.employee_id, aal.date, aal.start_datetime, pro_emp.price_unit + --group by pro.id, aal.employee_id, aal.date, aal.start_datetime, AAL.unit_amount, pro_emp.price_unit union SELECT pro.id AS project_id, @@ -143,14 +172,19 @@ class BudgetAmtAnalysis(models.Model): pro.partner_id AS partner_id, AAL.employee_id AS employee_id, 'Actual Cost' as amount_type, + pro.profit_per, + pro.profit_amt, pro.pricing_type as pricing_type, pro.project_type as project_type, AAL.date AS timesheet_date, AAL.start_datetime AS timesheet_sdatetime, + AAL.unit_amount as unit_amount, + emp.timesheet_cost as timesheet_cost, (AAL.amount * -1) AS revenue FROM project_project PRO 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 + LEFT JOIN hr_employee emp on AAL.employee_id = emp.id --and AAL.employee_id = pro_emp.employee_id WHERE PRO.active = 't' and PRO.pricing_type = 'fixed_rate') as res diff --git a/project_report/report/project_budget_amt_analysis_views.xml b/project_report/report/project_budget_amt_analysis_views.xml index 2ae84af..49a75be 100755 --- a/project_report/report/project_budget_amt_analysis_views.xml +++ b/project_report/report/project_budget_amt_analysis_views.xml @@ -6,8 +6,9 @@ project.budget.amt.report - - + + + @@ -19,9 +20,7 @@ - - - + @@ -36,6 +35,7 @@ + @@ -80,6 +80,7 @@ project.budget.amt.report graph,tree,pivot + {'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report', 'search_default_notfixed':1}