Report updated based on consultant allocated
This commit is contained in:
parent
e5b3900d63
commit
bec7b95d0b
|
@ -15,6 +15,7 @@
|
|||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/project_create_expenses_views.xml',
|
||||
'views/assets.xml',
|
||||
#'views/project_view.xml',
|
||||
'report/project_budget_hrs_analysis_views.xml',
|
||||
'report/project_budget_amt_analysis_views.xml',
|
||||
|
|
|
@ -13,14 +13,16 @@ class BudgetHrsAnalysis(models.Model):
|
|||
|
||||
#analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', readonly=True)
|
||||
project_id = fields.Many2one('project.project', string='Project', readonly=True)
|
||||
start_date = fields.Date(string='Start Date', readonly=True)
|
||||
end_date = fields.Date(string='End Date', readonly=True)
|
||||
partner_id = fields.Many2one('res.partner', string='Client', readonly=True)
|
||||
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")
|
||||
|
@ -30,36 +32,20 @@ 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, project_type, hours from (
|
||||
SELECT ROW_NUMBER() OVER() as id, project_id, start_date, end_date, partner_id, employee_id, hours_type,
|
||||
hours from (
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_date,
|
||||
Pro_emp_hours.start_date AS start_date,
|
||||
Pro_emp_hours.end_date AS end_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
null::int AS employee_id,
|
||||
Pro_emp_hours.employee_id AS employee_id,
|
||||
'Budgeted Hours' as hours_type,
|
||||
PRO.project_type as project_type,
|
||||
PRO.budgeted_hours AS hours
|
||||
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'
|
||||
and 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 Hours' as hours_type,
|
||||
PRO.project_type as project_type,
|
||||
Pro_emp.budgeted_qty as hours
|
||||
Pro_emp_hours.budgeted_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
|
||||
|
@ -70,29 +56,23 @@ class BudgetHrsAnalysis(models.Model):
|
|||
Union
|
||||
SELECT
|
||||
PRO.id AS project_id,
|
||||
PRO.create_date AS create_date,
|
||||
Pro_emp_hours.start_date AS start_date,
|
||||
Pro_emp_hours.end_date AS end_date,
|
||||
PRO.partner_id AS partner_id,
|
||||
AAL.employee_id AS employee_id,
|
||||
Pro_emp_hours.employee_id AS employee_id,
|
||||
'Actual Hours' as hours_type,
|
||||
PRO.project_type as project_type,
|
||||
AAL.unit_amount AS hours
|
||||
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
|
||||
--and AAL.employee_id = Pro_emp.employee_id
|
||||
Where
|
||||
PRO.active = 't'
|
||||
and PRO.pricing_type != 'fixed_rate'
|
||||
group by
|
||||
Pro.id,
|
||||
--Pro_emp.id,
|
||||
--PRO.partner_id,
|
||||
AAL.employee_id,
|
||||
AAL.unit_amount,
|
||||
hours_type
|
||||
and PRO.project_type = 'hours_in_consultant'
|
||||
) as res
|
||||
order by
|
||||
project_id desc,
|
||||
|
|
|
@ -34,12 +34,14 @@
|
|||
<field name="project_id"/>
|
||||
<field name="partner_id" filter_domain="[('partner_id', 'child_of', self)]"/>
|
||||
<field name="employee_id"/>
|
||||
<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="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')]"/>-->
|
||||
<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'}"/>
|
||||
<filter string="Consultant" name="group_by_employee_id" context="{'group_by':'employee_id'}"/>
|
||||
<filter string="Start Date" name="sdate" domain="[]" context="{'group_by':'start_date'}"/>
|
||||
<filter string="End Date" name="edate" domain="[]" context="{'group_by':'end_date'}"/>
|
||||
<filter string="Hours type" name="group_by_hours_type" context="{'group_by':'hours_type'}"/>
|
||||
</group>
|
||||
</search>
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
odoo.define("project_report.GraphRenderer", function(require) {
|
||||
var GraphRenderer = require("web.GraphRenderer");
|
||||
var config = require("web.config");
|
||||
var field_utils = require("web.field_utils");
|
||||
|
||||
// Hide top legend when too many items for device size
|
||||
var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
|
||||
|
||||
GraphRenderer.include({
|
||||
init: function(parent, state, params) {
|
||||
this._super.apply(this, arguments);
|
||||
console.log("Dataset Name", this);
|
||||
this.title = 'Time line'
|
||||
if (this.params && this.params.title) {
|
||||
this.params.title = '111Time line'
|
||||
}
|
||||
console.log("Module Name", arguments);
|
||||
console.log("this parent", parent);
|
||||
console.log("this state", state);
|
||||
console.log("this params", params);
|
||||
},
|
||||
|
||||
_getElementOptions: function () {
|
||||
var animationOptions = {};
|
||||
if (this.state.mode === 'bar') {
|
||||
var animationOptions = {
|
||||
duration: "0.1",
|
||||
"onComplete": function() {
|
||||
var chartInstance = this.chart,
|
||||
ctx = chartInstance.ctx;
|
||||
ctx.font = Chart.helpers.fontString(12, 'bold', "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif");
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'bottom';
|
||||
this.data.datasets.forEach(function(dataset, i) {
|
||||
var meta = chartInstance.controller.getDatasetMeta(i);
|
||||
meta.data.forEach(function(bar, index) {
|
||||
var data = dataset.data[index];
|
||||
if(!!data){
|
||||
ctx.fillText(data, bar._model.x, bar._model.y - 5);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
return animationOptions;
|
||||
},
|
||||
|
||||
_prepareOptions: function (datasetsCount) {
|
||||
const options = {
|
||||
maintainAspectRatio: false,
|
||||
scales: this._getScaleOptions(),
|
||||
legend: this._getLegendOptions(datasetsCount),
|
||||
tooltips: this._getTooltipOptions(),
|
||||
elements: this._getElementOptions(),
|
||||
animation: this._getElementOptions(),
|
||||
};
|
||||
if (this._isRedirectionEnabled()) {
|
||||
options.onClick = this._onGraphClicked.bind(this);
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
_renderBarChart: function (dataPoints) {
|
||||
var self = this;
|
||||
|
||||
// prepare data
|
||||
var data = this._prepareData(dataPoints);
|
||||
|
||||
data.datasets.forEach(function (dataset, index) {
|
||||
// used when stacked
|
||||
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined;
|
||||
// set dataset color
|
||||
var color = self._getColor(index);
|
||||
dataset.backgroundColor = color;
|
||||
});
|
||||
|
||||
// prepare options
|
||||
var options = this._prepareOptions(data.datasets.length);
|
||||
console.log("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr chart data>>>>>>>>>>>>>>>>", data)
|
||||
console.log("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr chart>>>>>>>>>>>>>>>>", options)
|
||||
console.log("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr chart>>>>>>>>>>>>>>>>", JSON.stringify(options))
|
||||
// create chart
|
||||
var ctx = document.getElementById(this.chartId);
|
||||
this.chart = new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: data,
|
||||
options: options,
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
|
||||
<template id="assets_backend" inherit_id="web.assets_backend" priority="99">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/project_report/static/src/js/graph_renderer.js" />
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
Loading…
Reference in New Issue