forked from Techsystech/web
commit
d0d552bbea
|
@ -0,0 +1 @@
|
|||
../../../../web_pivot_hide_total
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
This file is going to be generated by oca-gen-addon-readme.
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2017 ACSONE SA/NV
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Web Pivot View Hide Total",
|
||||
"summary": """
|
||||
This addon adds a new inherited version of pivot view.
|
||||
It intends to hide the last total column when required.""",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"depends": ["web"],
|
||||
"data": ["views/web_pivot_hide_total_views.xml"],
|
||||
"installable": True,
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
Activation of the view is done in xml file, using "js_class" tag.
|
||||
|
||||
In your xml file, declare a pivot view with js_class="web_pivot_hide_total".
|
||||
|
||||
For example :
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<record id='my_new_pivot_view' model='ir.ui.view'>
|
||||
<field name="model">my.model</field>
|
||||
<field name="arch" type="xml">
|
||||
<pivot string="My new pivot view name" js_class="web_pivot_hide_total">
|
||||
<field name="My field" type="row" />
|
||||
<field name="My column" type="col" />
|
||||
<field name="My measure" type="measure" />
|
||||
</pivot>
|
||||
</field>
|
||||
</record>
|
|
@ -0,0 +1,2 @@
|
|||
* Régis Pirard <regis.pirard@acsone.eu>
|
||||
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
|
|
@ -0,0 +1,13 @@
|
|||
In some cases, we want to use the columns of a pivot view
|
||||
to compare datas, but the total sum displayed in the last column
|
||||
juste makes no sens.
|
||||
|
||||
This module intends to hide that last total column when required.
|
||||
|
||||
.. image:: ../static/description/before.png
|
||||
:alt: Before
|
||||
|
||||
\
|
||||
|
||||
.. image:: ../static/description/after.png
|
||||
:alt: After
|
|
@ -0,0 +1 @@
|
|||
* Allow setting default dialog size per user.
|
Binary file not shown.
After Width: | Height: | Size: 170 KiB |
Binary file not shown.
After Width: | Height: | Size: 202 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
|
@ -0,0 +1,86 @@
|
|||
odoo.define("web.PivotModelHideTotal", function (require) {
|
||||
"use strict";
|
||||
|
||||
const {_t} = require("web.core");
|
||||
|
||||
const PivotModel = require("web.PivotModel");
|
||||
|
||||
const PivotModelHideTotal = PivotModel.extend({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_getTableHeaders: function () {
|
||||
var colGroupBys = this._getGroupBys().colGroupBys;
|
||||
var height = colGroupBys.length + 1;
|
||||
var measureCount = this.data.measures.length;
|
||||
var originCount = this.data.origins.length;
|
||||
var leafCounts = this._getLeafCounts(this.colGroupTree);
|
||||
var headers = [];
|
||||
var measureColumns = [];
|
||||
|
||||
// 1) generate col group rows (total row + one row for each col groupby)
|
||||
var colGroupRows = new Array(height).fill(0).map(function () {
|
||||
return [];
|
||||
});
|
||||
// Blank top left cell
|
||||
colGroupRows[0].push({
|
||||
height: height + 1 + (originCount > 1 ? 1 : 0),
|
||||
title: "",
|
||||
width: 1,
|
||||
});
|
||||
|
||||
// Col groupby cells with group values
|
||||
/**
|
||||
* Recursive function that generates the header cells corresponding to
|
||||
* the groups of a given tree.
|
||||
*
|
||||
* @param {Object} tree
|
||||
* @param {Object} fields
|
||||
*/
|
||||
function generateTreeHeaders(tree, fields) {
|
||||
var group = tree.root;
|
||||
var rowIndex = group.values.length;
|
||||
var row = colGroupRows[rowIndex];
|
||||
var groupId = [[], group.values];
|
||||
var isLeaf = !tree.directSubTrees.size;
|
||||
var leafCount = leafCounts[JSON.stringify(tree.root.values)];
|
||||
var cell = {
|
||||
groupId: groupId,
|
||||
height: isLeaf ? colGroupBys.length + 1 - rowIndex : 1,
|
||||
isLeaf: isLeaf,
|
||||
label:
|
||||
rowIndex === 0
|
||||
? undefined
|
||||
: fields[colGroupBys[rowIndex - 1].split(":")[0]].string,
|
||||
title: group.labels[group.labels.length - 1] || _t("Total"),
|
||||
width: leafCount * measureCount * (2 * originCount - 1),
|
||||
};
|
||||
row.push(cell);
|
||||
if (isLeaf) {
|
||||
measureColumns.push(cell);
|
||||
}
|
||||
|
||||
[...tree.directSubTrees.values()].forEach(function (subTree) {
|
||||
generateTreeHeaders(subTree, fields);
|
||||
});
|
||||
}
|
||||
|
||||
generateTreeHeaders(this.colGroupTree, this.fields);
|
||||
|
||||
headers = headers.concat(colGroupRows);
|
||||
|
||||
// 2) generate measures row
|
||||
var measuresRow = this._getMeasuresRow(measureColumns);
|
||||
headers.push(measuresRow);
|
||||
|
||||
// 3) generate origins row if more than one origin
|
||||
if (originCount > 1) {
|
||||
headers.push(this._getOriginsRow(measuresRow));
|
||||
}
|
||||
|
||||
return headers;
|
||||
},
|
||||
});
|
||||
|
||||
return PivotModelHideTotal;
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
odoo.define("web_pivot_hide_total.PivotViewHideTotal", function (require) {
|
||||
"use strict";
|
||||
|
||||
const PivotView = require("web.PivotView");
|
||||
const PivotModelHideTotal = require("web.PivotModelHideTotal");
|
||||
const viewRegistry = require("web.view_registry");
|
||||
|
||||
const PivotViewHideTotal = PivotView.extend({
|
||||
config: _.extend({}, PivotView.prototype.config, {
|
||||
Model: PivotModelHideTotal,
|
||||
}),
|
||||
});
|
||||
|
||||
viewRegistry.add("web_pivot_hide_total", PivotViewHideTotal);
|
||||
|
||||
return PivotViewHideTotal;
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- Copyright 2020 ACSONE SA/NV
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
<template
|
||||
id="web_pivot_hide_total_assets_backend"
|
||||
name="web_pivot_hide_total assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_pivot_hide_total/static/src/js/views/pivot/pivot_model_hide_total.js"
|
||||
/>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_pivot_hide_total/static/src/js/views/pivot/pivot_view_hide_total.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue