Updated bar chart related reports
This commit is contained in:
parent
2b1f7b4443
commit
a5f43f8090
|
@ -3,4 +3,4 @@
|
|||
from . import controllers
|
||||
from . import models
|
||||
from . import wizard
|
||||
#from . import report
|
||||
from . import report
|
|
@ -33,6 +33,7 @@
|
|||
'views/hr_employee_views.xml',
|
||||
'views/hr_timesheet_templates.xml',
|
||||
'views/analytic_view.xml',
|
||||
'report/project_hours_report_view.xml',
|
||||
'report/project_profitability_report_analysis_views.xml',
|
||||
'views/views.xml',
|
||||
'views/templates.xml',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import project_profitability_report_analysis
|
||||
#from . import project_profitability_report_analysis
|
||||
from . import project_hours_report
|
||||
|
|
|
@ -7,4 +7,6 @@ access_project_consultant_hrs_pmanager,project.consultant.hrs,model_project_cons
|
|||
access_model_project_multi_budget_assign_puser,project.multi.budget.assign,model_project_multi_budget_assign,project.group_project_user,1,0,0,0
|
||||
access_model_project_multi_budget_assign_pmanager,project.multi.budget.assign,model_project_multi_budget_assign,project.group_project_manager,1,1,1,1
|
||||
access_model_project_multi_budget_assign_line_puser,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_user,1,0,0,0
|
||||
access_model_project_multi_budget_assign_line_pmanager,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_manager,1,1,1,1
|
||||
access_model_project_multi_budget_assign_line_pmanager,project.multi.budget.assign.line,model_project_multi_budget_assign_line,project.group_project_manager,1,1,1,1
|
||||
access_project_consultant_hrs_report_puser,project.consultant.hrs.report,model_project_consultant_hrs_report,project.group_project_user,1,0,0,0
|
||||
access_project_consultant_hrs_report_pmanager,project.consultant.hrs.report,model_project_consultant_hrs_report,project.group_project_manager,1,1,1,1
|
|
|
@ -63,7 +63,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="project_consul_hours_view_form" model="ir.ui.view">
|
||||
<field name="name">Project Consul Hours</field>
|
||||
<field name="model">project.project</field>
|
||||
|
|
|
@ -35,62 +35,50 @@ class BudgetAmtAnalysis(models.Model):
|
|||
CREATE OR REPLACE VIEW %s AS (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, partner_id, employee_id, amount_type, pricing_type, project_type, revenue from (
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
null::int AS employee_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
|
||||
WHERE PRO.active = 't'
|
||||
--and (PRO.pricing_type = 'fixed_rate' OR PRO.project_type = 'hours_no_limit')
|
||||
--union
|
||||
--SELECT
|
||||
--PRO.id AS project_id,
|
||||
--PRO.create_date AS create_date,
|
||||
--PRO.partner_id AS partner_id,
|
||||
--Pro_emp.employee_id AS employee_id,
|
||||
--'Budgeted Revenue' as amount_type,
|
||||
--PRO.pricing_type as pricing_type,
|
||||
--PRO.project_type as project_type,
|
||||
--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
|
||||
--WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
|
||||
--union
|
||||
--SELECT
|
||||
--PRO.id AS project_id,
|
||||
--PRO.create_date AS create_date,
|
||||
--PRO.partner_id AS partner_id,
|
||||
--AAL.employee_id AS employee_id,
|
||||
--'Actual Revenue' as amount_type,
|
||||
--PRO.pricing_type as pricing_type,
|
||||
--PRO.project_type as project_type,
|
||||
--(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
|
||||
--WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
|
||||
union
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
null::int AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
PRO.pricing_type as pricing_type,
|
||||
PRO.project_type as project_type,
|
||||
--(AAL.amount * -1) + pro.expenses_amt AS revenue
|
||||
pro.total_expenses 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
|
||||
WHERE PRO.active = 't'
|
||||
--and (PRO.pricing_type = 'fixed_rate' OR PRO.project_type = 'hours_no_limit')
|
||||
group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, AAL.amount
|
||||
order by create_date desc, project_id, amount_type desc) as res
|
||||
pro.id AS project_id,
|
||||
pro.partner_id AS partner_id,
|
||||
pro_emp.employee_id AS employee_id,
|
||||
'Budgeted Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
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
|
||||
WHERE PRO.active = 't' and pro.pricing_type = 'employee_rate' and pro.project_type = 'hours_in_consultant'
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Revenue' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
(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
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant'
|
||||
union
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Cost' as amount_type,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
(AAL.amount * -1) AS revenue
|
||||
--(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
|
||||
WHERE PRO.active = 't' and PRO.pricing_type = 'employee_rate' and PRO.project_type = 'hours_in_consultant')
|
||||
as res
|
||||
order by
|
||||
project_id,
|
||||
amount_type desc
|
||||
--group by Pro.id, PRO.partner_id, Pro.budgeted_revenue, AAL.amount
|
||||
)""" % (self._table,))
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models, tools
|
||||
from odoo import fields, models, tools, api
|
||||
|
||||
|
||||
class BudgetHrsAnalysis(models.Model):
|
||||
|
@ -19,56 +19,75 @@ 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)
|
||||
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")
|
||||
|
||||
@api.model
|
||||
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", 'hours_type' not in groupby)
|
||||
if 'hours_type' not in groupby:
|
||||
groupby.append('hours_type')
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", groupby, orderby)
|
||||
"""fields.remove('on_time_rate')
|
||||
if 'qty_total' not in fields:
|
||||
fields.append('qty_total')
|
||||
if 'qty_on_time' not in fields:
|
||||
fields.append('qty_on_time')
|
||||
res = super().read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
|
||||
for group in res:
|
||||
if group['qty_total'] == 0:
|
||||
on_time_rate = 100
|
||||
else:
|
||||
on_time_rate = group['qty_on_time'] / group['qty_total'] * 100
|
||||
group.update({'on_time_rate': on_time_rate}"""
|
||||
print("rrr>>>>>>>>>>>>>>>>>>>>>>>>>.", groupby, orderby)
|
||||
res = super().read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
|
||||
print("Res", res)
|
||||
return res
|
||||
|
||||
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, project_id, start_date, end_date, partner_id, employee_id, hours_type,
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, start_date, end_date, pricing_type, project_type, partner_id, employee_id, hours_type,
|
||||
hours from (
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
Pro_emp_hours.start_date AS start_date,
|
||||
Pro_emp_hours.end_date AS end_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
Pro_emp_hours.employee_id AS employee_id,
|
||||
SELECT
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
pro.partner_id AS partner_id,
|
||||
pro_emp.employee_id AS employee_id,
|
||||
'Budgeted Hours' as hours_type,
|
||||
Pro_emp_hours.budgeted_hours as hours
|
||||
pro_emp.budgeted_qty as hours
|
||||
FROM
|
||||
project_project PRO
|
||||
Left JOIN project_sale_line_employee_map Pro_emp ON Pro_emp.project_id = Pro.id
|
||||
Left JOIN project_consultant_hrs Pro_emp_hours ON Pro_emp_hours.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
|
||||
Left JOIN project_sale_line_employee_map pro_emp ON pro_emp.project_id = pro.id
|
||||
Where
|
||||
PRO.active = 't'
|
||||
pro.active = 't'
|
||||
and PRO.pricing_type != 'fixed_rate'
|
||||
and PRO.project_type = 'hours_in_consultant'
|
||||
Union
|
||||
Union
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
Pro_emp_hours.start_date AS start_date,
|
||||
Pro_emp_hours.end_date AS end_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
Pro_emp_hours.employee_id AS employee_id,
|
||||
'Actual Hours' as hours_type,
|
||||
Pro_emp_hours.actual_hours AS hours
|
||||
FROM
|
||||
project_project PRO
|
||||
Left JOIN project_sale_line_employee_map Pro_emp ON Pro_emp.project_id = Pro.id
|
||||
Left JOIN project_consultant_hrs Pro_emp_hours ON Pro_emp_hours.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
|
||||
pro.id AS project_id,
|
||||
pro.date_start AS start_date,
|
||||
pro.date AS end_date,
|
||||
pro.pricing_type as pricing_type,
|
||||
pro.project_type as project_type,
|
||||
pro.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
'Actual Hours' as hours_type,
|
||||
unit_amount as hours
|
||||
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'
|
||||
and PRO.pricing_type != 'fixed_rate'
|
||||
|
@ -76,6 +95,10 @@ class BudgetHrsAnalysis(models.Model):
|
|||
) as res
|
||||
order by
|
||||
project_id desc,
|
||||
start_date,
|
||||
end_date,
|
||||
pricing_type,
|
||||
project_type,
|
||||
hours_type asc,
|
||||
employee_id
|
||||
)""" % (self._table,))
|
||||
|
|
|
@ -25,6 +25,21 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="project_budget_hrs_report_view_tree" model="ir.ui.view">
|
||||
<field name="name">project.budget.hrs.report.tree</field>
|
||||
<field name="model">project.budget.hrs.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Budget Analysis" create="false" edit="false" delete="false">
|
||||
<field name="project_id"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="hours_type"/>
|
||||
<field name="hours"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="project_budget_hrs_report_view_search" model="ir.ui.view">
|
||||
<field name="name">project.budget.hrs.report.search</field>
|
||||
|
@ -34,8 +49,10 @@
|
|||
<field name="project_id"/>
|
||||
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<!--<filter string="Hours are budgeted according to a consultant" name="cons" domain="[('project_type','=','hours_in_consultant')]"/>
|
||||
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>-->
|
||||
<filter string="Total hours are budgeted without division to consultant" name="limit" domain="[('project_type','=','hours_no_limit')]"/>-->
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Project" name="group_by_project" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Client" name="group_by_partner_id" context="{'group_by':'partner_id'}"/>
|
||||
|
@ -52,9 +69,9 @@
|
|||
<field name="name">Projects Hours Acutal Vs Budget</field>
|
||||
<!--<field name="name">Projects Revenue Acutal Vs Budget</field>-->
|
||||
<field name="res_model">project.budget.hrs.report</field>
|
||||
<field name="view_mode">graph,pivot</field>
|
||||
<field name="view_mode">graph,tree,pivot</field>
|
||||
<field name="search_view_id" ref="project_budget_hrs_report_view_search"/>
|
||||
<field name="context">{'search_default_group_by_project': 1,'search_default_group_by_hours_type': 1}</field>
|
||||
<field name="context">{'search_default_group_by_project': 1,'search_default_group_by_hours_type': 1, 'default_res_model': 'project.budget.hrs.report'}</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_project_budget_report_hrs_analysis"
|
||||
|
|
|
@ -9,11 +9,17 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
|
|||
GraphRenderer.include({
|
||||
init: function(parent, state, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.context = state.context;
|
||||
this.resModel = this.context && this.context.default_res_model;
|
||||
console.log("this.resModel", this.resModel, this.context.default_res_model);
|
||||
//if (this.resModel == 'project.budget.hrs.report') {
|
||||
// this.title = 'Time Line';
|
||||
// }
|
||||
},
|
||||
|
||||
_animationOptions: function () {
|
||||
var animationOptions = {};
|
||||
if (this.state.mode === 'bar') {
|
||||
if (this.state.mode === 'bar' && this.resModel == 'project.budget.hrs.report') {
|
||||
var animationOptions = {
|
||||
duration: "0.1",
|
||||
"onComplete": function() {
|
||||
|
|
Loading…
Reference in New Issue