[IMP] analytic: no status indicator for optional plans
The status indicator for optional plans switches between grey and green and creates a perception that action is required, when in fact, all values are valid. For this reason, the status indicator only applies to mandatory plans (green: ok, orange: editing, red: invalid) The grey status is removed entirely. closes odoo/odoo#102503 X-original-commit: e2cd7f93d49cbdd60d6f84b465b042fae9389bb1 Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Ayob Habib (ayh) <ayh@odoo.com>
This commit is contained in:
@@ -419,14 +419,7 @@ msgstr ""
|
||||
#. openerp-web
|
||||
#: code:addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js:0
|
||||
#, python-format
|
||||
msgid "Editing (Incomplete)"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic
|
||||
#. openerp-web
|
||||
#: code:addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js:0
|
||||
#, python-format
|
||||
msgid "Editing (OK)"
|
||||
msgid "Editing"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic
|
||||
@@ -546,6 +539,7 @@ msgid "Main Attachment"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic
|
||||
#: code:addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js:0
|
||||
#: model:ir.model.fields.selection,name:analytic.selection__account_analytic_applicability__applicability__mandatory
|
||||
#: model:ir.model.fields.selection,name:analytic.selection__account_analytic_plan__default_applicability__mandatory
|
||||
msgid "Mandatory"
|
||||
@@ -639,6 +633,7 @@ msgid "Operating Costs"
|
||||
msgstr ""
|
||||
|
||||
#. module: analytic
|
||||
#: code:addons/analytic/static/src/components/analytic_distribution/analytic_distribution.js:0
|
||||
#: model:ir.model.fields.selection,name:analytic.selection__account_analytic_applicability__applicability__optional
|
||||
#: model:ir.model.fields.selection,name:analytic.selection__account_analytic_plan__default_applicability__optional
|
||||
msgid "Optional"
|
||||
|
||||
+26
-32
@@ -7,6 +7,7 @@ import { getNextTabableElement, getPreviousTabableElement } from "@web/core/util
|
||||
import { usePosition } from "@web/core/position_hook";
|
||||
import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service";
|
||||
import { shallowEqual } from "@web/core/utils/arrays";
|
||||
import { _lt } from "@web/core/l10n/translation";
|
||||
import { AnalyticAutoComplete } from "../autocomplete/autocomplete";
|
||||
|
||||
import { standardFieldProps } from "@web/views/fields/standard_field_props";
|
||||
@@ -17,7 +18,15 @@ import { formatPercentage } from "@web/views/fields/formatters";
|
||||
|
||||
const { Component, useState, useRef, useExternalListener, onWillUpdateProps, onWillStart, onPatched } = owl;
|
||||
|
||||
|
||||
const PLAN_APPLICABILITY = {
|
||||
mandatory: _lt("Mandatory"),
|
||||
optional: _lt("Optional"),
|
||||
}
|
||||
const PLAN_STATUS = {
|
||||
editing: _lt("Editing"),
|
||||
invalid: _lt("Invalid"),
|
||||
ok: _lt("OK"),
|
||||
}
|
||||
export class AnalyticDistribution extends Component {
|
||||
setup(){
|
||||
this.orm = useService("orm");
|
||||
@@ -285,7 +294,7 @@ export class AnalyticDistribution extends Component {
|
||||
get firstIncompletePlanId() {
|
||||
for (const group_id in this.list) {
|
||||
const group_status = this.groupStatus(group_id);
|
||||
if (["orange", "red"].includes(group_status)) return group_id;
|
||||
if (["editing", "invalid"].includes(group_status)) return group_id;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -316,7 +325,7 @@ export class AnalyticDistribution extends Component {
|
||||
|
||||
get allowSave() {
|
||||
for (const group_id in this.list) {
|
||||
if (['orange', 'red'].includes(this.groupStatus(group_id))) return false;
|
||||
if (['editing', 'invalid'].includes(this.groupStatus(group_id))) return false;
|
||||
}
|
||||
return this.props.allow_save;
|
||||
}
|
||||
@@ -329,41 +338,26 @@ export class AnalyticDistribution extends Component {
|
||||
return this.state.showDropdown && !!this.dropdownRef.el;
|
||||
}
|
||||
|
||||
applicabilityStatus(group_id) {
|
||||
statusDescription(group_id) {
|
||||
const group = this.list[group_id];
|
||||
const status = this.groupStatus(group_id);
|
||||
let description;
|
||||
switch(status){
|
||||
case "gray":
|
||||
description = this.env._t("Editing (OK)");
|
||||
break;
|
||||
case "orange": {
|
||||
description = this.env._t("Editing (Incomplete)");
|
||||
break;
|
||||
}
|
||||
case "red": {
|
||||
description = this.env._t("Invalid");
|
||||
break;
|
||||
}
|
||||
case "green": {
|
||||
description = this.env._t("OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return `${group.applicability.charAt(0).toUpperCase()}${group.applicability.slice(1)} - ${description}`;
|
||||
const applicability = PLAN_APPLICABILITY[group.applicability];
|
||||
const status = PLAN_STATUS[this.groupStatus(group_id)];
|
||||
return `${applicability} - ${status} ${this.formatPercentage(this.sumByGroup(group_id))}`;
|
||||
}
|
||||
|
||||
groupStatus(id) {
|
||||
const group = this.list[id];
|
||||
const ready_tags = this.listReadyByGroup(id);
|
||||
if (group.distribution.length > ready_tags.length) {
|
||||
return group.applicability === 'mandatory' ? 'orange' : 'gray';
|
||||
if (group.applicability === 'mandatory') {
|
||||
if (group.distribution.length > ready_tags.length) {
|
||||
return 'editing'
|
||||
}
|
||||
const sum = this.sumByGroup(id);
|
||||
if (sum < 99.99 || sum >= 100.01) {
|
||||
return 'invalid';
|
||||
}
|
||||
}
|
||||
const sum = this.sumByGroup(id);
|
||||
if (group.applicability === 'mandatory' && (sum < 99.99 || sum >= 100.01)){
|
||||
return 'red';
|
||||
}
|
||||
return 'green';
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
listReadyByGroup(id) {
|
||||
@@ -410,7 +404,7 @@ export class AnalyticDistribution extends Component {
|
||||
|
||||
validate() {
|
||||
for (const group_id in this.list) {
|
||||
if (this.groupStatus(group_id) === 'red') {
|
||||
if (this.groupStatus(group_id) === 'invalid') {
|
||||
this.props.record.setInvalidField(this.props.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
+3
-7
@@ -14,22 +14,18 @@
|
||||
.o_analytic_percentage {
|
||||
width: 45px !important;
|
||||
}
|
||||
.o_analytic_status_red {
|
||||
.o_analytic_status_invalid {
|
||||
background-color: $o-danger;
|
||||
margin-left:8px;
|
||||
}
|
||||
.o_analytic_status_green {
|
||||
.o_analytic_status_ok {
|
||||
background-color: $o-success;
|
||||
margin-left:8px;
|
||||
}
|
||||
.o_analytic_status_orange {
|
||||
.o_analytic_status_editing {
|
||||
background-color: $o-warning;
|
||||
margin-left:8px;
|
||||
}
|
||||
.o_analytic_status_gray {
|
||||
background-color: $gray-200;
|
||||
margin-left:8px;
|
||||
}
|
||||
tr:hover {
|
||||
outline: none !important;
|
||||
}
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
<th class="o_analytic_account_name">
|
||||
<t t-esc="plan.name"/>
|
||||
<t t-if="plan.account_count === 0"> (no accounts)</t>
|
||||
<span t-attf-class="o_status d-inline-block o_analytic_status_{{groupStatus(plan.id)}}" t-att-title="applicabilityStatus(plan.id) + ' ' + formatPercentage(sumByGroup(plan.id))"/>
|
||||
<span t-if="plan.applicability === 'mandatory'" t-attf-class="o_status d-inline-block o_analytic_status_{{groupStatus(plan.id)}}" t-att-title="statusDescription(plan.id)"/>
|
||||
</th>
|
||||
</tr>
|
||||
<t t-foreach="plan.distribution" t-as="dist_tag" t-key="dist_tag.id">
|
||||
|
||||
@@ -144,7 +144,7 @@ QUnit.module("Analytic", (hooks) => {
|
||||
const input = document.activeElement;
|
||||
await editInput(input, null, "19");
|
||||
|
||||
assert.containsOnce(planTable, '.o_analytic_status_orange', "Mandatory plan has incomplete status");
|
||||
assert.containsOnce(planTable, '.o_analytic_status_editing', "Mandatory plan has incomplete status");
|
||||
|
||||
let incompleteInputName = planTable.querySelector('tr.incomplete .o_analytic_account_name input');
|
||||
assert.strictEqual(document.activeElement, incompleteInputName,
|
||||
|
||||
Reference in New Issue
Block a user