3
0
Fork 0

[IMP] web_pivot_computed_measure: pre-commit auto fixes

18.0
Carlos Roca 2024-11-26 14:09:12 +01:00
parent 0e18318084
commit 31cbc5b679
14 changed files with 148 additions and 124 deletions

View File

@ -17,13 +17,13 @@ Web Pivot Computed Measure
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure
:target: https://github.com/OCA/web/tree/18.0/web_pivot_computed_measure
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_pivot_computed_measure
:target: https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_pivot_computed_measure
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=18.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -38,37 +38,48 @@ Adds support for computed measures on the pivot view.
Usage
=====
Go to pivot view and click on the "Measures" menu, you will see
a new option called 'Computed Measure'.
Go to pivot view and click on the "Measures" menu, you will see a new
option called 'Computed Measure'.
You have the follow options to create a 'computed measure':
- Measure 1: Used in 'operation formula' as 'm1'
- Measure 2: Used in 'operation formula' as 'm2'
- Operation: The formula
- Sum: m1 + m2
- Sub: m1 - m2
- Mult: m1 * m2
- Div: m1 / m2 (Format: Float)
- Perc m1 / m2 (Format: Percentage)
- Custom: Special option only visible in debug mode to write a custom formula.
- Name: The name of the new measure (emtpy = auto-generated)
- Format: How will the value be printed
- Integer
- Float
- Percentage (value * 100)
- Formula*: Custom operation formula
These formula is evaluated using 'PY.eval'
These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites.
- Measure 1: Used in 'operation formula' as 'm1'
Notice that "measures/computed measures" involved in an active 'computed measure'
can't be deactivated until you have deactivate the 'computed measure'.
- Measure 2: Used in 'operation formula' as 'm2'
- Operation: The formula
- Sum: m1 + m2
- Sub: m1 - m2
- Mult: m1 \* m2
- Div: m1 / m2 (Format: Float)
- Perc m1 / m2 (Format: Percentage)
- Custom: Special option only visible in debug mode to write a
custom formula.
- Name: The name of the new measure (emtpy = auto-generated)
- Format: How will the value be printed
- Integer
- Float
- Percentage (value \* 100)
- | Formula\*: Custom operation formula
| These formula is evaluated using 'PY.eval'
These computed measures can be mixed (You can reuse it to make new
computed measures) and saved as favorites.
Notice that "measures/computed measures" involved in an active 'computed
measure' can't be deactivated until you have deactivate the 'computed
measure'.
Known issues / Roadmap
======================
#. Add support to define a style for a computed measure (ex. colored)
#. Use t-model to data-binding instead of jquery selectors
1. Add support to define a style for a computed measure (ex. colored)
2. Use t-model to data-binding instead of jquery selectors
Bug Tracker
===========
@ -76,7 +87,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
@ -84,22 +95,22 @@ Credits
=======
Authors
~~~~~~~
-------
* Tecnativa
Contributors
~~~~~~~~~~~~
------------
* `Tecnativa <https://www.tecnativa.com/>`_:
- `Tecnativa <https://www.tecnativa.com/>`__:
* Alexandre D. Díaz
* Pedro M. Baeza
* Ernesto Tejeda
* Carlos Roca
- Alexandre D. Díaz
- Pedro M. Baeza
- Ernesto Tejeda
- Carlos Roca
Maintainers
~~~~~~~~~~~
-----------
This module is maintained by the OCA.
@ -119,6 +130,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-CarlosRoca13|
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/18.0/web_pivot_computed_measure>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"

View File

@ -0,0 +1,5 @@
- [Tecnativa](https://www.tecnativa.com/):
- Alexandre D. Díaz
- Pedro M. Baeza
- Ernesto Tejeda
- Carlos Roca

View File

@ -1,6 +0,0 @@
* `Tecnativa <https://www.tecnativa.com/>`_:
* Alexandre D. Díaz
* Pedro M. Baeza
* Ernesto Tejeda
* Carlos Roca

View File

@ -0,0 +1,2 @@
1. Add support to define a style for a computed measure (ex. colored)
2. Use t-model to data-binding instead of jquery selectors

View File

@ -1,2 +0,0 @@
#. Add support to define a style for a computed measure (ex. colored)
#. Use t-model to data-binding instead of jquery selectors

View File

@ -0,0 +1,33 @@
Go to pivot view and click on the "Measures" menu, you will see a new
option called 'Computed Measure'.
You have the follow options to create a 'computed measure':
- Measure 1: Used in 'operation formula' as 'm1'
- Measure 2: Used in 'operation formula' as 'm2'
- Operation: The formula
- Sum: m1 + m2
- Sub: m1 - m2
- Mult: m1 \* m2
- Div: m1 / m2 (Format: Float)
- Perc m1 / m2 (Format: Percentage)
- Custom: Special option only visible in debug mode to write a custom
formula.
- Name: The name of the new measure (emtpy = auto-generated)
- Format: How will the value be printed
- Integer
- Float
- Percentage (value \* 100)
- Formula\*: Custom operation formula
These formula is evaluated using 'PY.eval'
These computed measures can be mixed (You can reuse it to make new
computed measures) and saved as favorites.
Notice that "measures/computed measures" involved in an active 'computed
measure' can't be deactivated until you have deactivate the 'computed
measure'.

View File

@ -1,25 +0,0 @@
Go to pivot view and click on the "Measures" menu, you will see
a new option called 'Computed Measure'.
You have the follow options to create a 'computed measure':
- Measure 1: Used in 'operation formula' as 'm1'
- Measure 2: Used in 'operation formula' as 'm2'
- Operation: The formula
- Sum: m1 + m2
- Sub: m1 - m2
- Mult: m1 * m2
- Div: m1 / m2 (Format: Float)
- Perc m1 / m2 (Format: Percentage)
- Custom: Special option only visible in debug mode to write a custom formula.
- Name: The name of the new measure (emtpy = auto-generated)
- Format: How will the value be printed
- Integer
- Float
- Percentage (value * 100)
- Formula*: Custom operation formula
These formula is evaluated using 'PY.eval'
These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites.
Notice that "measures/computed measures" involved in an active 'computed measure'
can't be deactivated until you have deactivate the 'computed measure'.

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@ -9,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@ -301,7 +301,7 @@ span.option {
span.pre {
white-space: pre }
span.problematic {
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@ -369,7 +369,7 @@ ul.auto-toc {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:4cef60dd775467b756ccbacb8c215bba0bc74fd32e1917c8b15c3be9de6302a1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_pivot_computed_measure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/18.0/web_pivot_computed_measure"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-18-0/web-18-0-web_pivot_computed_measure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Adds support for computed measures on the pivot view.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
@ -387,48 +387,45 @@ ul.auto-toc {
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>Go to pivot view and click on the “Measures” menu, you will see
a new option called Computed Measure.</p>
<dl class="docutils">
<dt>You have the follow options to create a computed measure:</dt>
<dd><ul class="first last simple">
<li>Measure 1: Used in operation formula as m1</li>
<li>Measure 2: Used in operation formula as m2</li>
<li><dl class="first docutils">
<dt>Operation: The formula</dt>
<dd><ul class="first last">
<p>Go to pivot view and click on the “Measures” menu, you will see a new
option called Computed Measure.</p>
<p>You have the follow options to create a computed measure:</p>
<ul>
<li><p class="first">Measure 1: Used in operation formula as m1</p>
</li>
<li><p class="first">Measure 2: Used in operation formula as m2</p>
</li>
<li><p class="first">Operation: The formula</p>
<ul class="simple">
<li>Sum: m1 + m2</li>
<li>Sub: m1 - m2</li>
<li>Mult: m1 * m2</li>
<li>Div: m1 / m2 (Format: Float)</li>
<li>Perc m1 / m2 (Format: Percentage)</li>
<li>Custom: Special option only visible in debug mode to write a custom formula.</li>
<li>Custom: Special option only visible in debug mode to write a
custom formula.</li>
</ul>
</dd>
</dl>
</li>
<li>Name: The name of the new measure (emtpy = auto-generated)</li>
<li><dl class="first docutils">
<dt>Format: How will the value be printed</dt>
<dd><ul class="first last">
<li><p class="first">Name: The name of the new measure (emtpy = auto-generated)</p>
</li>
<li><p class="first">Format: How will the value be printed</p>
<ul class="simple">
<li>Integer</li>
<li>Float</li>
<li>Percentage (value * 100)</li>
</ul>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt>Formula*: Custom operation formula</dt>
<dd>These formula is evaluated using PY.eval</dd>
</dl>
<li><div class="first line-block">
<div class="line">Formula*: Custom operation formula</div>
<div class="line">These formula is evaluated using PY.eval</div>
</div>
</li>
</ul>
</dd>
</dl>
<p>These computed measures can be mixed (You can reuse it to make new computed measures) and saved as favorites.</p>
<p>Notice that “measures/computed measures” involved in an active computed measure
cant be deactivated until you have deactivate the computed measure.</p>
<p>These computed measures can be mixed (You can reuse it to make new
computed measures) and saved as favorites.</p>
<p>Notice that “measures/computed measures” involved in an active computed
measure cant be deactivated until you have deactivate the computed
measure.</p>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#toc-entry-2">Known issues / Roadmap</a></h1>
@ -442,7 +439,7 @@ cant be deactivated until you have deactivate the computed measure.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_pivot_computed_measure%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
@ -468,13 +465,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/CarlosRoca13"><img alt="CarlosRoca13" src="https://github.com/CarlosRoca13.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_pivot_computed_measure">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/18.0/web_pivot_computed_measure">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -39,10 +39,10 @@
Computed Measure
<span class="o_submenu_switcher" data-id="__computed__">
<span
t-att-class="isOpen.value ? 'fa fa-caret-down' : 'fa fa-caret-right'"
/>
</span>
<span
t-att-class="isOpen.value ? 'fa fa-caret-down' : 'fa fa-caret-right'"
/>
</span>
</a>
<t t-if="isOpen.value">
<div id="add_computed_measure_wrapper" class="d-table">

View File

@ -148,7 +148,7 @@ patch(PivotModel.prototype, "web_pivot_computed_measure.PivotModel", {
if (subGroupData.__count === 0) {
subGroupData[cm.id] = false;
} else {
// eslint-disable-next-line no-undef
subGroupData[cm.id] = evalOperation(cm.operation, subGroupData);
}
}

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.PivotView.Buttons" t-inherit-mode="extension" owl="1">
<xpath expr="//t[@t-call='web.ReportViewMeasures']" position="inside">
<t t-set="add_computed_measures" t-value="true" />
<t t-set="model" t-value="model" />
</xpath>
</t>
<xpath expr="//t[@t-call='web.ReportViewMeasures']" position="inside">
<t t-set="add_computed_measures" t-value="true" />
<t t-set="model" t-value="model" />
</xpath>
</t>
</templates>

View File

@ -1,12 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates xml:space="preserve">
<t t-inherit="web.ReportViewMeasures" t-inherit-mode="extension" owl="1">
<xpath expr="//DropdownItem" position="attributes">
<attribute name="t-if">!measure.startsWith('__computed_')</attribute>
</xpath>
<xpath expr="//t[@t-foreach='measures']" position="after">
<div role="separator" class="dropdown-divider" t-if="add_computed_measures" />
<t t-foreach="measures" t-as="measure" t-key="measure_value.name">
<xpath expr="//DropdownItem" position="attributes">
<attribute name="t-if">!measure.startsWith('__computed_')</attribute>
</xpath>
<xpath expr="//t[@t-foreach='measures']" position="after">
<div
role="separator"
class="dropdown-divider"
t-if="add_computed_measures"
/>
<t t-foreach="measures" t-as="measure" t-key="measure_value.name">
<DropdownItem
class="{ o_menu_item: true, selected: activeMeasures.includes(measure) }"
t-if="add_computed_measures and measure.startsWith('__computed_')"
@ -15,11 +19,11 @@
onSelected="() => this.onMeasureSelected({ measure: measure_value.name })"
/>
</t>
<DropdownItemCustomMeasure
<DropdownItemCustomMeasure
measures="measures"
model="model"
t-if="add_computed_measures"
/>
</xpath>
</t>
</xpath>
</t>
</templates>