Hide deadline Remdays field and bar 3 report color

This commit is contained in:
projectsodoo 2021-02-10 21:34:03 +05:30
parent f035a32b01
commit d04d067310
5 changed files with 238 additions and 45 deletions

View File

@ -75,6 +75,7 @@
'search_default_project': 1,
'search_default_consultant': 1,
'search_default_group_by_hours_type': 1,
'default_res_model': 'project.consultant.hrs.report'
}
</field>
</record>

View File

@ -208,6 +208,10 @@
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_tree2"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='date_deadline']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<field name="date_deadline" optional="hide" widget="remaining_days" attrs="{'invisible': [('is_closed', '=', True)]}"/>
<xpath expr="//field[@name='name']" position="before">
<field name="date_deadline"/>
</xpath>

View File

@ -79,7 +79,7 @@
<field name="res_model">project.budget.amt.report</field>
<field name="view_mode">graph,tree,pivot</field>
<field name="search_view_id" ref="project_budget_amt_report_view_search"/>
<field name="context">{'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1}</field>
<field name="context">{'search_default_group_by_project': 1,'search_default_group_by_amount_type': 1, 'default_res_model': 'project.budget.amt.report'}</field>
</record>
<menuitem id="menu_project_budget_report_amt_analysis"

View File

@ -45,61 +45,56 @@ 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, is_sub_project, sub_project, start_date, end_date, timesheet_date, pricing_type, project_type, partner_id, employee_id, hours_type,
SELECT
ROW_NUMBER() OVER() as id,
project_id,
is_sub_project,
sub_project,
date_start AS start_date,
date AS end_date,
timesheet_date,
pricing_type as pricing_type,
project_type as project_type,
partner_id,
partner_id
employee_id,
hours_type,
hours from (
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
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,
null::date AS timesheet_date,
pro_emp.budgeted_qty as hours
pro_emp.budgeted_qty as hours,
pro.*
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
Union all
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
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,
null::int AS employee_id,
'Budgeted Hours' as hours_type,
null::date AS timesheet_date,
pro.budgeted_hours2 as hours
pro.budgeted_hours2 as hours,
pro.*
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_no_limit'
Union
Union all
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
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,
AAL.date AS timesheet_date,
unit_amount as hours
unit_amount as hours,
pro.*
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
@ -107,20 +102,14 @@ class BudgetHrsAnalysis(models.Model):
Where
PRO.active = 't' and PRO.pricing_type = 'employee_rate'
--and PRO.project_type = 'hours_in_consultant'
Union
Union all
SELECT
pro.id AS project_id,
pro.is_sub_project as is_sub_project,
pro.sub_project as sub_project,
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,
AAL.date AS timesheet_date,
unit_amount as hours
unit_amount as hours,
pro.*
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

View File

@ -11,8 +11,8 @@ var DateClasses = dataComparisonUtils.DateClasses;
var qweb = core.qweb;
var CHART_TYPES = ['pie', 'bar', 'horizontalBar', 'line'];
var COLORS = ["#1f77b4", "#ff7f0e", "#aec7e8", "#ffbb78", "#2ca02c", "#98df8a", "#d62728",
// #d62728 into #794dd6
var COLORS = ["#1f77b4", "#ff7f0e", "#aec7e8", "#ffbb78", "#2ca02c", "#98df8a", "#794dd6",
"#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2",
"#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5"];
var COLOR_NB = COLORS.length;
@ -64,7 +64,16 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
var formatedValue = formatter(value, measureField, FORMAT_OPTIONS);
return formatedValue;
},
/**
* Used any time we need a new color in our charts.
*
* @private
* @param {number} index
* @returns {string} a color in HEX format
*/
_getColor: function (index) {
return COLORS[index % COLOR_NB];
},
/**
* Determines the initial section of the labels array
* over a dataset has to be completed. The section only depends
@ -200,17 +209,28 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
generateLabels: function (chart) {
var data = chart.data;
return data.datasets.map(function (dataset, i) {
var r = dataset[referenceColor];
if ((dataset[referenceColor] instanceof Array) && (dataset[referenceColor].length>=1)) {
//var res = dataset[referenceColor].filter(item => item != 'red');
var res = r.filter(item => item != 'red');
if (res.length>=1) {
r = res[0]
}
/* else{
dataset[referenceColor] = dataset[referenceColor][0]
} */
}
return {
text: self._shortenLabel(dataset.label),
fullText: dataset.label,
fillStyle: dataset[referenceColor],
fillStyle: r,
hidden: !chart.isDatasetVisible(i),
lineCap: dataset.borderCapStyle,
lineDash: dataset.borderDash,
lineDashOffset: dataset.borderDashOffset,
lineJoin: dataset.borderJoinStyle,
lineWidth: dataset.borderWidth,
strokeStyle: dataset[referenceColor],
strokeStyle: r,
pointStyle: dataset.pointStyle,
datasetIndex: i,
};
@ -521,16 +541,110 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
// prepare data
var data = this._prepareData(dataPoints);
// this.title = 'Time Line';
if (self.resModel == 'project.budget.hrs.report') {
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
_.map(groupedData, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
//var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]);
/*var maxB = zipped_2.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return self._getColor(1);
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return 'red';
}
else {
return self._getColor(1);
}
});
y[1].backgroundColor = maxB;*/
}
});
}
if (self.resModel == 'project.budget.amt.report') {
var groupedData2 = _.groupBy(data.datasets, x => x.label.replace('Actual Cost', '').replace('Budgeted Revenue', ''));
_.map(groupedData2, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
}
});
}
if (self.resModel == 'project.consultant.hrs.report') {
var groupedData3 = _.groupBy(data.datasets, x => x.label.replace('Actual Hours for period', '').replace('Budgeted Hours for period', ''));
_.map(groupedData3, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
}
});
}
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;
if (self.resModel == 'project.budget.hrs.report') {
if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (self.resModel == 'project.budget.amt.report') {
if (dataset.label.indexOf("Actual Cost") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Revenue") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (self.resModel == 'project.consultant.hrs.report') {
if (dataset.label.indexOf("Actual Hours for period") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours for period") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
});
// prepare options
var options = this._prepareOptions(data.datasets.length);
var options = this._prepareOptions(data.datasets.length);
// create chart
var ctx = document.getElementById(this.chartId);
this.chart = new Chart(ctx, {
@ -562,12 +676,97 @@ var MAX_LEGEND_LENGTH = 25 * (1 + config.device.size_class);
// prepare data
var data = this._prepareData(dataPoints);
if (self.resModel == 'project.budget.hrs.report') {
var groupedData = _.groupBy(data.datasets, x => x.label.replace('Actual Hours', '').replace('Budgeted Hours', ''));
_.map(groupedData, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]);
}
});
}
if (self.resModel == 'project.budget.amt.report') {
var groupedData2 = _.groupBy(data.datasets, x => x.label.replace('Actual Cost', '').replace('Budgeted Revenue', ''));
_.map(groupedData2, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
//var zipped_2 = _.zip.apply(null, [y[1].data, y[0].data]);
}
});
}
if (self.resModel == 'project.consultant.hrs.report') {
var groupedData3 = _.groupBy(data.datasets, x => x.label.replace('Actual Hours for period', '').replace('Budgeted Hours for period', ''));
_.map(groupedData3, (y) => {
if (y.length > 1) {
var zipped_1 = _.zip.apply(null, [y[0].data, y[1].data]);
var maxA = zipped_1.map((a) => {
if ((!!a[0] && !!a[1]) && a[0] > a[1]) {
return 'red';
} else if ((!!a[0] && !!a[1]) && a[0] < a[1]) {
return self._getColor(0);
}
else {
return self._getColor(0);
}
});
y[0].backgroundColor = maxA;
y[1].backgroundColor = self._getColor(1);
}
});
}
data.datasets.forEach(function (dataset, index) {
// used when stacked
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined;
// set dataset color
if (self.resModel == 'project.budget.hrs.report') {
if (dataset.label.indexOf("Actual Hours") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (self.resModel == 'project.budget.amt.report') {
if (dataset.label.indexOf("Actual Cost") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Revenue") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else if (self.resModel == 'project.consultant.hrs.report') {
if (dataset.label.indexOf("Actual Hours for period") === -1 && dataset.label.toLowerCase().indexOf("Budgeted Hours for period") === -1) {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
}
else {
var color = self._getColor(index);
dataset.backgroundColor = color;
}
});
// prepare options