From bf4c33620621b708133aa4865bc5c629a978841e Mon Sep 17 00:00:00 2001 From: projectsodoo Date: Mon, 11 Jan 2021 17:40:46 +0530 Subject: [PATCH] Report filter by options added --- .../report/project_budget_amt_analysis.py | 18 +++++++++++++++--- .../project_budget_amt_analysis_views.xml | 3 +++ .../report/project_budget_hrs_analysis.py | 9 ++++++++- .../project_budget_hrs_analysis_views.xml | 2 ++ 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/project_report/report/project_budget_amt_analysis.py b/project_report/report/project_budget_amt_analysis.py index a71caa4..0eafb06 100755 --- a/project_report/report/project_budget_amt_analysis.py +++ b/project_report/report/project_budget_amt_analysis.py @@ -16,6 +16,14 @@ class BudgetAmtAnalysis(models.Model): partner_id = fields.Many2one('res.partner', string='Client', readonly=True) amount_type = fields.Char(string="Amount Type") revenue = fields.Float("Revenue", digits=(16, 2), readonly=True, group_operator="sum") + project_type = fields.Selection([ + ('hours_in_consultant', 'Hours are budgeted according to a consultant'), + ('hours_no_limit', 'Total hours are budgeted without division to consultant'), + ], string="Project Type", readonly=True) + pricing_type = fields.Selection([ + ('fixed_rate', 'Fixed rate'), + ('employee_rate', 'Consultant rate') + ], string="Pricing", readonly=True) #employee_id = fields.Many2one('hr.employee', string='Employee', readonly=True) #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") @@ -25,19 +33,21 @@ 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, partner_id, amount_type, revenue from ( + SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, amount_type, pricing_type, project_type, revenue from ( SELECT row_number() OVER() AS id, PRO.id AS project_id, PRO.create_date AS create_date, PRO.partner_id AS partner_id, 'Budgeted Revenue' as amount_type, + PRO.pricing_type as pricing_type, + PRO.project_type as project_type, PRO.budgeted_revenue AS 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 and AAL.project_id = PRO.id - WHERE PRO.active = 't' and PRO.pricing_type!='fixed_rate' + WHERE PRO.active = 't' group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total union SELECT @@ -46,12 +56,14 @@ class BudgetAmtAnalysis(models.Model): PRO.create_date AS create_date, PRO.partner_id AS partner_id, 'Actual Revenue' as amount_type, + PRO.pricing_type as pricing_type, + PRO.project_type as project_type, pro.total_expenses AS 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 and AAL.project_id = PRO.id - WHERE PRO.active = 't' and PRO.pricing_type!='fixed_rate' + WHERE PRO.active = 't' group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, so.amount_total order by create_date desc, project_id, amount_type desc) as res )""" % (self._table,)) diff --git a/project_report/report/project_budget_amt_analysis_views.xml b/project_report/report/project_budget_amt_analysis_views.xml index 2374ae0..4f1ad1a 100755 --- a/project_report/report/project_budget_amt_analysis_views.xml +++ b/project_report/report/project_budget_amt_analysis_views.xml @@ -35,6 +35,9 @@ + + + diff --git a/project_report/report/project_budget_hrs_analysis.py b/project_report/report/project_budget_hrs_analysis.py index 4ca619d..cc4eb32 100755 --- a/project_report/report/project_budget_hrs_analysis.py +++ b/project_report/report/project_budget_hrs_analysis.py @@ -17,6 +17,10 @@ class BudgetHrsAnalysis(models.Model): employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) hours_type = fields.Char(string="Hours Type", readonly=True) hours = fields.Float("Hours", digits=(16, 2), readonly=True, group_operator="sum") + project_type = fields.Selection([ + ('hours_in_consultant', 'Hours are budgeted according to a consultant'), + ('hours_no_limit', 'Total hours are budgeted without division to consultant'), + ], string="Project Type", readonly=True) #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") @@ -26,13 +30,14 @@ class BudgetHrsAnalysis(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, partner_id, employee_id, hours_type, hours from ( + SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, employee_id, hours_type, project_type, hours from ( SELECT PRO.id AS project_id, PRO.create_date AS create_date, PRO.partner_id AS partner_id, null AS employee_id, 'Budgeted Hours' as hours_type, + PRO.project_type as project_type, PRO.budgeted_hours AS hours FROM project_project PRO @@ -50,6 +55,7 @@ class BudgetHrsAnalysis(models.Model): PRO.partner_id AS partner_id, Pro_emp.employee_id AS employee_id, 'Budgeted Hours' as hours_type, + PRO.project_type as project_type, Pro_emp.budgeted_qty as hours FROM project_project PRO @@ -68,6 +74,7 @@ class BudgetHrsAnalysis(models.Model): PRO.partner_id AS partner_id, AAL.employee_id AS employee_id, 'Actual Hours' as hours_type, + PRO.project_type as project_type, AAL.unit_amount AS hours FROM project_project PRO diff --git a/project_report/report/project_budget_hrs_analysis_views.xml b/project_report/report/project_budget_hrs_analysis_views.xml index 23ee61b..facf73e 100755 --- a/project_report/report/project_budget_hrs_analysis_views.xml +++ b/project_report/report/project_budget_hrs_analysis_views.xml @@ -34,6 +34,8 @@ + +