From 92ecd788598e2f62ba4c83618a58749b967765e6 Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Thu, 24 Mar 2022 18:55:13 +0530 Subject: [PATCH 1/3] add cor project report --- project_report/__manifest__.py | 1 + project_report/report/__init__.py | 2 + project_report/report/cor_project_report.py | 38 +++++++++++ .../report/cor_project_report_views.xml | 67 +++++++++++++++++++ project_report/security/ir.model.access.csv | 5 +- 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100755 project_report/report/cor_project_report.py create mode 100755 project_report/report/cor_project_report_views.xml diff --git a/project_report/__manifest__.py b/project_report/__manifest__.py index 8cae31e..2508add 100755 --- a/project_report/__manifest__.py +++ b/project_report/__manifest__.py @@ -21,6 +21,7 @@ 'report/project_budget_amt_analysis_views.xml', 'report/project_timeline_report_views.xml', 'report/project_timesheet_report_views.xml', + 'report/cor_project_report_views.xml', ], 'qweb': [ "static/src/xml/base.xml", diff --git a/project_report/report/__init__.py b/project_report/report/__init__.py index d635724..a5bbbb8 100755 --- a/project_report/report/__init__.py +++ b/project_report/report/__init__.py @@ -5,3 +5,5 @@ from . import project_budget_hrs_analysis from . import project_budget_amt_analysis from . import project_timeline_report from . import project_timesheet_report + +from . import cor_project_report diff --git a/project_report/report/cor_project_report.py b/project_report/report/cor_project_report.py new file mode 100755 index 0000000..aa3d722 --- /dev/null +++ b/project_report/report/cor_project_report.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, tools, api + + +class CorProjectReport(models.Model): + _name = "cor.project.report" + _description = "COR Project Report" + # _order = 'project_id' + _auto = False + + project_id = fields.Many2one('project.project', string='Project', readonly=True) + employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) + #hours_type = fields.Char(string="Hours Type", readonly=True) + hours = fields.Float("Number of Hours", digits=(16, 2), readonly=True, group_operator="sum") + # pricing_type = fields.Selection([ + # ('fixed_rate', 'Fixed rate'), + # ('employee_rate', 'Consultant rate') + # ], string="Pricing", readonly=True) + # 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) + + def init(self): + '''Create the view''' + tools.drop_view_if_exists(self._cr, self._table) + self._cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + SELECT ROW_NUMBER() OVER() as id, + aa.project_id AS project_id, + aa.employee_id AS employee_id, + SUM(aa.unit_amount) AS hours + FROM account_analytic_line aa + Left JOIN project_sale_line_employee_map bb ON bb.project_id = aa.project_id + GROUP BY aa.project_id, aa.employee_id, aa.amount + )""" % (self._table,)) diff --git a/project_report/report/cor_project_report_views.xml b/project_report/report/cor_project_report_views.xml new file mode 100755 index 0000000..841d9e0 --- /dev/null +++ b/project_report/report/cor_project_report_views.xml @@ -0,0 +1,67 @@ + + + + + cor.project.report.pivot + cor.project.report + + + + + + + + + + + cor.project.report.graph + cor.project.report + + + + + + + + + + + cor.project.report.tree + cor.project.report + + + + + + + + + + + + cor.project.report.search + cor.project.report + + + + + + + + + + + COR Project Report + cor.project.report + graph,tree,pivot + + {} + + + + + diff --git a/project_report/security/ir.model.access.csv b/project_report/security/ir.model.access.csv index d29c722..91fe871 100755 --- a/project_report/security/ir.model.access.csv +++ b/project_report/security/ir.model.access.csv @@ -8,4 +8,7 @@ access_project_create_expense_user,access_project_create_expense_project_user,mo access_project_timeline_report_manager,project.timeline.report,model_project_timeline_report,project.group_project_manager,1,1,1,1 access_project_timeline_report_user,project.timeline.report,model_project_timeline_report,project.group_project_user,1,0,0,0 access_project_timesheet_report_manager,project.timesheet.report,model_project_timesheet_report,project.group_project_manager,1,1,1,1 -access_project_timesheet_report_user,project.timesheet.report,model_project_timesheet_report,project.group_project_user,1,0,0,0 \ No newline at end of file +access_project_timesheet_report_user,project.timesheet.report,model_project_timesheet_report,project.group_project_user,1,0,0,0 + +access_cor_project_report_manager,cor.project.report,model_cor_project_report,project.group_project_manager,1,1,1,1 +access_cor_project_report_user,cor.project.report,model_cor_project_report,project.group_project_user,1,0,0,0 \ No newline at end of file From 53fc6ccd52ba6d47f13c1dbea73fef4ce5815de1 Mon Sep 17 00:00:00 2001 From: "pawan.sharma" Date: Fri, 25 Mar 2022 12:25:50 +0530 Subject: [PATCH 2/3] add changes in project --- project_report/report/cor_project_report.py | 16 +++++++++++++--- .../report/cor_project_report_views.xml | 11 +++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/project_report/report/cor_project_report.py b/project_report/report/cor_project_report.py index aa3d722..49e9112 100755 --- a/project_report/report/cor_project_report.py +++ b/project_report/report/cor_project_report.py @@ -13,7 +13,12 @@ class CorProjectReport(models.Model): project_id = fields.Many2one('project.project', string='Project', readonly=True) employee_id = fields.Many2one('hr.employee', string='Consultant', readonly=True) #hours_type = fields.Char(string="Hours Type", readonly=True) + price_unit = fields.Float("Hourly Rate") + budgeted_qty = fields.Float(string='Budgeted Hours', digits=(16, 2)) hours = fields.Float("Number of Hours", digits=(16, 2), readonly=True, group_operator="sum") + employee_price = fields.Float(string="Consultant Price") + consultant_cost = fields.Float("Actual Cost") + actual_revenue = fields.Float("Actual Revenue") # pricing_type = fields.Selection([ # ('fixed_rate', 'Fixed rate'), # ('employee_rate', 'Consultant rate') @@ -31,8 +36,13 @@ class CorProjectReport(models.Model): SELECT ROW_NUMBER() OVER() as id, aa.project_id AS project_id, aa.employee_id AS employee_id, - SUM(aa.unit_amount) AS hours + bb.price_unit AS price_unit, + bb.budgeted_qty AS budgeted_qty, + bb.employee_price AS employee_price, + SUM(aa.unit_amount) AS hours, + bb.consultant_cost AS consultant_cost FROM account_analytic_line aa - Left JOIN project_sale_line_employee_map bb ON bb.project_id = aa.project_id - GROUP BY aa.project_id, aa.employee_id, aa.amount + Left JOIN project_sale_line_employee_map bb ON bb.project_id = aa.project_id and bb.employee_id = aa.employee_id + where aa.project_id = 21 + GROUP BY aa.project_id, aa.employee_id,bb.price_unit,bb.budgeted_qty,bb.employee_price,bb.consultant_cost )""" % (self._table,)) diff --git a/project_report/report/cor_project_report_views.xml b/project_report/report/cor_project_report_views.xml index 841d9e0..8fb5459 100755 --- a/project_report/report/cor_project_report_views.xml +++ b/project_report/report/cor_project_report_views.xml @@ -32,7 +32,10 @@ + + + @@ -46,6 +49,10 @@ + + + + @@ -53,9 +60,9 @@ COR Project Report cor.project.report - graph,tree,pivot + tree,pivot,graph - {} + {'search_default_group_by_project': 1, 'default_res_model': 'cor.project.report'} Date: Fri, 25 Mar 2022 15:18:17 +0530 Subject: [PATCH 3/3] add changes in report --- project_report/report/cor_project_report.py | 14 ++++++++++---- project_report/report/cor_project_report_views.xml | 5 +++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/project_report/report/cor_project_report.py b/project_report/report/cor_project_report.py index 49e9112..6dcb1cc 100755 --- a/project_report/report/cor_project_report.py +++ b/project_report/report/cor_project_report.py @@ -15,10 +15,13 @@ class CorProjectReport(models.Model): #hours_type = fields.Char(string="Hours Type", readonly=True) price_unit = fields.Float("Hourly Rate") budgeted_qty = fields.Float(string='Budgeted Hours', digits=(16, 2)) - hours = fields.Float("Number of Hours", digits=(16, 2), readonly=True, group_operator="sum") + cost = fields.Float("Budgeted Revenue", default=0.0, store=True) + hours = fields.Float("Timesheet Hour", digits=(16, 2), readonly=True, group_operator="sum") employee_price = fields.Float(string="Consultant Price") consultant_cost = fields.Float("Actual Cost") actual_revenue = fields.Float("Actual Revenue") + profit = fields.Float('Profit', digits=(16, 2)) + profit_per = fields.Float('Porfit(%)', digits=(16, 2)) # pricing_type = fields.Selection([ # ('fixed_rate', 'Fixed rate'), # ('employee_rate', 'Consultant rate') @@ -38,11 +41,14 @@ class CorProjectReport(models.Model): aa.employee_id AS employee_id, bb.price_unit AS price_unit, bb.budgeted_qty AS budgeted_qty, + bb.cost AS cost, bb.employee_price AS employee_price, SUM(aa.unit_amount) AS hours, - bb.consultant_cost AS consultant_cost + (SUM(aa.unit_amount) * bb.employee_price) AS consultant_cost, + (SUM(aa.unit_amount) * bb.price_unit) AS actual_revenue, + ((SUM(aa.unit_amount) * bb.price_unit)- (SUM(aa.unit_amount) * bb.employee_price)) AS profit, + ((((SUM(aa.unit_amount) * bb.price_unit)- (SUM(aa.unit_amount) * bb.employee_price))/(SUM(aa.unit_amount) * bb.price_unit))*100) AS profit_per FROM account_analytic_line aa Left JOIN project_sale_line_employee_map bb ON bb.project_id = aa.project_id and bb.employee_id = aa.employee_id - where aa.project_id = 21 - GROUP BY aa.project_id, aa.employee_id,bb.price_unit,bb.budgeted_qty,bb.employee_price,bb.consultant_cost + GROUP BY aa.project_id, aa.employee_id,bb.price_unit,bb.budgeted_qty,bb.cost,bb.employee_price )""" % (self._table,)) diff --git a/project_report/report/cor_project_report_views.xml b/project_report/report/cor_project_report_views.xml index 8fb5459..3eefb93 100755 --- a/project_report/report/cor_project_report_views.xml +++ b/project_report/report/cor_project_report_views.xml @@ -34,8 +34,13 @@ + + + + +