This commit is contained in:
2026-11-08 17:43:44 +08:00
parent 974a1fb10b
commit 3b5af1e3a6
483 changed files with 590466 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
import { registry } from "@web/core/registry";
import { useVirtualGrid } from "@web/core/virtual_grid_hook";
import { ControlPanel } from "@web/search/control_panel/control_panel";
import { useSetupAction } from "@web/search/action_hook";
import { standardActionServiceProps } from "@web/webclient/actions/action_plugin";
import { UIPlugin } from "@web/core/ui/ui_plugin";
import { Component, onWillDestroy, computed, providePlugins, signal, t, usePlugin, useProps, useScope } from "@odoo/owl";
import { AccountReportButtonsBar } from "@account_reports/components/account_report/buttons_bar/buttons_bar";
import { AccountReportChatter } from "@account_reports/components/mail/chatter";
import { AccountReportCogMenu } from "@account_reports/components/account_report/cog_menu/cog_menu";
import { AccountReportController } from "@account_reports/components/account_report/controller";
import { AccountReportSearchBar } from "@account_reports/components/account_report/search_bar/search_bar";
class AccountReportPadding extends Component {
static template = "account_reports.AccountReportPadding";
props = useProps({ height: t.signal(t.number()) });
}
export class AccountReport extends Component {
static template = "account_reports.AccountReport";
static components = {
ControlPanel,
AccountReportButtonsBar,
AccountReportChatter,
AccountReportCogMenu,
AccountReportPadding,
AccountReportSearchBar,
};
props = useProps(standardActionServiceProps);
rootRef = signal.ref();
virtualScrollableRef = signal.ref();
ui = usePlugin(UIPlugin);
scope = useScope();
setup() {
useSetupAction({
rootRef: this.rootRef,
getLocalState: () => ({ keep_journal_groups_options: true }), // used when using the breadcrumb
});
if (this.props?.state?.keep_journal_groups_options !== undefined) {
this.props.action.keep_journal_groups_options = true;
}
// The scrollable element is different if we are on a small device or not due to the flex-direction used on the o_content.
const scrollableRef = computed(() => this.ui.isSmall() ? this.rootRef() : this.virtualScrollableRef());
function createVirtualGrids() {
return {
left: useVirtualGrid({
scrollableRef,
/** Lines are very expensive to render since they contain a lot of logic and sub components.
* Since this buffer is for the top **AND** bottom, it will add 2 lines for every line added in a direction
* making it quickly more expensive. Another reason to keep this low is to not overload the DOM with too many
* elements, which can drastically reduce the performance.
*/
bufferCoef: 0.5,
}),
right: useVirtualGrid({ // Right table for horizontal split, if enabled
scrollableRef,
bufferCoef: 0.5,
}),
};
}
const virtualGrids = computed(() => {
this.controller?._invalidateVisibleLines.set(true);
return this.scope.run(() => createVirtualGrids());
});
providePlugins([AccountReportController], {
action: this.props.action,
scrollableRef,
virtualGrids,
});
this.controller = usePlugin(AccountReportController);
this.initialQuery = this.props.action.context.default_filter_accounts || '';
onWillDestroy(() => {
// Since the controller is preloading the sections using a setTimeout, it's never stopped unless we explicitly tell it.
this.controller.destroyed = true;
});
this.cssCustomClass = computed(() => this.controller.options().custom_display_config.css_custom_class || "");
this.tableClasses = computed(() => this.getTableClasses());
}
// -----------------------------------------------------------------------------------------------------------------
// Table
// -----------------------------------------------------------------------------------------------------------------
getTableClasses() {
let classes = "";
if (this.controller.options().columns.length > 1)
classes += " striped";
if (this.controller.options().horizontal_split)
classes += " w-50 mx-2";
return classes;
}
// -----------------------------------------------------------------------------------------------------------------
// Chatter
// -----------------------------------------------------------------------------------------------------------------
/**
* @param {KeyboardEvent} ev
*/
onKeydown(ev) {
if (ev.key === "Escape") {
this.controller.closeChatter();
}
}
/**
* @param {MouseEvent} ev
*/
onClick(ev) {
if (this.ui.isSmall() && this.controller.chatterState.id() && !ev.target.closest(".o_account_report_mobile_chatter")) {
this.controller.closeChatter();
}
}
}
registry.category("actions").add("account_report", AccountReport);

View File

@@ -0,0 +1,587 @@
.account_report {
.o_account_report_scroll_container {
margin-inline: 0 !important;
padding-bottom: 40px;
}
//------------------------------------------------------------------------------------------------------------------
// Control panel
//------------------------------------------------------------------------------------------------------------------
.o_control_panel_main_buttons {
.dropdown-item {
padding: 0;
.btn-link {
width: 100%;
text-align: left;
padding: 3px 20px;
border-radius: 0;
}
}
}
.o_control_panel_breadcrumbs {
min-width: fit-content;
}
//------------------------------------------------------------------------------------------------------------------
// Sections
//------------------------------------------------------------------------------------------------------------------
.section_selector {
display: flex;
gap: 4px;
margin: 16px 16px 8px 16px;
justify-content: center;
}
.btn-outline-primary,
.btn-outline-primary:hover {
background-color: transparent !important;
color: var(--primary) !important;
border-color: var(--primary) !important;
}
//------------------------------------------------------------------------------------------------------------------
// Alert
//------------------------------------------------------------------------------------------------------------------
.alert {
margin-bottom: 0;
border-radius: 0;
a:hover { cursor:pointer }
}
//------------------------------------------------------------------------------------------------------------------
// No content
//------------------------------------------------------------------------------------------------------------------
.o_view_nocontent { z-index: -1 }
//------------------------------------------------------------------------------------------------------------------
// Table
//------------------------------------------------------------------------------------------------------------------
.table {
background-color: $o-view-background-color;
border-collapse: separate; //!\\ Allows to add padding to the table
border-spacing: 0; //!\\ Removes default spacing between cells due to 'border-collapse: separate'
font-size: 0.8rem;
margin: 24px 24px;
padding: 24px;
width: auto;
min-width: 800px;
border: 1px solid $o-gray-300;
border-radius: 0.25rem;
overflow-anchor: none; /* Prevents scroll jump with the virtual lines */
--row-action-color: #{ $o-gray-300 }; // color take below at button section
--row-action-opacity: 0;
--row-muted-color: #{ var(--AccountReport-muted-data-color, $o-gray-300) };
td, th { //!\\ Override of bootstrap selector `> :not(caption) > * > *`
padding: 0.25rem 0.75rem !important;
}
.line_cell > a.cursor-pointer {
color: inherit;
}
> thead {
> tr:first-child > th {
color: var(--AccountReport-muted-data-color, $o-gray-300);
> .companies_header {
display: inline-block;
max-width: min-content;
min-width: -moz-available; /* WebKit-based browsers will ignore this. */
min-width: -webkit-fill-available; /* Mozilla-based browsers will ignore this. */
}
}
> tr:not(:first-child) > th:not(:first-child) {
text-align: center;
vertical-align: middle;
}
> tr:not(:last-child) > th:not(:first-child) { border: 1px solid $o-gray-300 }
tr {
white-space: nowrap;
.numeric-header {
padding-right: calc(20px + 0.75rem) !important;
}
}
}
> tbody {
tr { // style applied in recursive tables
// 1.7rem = 1.5 [line-height] * 0.8rem [font-size] + 0.25 * 2 [padding top/bottom]
// 5 px = 1px [border bottom] + 4px [additional pixels to be make sure all lines kinda match]
height: calc(0.8rem * var(--body-line-height) + 0.5rem + 5px);
}
> tr {
&.unfolded { font-weight: bold }
> td {
border-bottom: 1px solid var(--AccountReport-fine-line-separator-color, $o-gray-200);
.clickable { color: $o-enterprise-action-color }
&.muted, .muted { color: var(--row-muted-color) }
.btn_annotation {
color: $o-gray-400;
&.o_account_report_chatter_selected {
color: $o-enterprise-action-color !important;
}
&.o_account_report_chatter_selected,
&.o_account_report_chatter_annotated {
opacity: 1;
}
.o_web_client.o_touch_device & {
opacity: 1;
}
}
}
&.total { font-weight: bold }
&.o_bold_tr { font-weight: bold }
&.unfolded {
--row-action-opacity: 1;
> td { border-bottom: 1px solid $o-gray-300 }
}
.btn_action, .btn_more, .btn_edit, .btn_dropdown, .btn_foldable, .btn_ellipsis,
.btn_annotation_go, .btn_debug {
color: var(--row-action-color);
}
.btn_action, .btn_more, .btn_annotation {
opacity: var(--row-action-opacity);
}
&:hover {
--row-action-opacity: 1;
--row-action-color: #{ $o-enterprise-action-color };
--row-muted-color: #{ $o-gray-800 };
> td.auditable { color: $o-enterprise-action-color !important; }
}
&.o_fake_line {
max-height: 0 !important;
height: 0 !important;
> td {
padding: 0 !important;
border: 0 !important;
height: 0 !important;
line-height: 0 !important;
}
}
&.o_hidden {
content-visibility: hidden;
}
}
}
@media print {
border: 0;
padding: 0;
}
}
table.striped {
//!\\ Changes the background of every even column starting with the 3rd one
> thead > tr:nth-child(n+3) > th:nth-child(2n+3) {
background: $o-gray-100;
}
> tbody > tr {
> td.line_cell_odd {
background: $o-gray-100;
}
&.line_level_0 > td.line_cell_odd {
background: $o-gray-300;
}
}
}
thead.sticky {
background-color: $o-view-background-color;
position: sticky;
top: 0;
z-index: 999;
}
//------------------------------------------------------------------------------------------------------------------
// Line
//------------------------------------------------------------------------------------------------------------------
.line_name {
vertical-align: middle;
white-space: nowrap;
sup { top: auto }
&.draft { color: $o-info; }
&.unfoldable:hover { cursor: pointer }
}
.line_cell {
vertical-align: middle;
white-space: nowrap;
&.date { text-align: center; }
&.numeric {
text-align: end;
padding-right: calc(20px + 0.75rem) !important;
&.editable-cell {
padding-right: 0.75rem !important;
}
}
}
.editable-cell {
text-align: end;
cursor: default;
.o_external_reference .o_input {
border: none;
text-align: right;
}
[data-icon='edit'] {
width: 20px;
}
input {
width: unset;
max-width: 200px;
color: $o-enterprise-action-color;
border: none;
display: inline;
cursor: pointer;
&:focus {
color: $o-enterprise-action-color;
}
&.focused {
color:$o-main-text-color;
}
}
&:hover {
cursor: pointer;
}
&:focus-within {
border-bottom-color: $o-enterprise-action-color !important;
input {
color: $o-black;
}
}
}
.line_level_0 {
color: $o-gray-700;
font-weight: bold;
> td {
border-bottom: 0 !important;
background-color: $o-gray-300;
}
.muted { color: $o-gray-400 !important }
.btn_debug { color: $o-gray-400 }
}
.line_level_1 > td:nth-child(1) {
padding-left: calc(20px + 0.75rem) !important;
&.unfoldable { padding-left: 0.75rem !important }
}
@for $i from 2 through 16 {
.line_level_#{$i} {
$indentation: ($i - 1) * 8px;
> td:nth-child(1) {
color: $o-gray-700;
padding-left: calc(#{ $indentation } + 20px + 0.75rem) !important;
&.unfoldable { padding-left: calc(#{ $indentation } + 0.75rem) !important }
}
}
}
//------------------------------------------------------------------------------------------------------------------
// Link
//------------------------------------------------------------------------------------------------------------------
.link { color: $o-enterprise-action-color }
//------------------------------------------------------------------------------------------------------------------
// buttons
//------------------------------------------------------------------------------------------------------------------
.btn_debug, .btn_dropdown, .btn_foldable, .btn_sortable, .btn_ellipsis, .btn_more,
.btn_annotation, .btn_annotation_go, .btn_annotation_delete, .btn_action, .btn_edit {
border: none;
color: $o-gray-300;
font-size: inherit;
font-weight: normal;
padding: 0 !important;
text-align: center;
width: 20px;
white-space: nowrap;
&:hover {
color: $o-enterprise-action-color !important;
cursor: pointer;
}
}
.btn_sortable > [data-icon="north"], .btn_sortable > [data-icon="south"] { color: $o-enterprise-action-color }
.btn_foldable { color: $o-gray-500 }
.btn_ellipsis > i { vertical-align: bottom }
.btn_more { opacity: 1 }
.btn_annotation_go { color: $o-gray-600 }
.btn_annotation_delete {
margin-left: 4px;
vertical-align: baseline;
}
.btn_action {
opacity: 0;
background-color: $o-view-background-color;
color: $o-gray-600;
width: auto;
padding: 0 0.25rem !important;
margin: 0 0.25rem;
border: 1px solid $o-gray-300;
border-radius: 0.25rem;
}
//------------------------------------------------------------------------------------------------------------------
// Dropdown
//------------------------------------------------------------------------------------------------------------------
.dropdown { display: inline }
//------------------------------------------------------------------------------------------------------------------
// Chatter
//------------------------------------------------------------------------------------------------------------------
.o_account_report_chatter {
border-left: 1px solid var(--border-color);
// using Min instead of min to trick scss since it doesn't like the usage of additions and var.
max-width: Min(calc(#{$o-mail-Chatter-minWidth} + 20px + var(--Chatter-asideExtraWidth)), 100%);
transition: max-width 0.2s ease-in-out;
.o-mail-Chatter-topbar {
padding-top: 0.25rem;
}
&.o_account_report_chatter_hidden {
max-width: 0;
transition: max-width 0.2s ease-in-out;
height: 0 !important;
.o-mail-Chatter-top, .o-mail-Chatter-content{
--Chatter-default-padding-x: 0;
--ChatterAsideForm-padding-left: 0;
}
}
}
}
.is_rendering tbody > tr[data-id="line"] > td * { //!\\ Prevents flash on animation when scrolling due to the virtual grids
animation: none !important;
transition: none !important;
}
//----------------------------------------------------------------------------------------------------------------------
// Dialogs
//----------------------------------------------------------------------------------------------------------------------
.account_report_annotation_dialog {
textarea {
border: 1px solid $o-gray-300;
border-radius: 0.25rem;
height: 120px;
padding: .5rem;
}
}
//----------------------------------------------------------------------------------------------------------------------
// Popovers
//----------------------------------------------------------------------------------------------------------------------
.account_report_popover_edit {
padding: .5rem 1rem;
box-sizing: content-box;
.edit_popover_boolean label { padding: 0 12px 0 4px }
.edit_popover_string {
width: 260px;
padding: 8px;
border-color: $o-gray-200;
}
.btn {
color: $o-white;
background-color: $o-enterprise-action-color;
}
}
.account_report_popover_ellipsis {
> p {
float: left;
margin: 1rem;
width: 360px;
}
}
.account_report_btn_clone {
margin: 1rem 1rem 0 0;
border: none;
color: $o-gray-300;
font-size: inherit;
font-weight: normal;
padding: 0;
text-align: center;
width: 20px;
&:hover {
color: $o-enterprise-action-color !important;
cursor: pointer;
}
}
.account_report_popover_debug {
width: 350px;
overflow-x: auto;
> .line_debug {
display: flex;
flex-direction: row;
padding: .25rem 1rem;
&:first-child { padding-top: 1rem }
&:last-child { padding-bottom: 1rem }
> span:first-child {
color: $o-gray-600;
max-width: 25%; //!\\ Not the same as 'width' because of 'display: flex'
min-width: 25%; //!\\ Not the same as 'width' because of 'display: flex'
white-space: nowrap;
margin-right: 10px;
}
> span:last-child {
color: $o-gray-800;
max-width: 75%; //!\\ Not the same as 'width' because of 'display: flex'
min-width: 75%; //!\\ Not the same as 'width' because of 'display: flex'
}
}
> .totals_separator { margin: .25rem 1rem }
> .engine_separator { margin: 1rem }
}
.carryover_popover {
margin: 12px;
width: 300px;
}
.o_web_client:has(.annotation_popover) {
.popover:has(.annotation_tooltip) { visibility: hidden; }
.popover:has(.annotation_popover) {
max-height: 45%;
max-width: 60%;
white-space: pre-wrap;
overflow-y: auto;
.annotation_popover {
overflow: scroll;
.annotation_popover_line th{
background-color: $o-white;
position: sticky;
top: 0;
z-index: 10;
}
}
.annotation_popover_line:nth-child(2n+2) { background: $o-gray-200; }
.annotation_popover_line {
.o_datetime_input {
border: none;
}
}
tr, th, td:not(:has(.btn_annotation_update)):not(:has(.btn_annotation_delete)) {
padding: .5rem 1rem .5rem .5rem;
vertical-align: top;
}
.annotation_popover_editable_cell {
background-color: transparent;
border: 0;
box-shadow: none;
color: $o-gray-700;
resize: none;
width: 85px;
outline: none;
}
}
}
label:focus-within input { border: 0; }
.popover:has(.annotation_tooltip) {
> .tooltip-inner {
padding: 0;
color: $o-white;
background-color: $o-white;
> .annotation_tooltip {
color: $o-gray-700;
background-color: $o-white;
white-space: pre-wrap;
> .annotation_tooltip_line:nth-child(2n+2) { background: $o-gray-200; }
tr, th, td {
padding: .25rem .5rem .25rem .25rem;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
}
}
+ .popover-arrow {
&.top-0::after { border-right-color: $o-white; }
&.bottom-0::after { border-left-color: $o-white; }
&.start-0::after { border-bottom-color: $o-white; }
&.end-0::after { border-top-color: $o-white; }
}
}
}
//----------------------------------------------------------------------------------------------------------------------
// Chatter
//----------------------------------------------------------------------------------------------------------------------
.o_account_report_mobile_chatter {
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
height: 60vh;
background-color: $o-view-background-color;
transform: translateY(0);
transition: transform 0.2s ease-in-out;
overflow: scroll;
&.o_account_report_mobile_chatter_hidden {
transform: translateY(100%);
}
}

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReport">
<t t-call="{{ this.controller.template('AccountReport') }}"/>
</t>
<t t-name="account_reports.AccountReportCustomizable">
<div class="o_action account_report" t-att-class="this.cssCustomClass()" t-ref="this.rootRef" t-on-keydown="this.onKeydown" t-on-click="this.onClick">
<ControlPanel display="{ adaptToScroll: false }">
<!-- Buttons bar -->
<t t-set-slot="control-panel-buttons">
<AccountReportButtonsBar/>
</t>
<t t-set-slot="control-panel-additional-actions">
<AccountReportCogMenu/>
</t>
<!-- Search bar (if configured for report) and filters -->
<t t-set-slot="control-panel-actions">
<div class="d-flex gap-1">
<button
class="btn btn-outline-secondary h-100 d-md-none" type="button"
data-bs-toggle="collapse" data-bs-target="#reportFilterCollapse"
>
<span class="oi oi-filled" data-icon="filter_alt"/>
</button>
<div id="reportFilterCollapse" t-att-class="this.ui.isSmall() ? 'collapse' : ''">
<div class="d-flex gap-1 flex-wrap">
<t t-if="this.controller.cachedFilterOptions().search_bar">
<AccountReportSearchBar initialQuery="this.initialQuery"/>
</t>
<t t-component="this.controller.component('AccountReportFilters')"/>
</div>
</div>
</div>
</t>
<t t-set-slot="control-panel-navigation-additional" t-if="this.controller.chatterState.id()">
<button
t-on-click="() => this.controller.closeChatter()"
data-tooltip="Chatter"
class="btn btn-secondary o_switch_view o_kanban d-inline active">
<i class="oi oi-fw mt-1" t-attf-data-icon="close"/>
</button>
</t>
</ControlPanel>
<div t-attf-class="d-flex h-100 {{ this.ui.isSmall() ? 'flex-column' : 'flex-row o_content' }}">
<div class="d-flex flex-column w-100" style="min-width: 0;">
<!-- Sections -->
<t t-if="this.controller.cachedFilterOptions().sections.length">
<div id="section_selector" class="section_selector">
<t t-foreach="this.controller.cachedFilterOptions().sections" t-as="section" t-key="section_index">
<button
t-att-class="(this.controller.cachedFilterOptions().selected_section_id === section.id) ? 'btn btn-outline-primary' : 'btn btn-secondary'"
t-on-click="() => this.controller.switchToSection(section.id)"
t-out="section.name"
/>
</t>
<t t-if="this.controller.cachedFilterOptions()['has_inactive_sections']">
<button class="btn btn-secondary" t-on-click="(ev) => this.controller.reportAction(ev, 'action_display_inactive_sections')" >+</button>
</t>
</div>
</t>
<!-- Warnings -->
<t t-if="this.controller.data() and this.controller.warnings">
<div id="warnings" class="warnings d-print-none">
<t t-foreach="this.controller.warnings" t-as="warningTemplateRef" t-key="warningTemplateRef">
<t t-set="warningParams" t-value="this.controller.warnings[warningTemplateRef]"/>
<div t-if="warningParams" t-att-class="`alert alert-${warningParams['alert_type'] || 'info'} alert-dismissible fade show text-center`">
<t t-call="{{ warningTemplateRef }}"/>
<button type="button"
class="btn-close"
data-bs-dismiss="alert"
t-on-click="(ev) => ev.currentTarget.disabled = true"
aria-label="Close">
</button>
</div>
</t>
</div>
</t>
<t t-if="this.controller.data() === null">
<div class="o_view_nocontent">
<div class="text-center mt-4">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</t>
<t t-elif="this.controller.data().lines.length > 0">
<!-- Table -->
<div class="mx-auto o_account_report_scroll_container overflow-x-auto" t-ref="this.virtualScrollableRef">
<div class="d-flex align-items-start o_account_report_scroll_content">
<t t-set="LineComponent" t-value="this.controller.component('AccountReportLine')"/>
<t t-foreach="this.controller.options().horizontal_split ? ['left', 'right'] : ['left']" t-as="splitSide" t-key="splitSide">
<table
class="table table-borderless table-hover mx-auto"
t-att-class="this.tableClasses()"
>
<t t-component="this.controller.component('AccountReportHeader')"/>
<tbody>
<AccountReportPadding height="this.controller.virtualData[splitSide].top"/>
<t t-foreach="this.controller.virtualData[splitSide].lines()" t-as="virtualLine" t-key="virtualLine_index">
<t t-component="LineComponent" t-props="{
line: virtualLine.line,
lineIndex: virtualLine.lineIndex,
virtualLineIndex: virtualLine_index,
numberOfVirtualLines: this.controller.virtualData[splitSide].numberOfVirtualLines,
}"/>
</t>
<!-- Since finding the largest width for every line without rendering them is impossible,
We use this fake line to find the largest width of every rendered columns and make sure
once it's de-rendered we still keep the same width -->
<tr class="o_fake_line" t-ref="this.controller.fakeLineRefs" t-att-id="splitSide">
<td/>
<t t-foreach="this.controller.options().columns" t-as="col" t-key="col_index">
<td/>
</t>
<td t-if="this.controller.needsColumnPercentComparison"/>
<td t-if="this.controller.hasDebugColumn"/>
</tr>
<AccountReportPadding height="this.controller.virtualData[splitSide].bottom"/>
</tbody>
</table>
</t>
</div>
</div>
</t>
<t t-else="">
<div class="o_view_nocontent">
<div class="o_nocontent_help">
<p class="o_view_nocontent_neutral_face">No data to display !</p>
<p>There is no data to display for the given filters.</p>
</div>
</div>
</t>
<t t-if="this.ui.isSmall()"> <!-- Spacer to avoid chatter overlapping content on small devices due to the fixed position of the chatter -->
<div
style="transition: height 0.2s ease-in-out;"
t-att-style="this.controller.chatterState.model() ? 'height: 60vh;' : 'height: 0;'"
/>
</t>
</div>
<div t-att-class="{
'o_account_report_chatter o-mail-ChatterContainer h-100 o-aside d-flex flex-column': !this.ui.isSmall(),
'o_account_report_chatter_hidden': !this.ui.isSmall() and !this.controller.chatterState.model(),
'o_account_report_mobile_chatter': this.ui.isSmall(),
'o_account_report_mobile_chatter_hidden': this.ui.isSmall() and !this.controller.chatterState.model(),
}">
<AccountReportChatter
threadModel="this.controller.chatterState.model()"
threadId="this.controller.chatterState.id()"
isChatterAside="!this.ui.isSmall()"
reportController="this.controller"
date_to="this.controller.options().date.date_to"
t-if="this.controller.chatterState.model()"
/>
</div>
</div>
</div>
</t>
<t t-name="account_reports.AccountReportPadding">
<!-- As the heights get refreshed every time we scroll, by keeping this component separate from the entire AccountReport code,
we prevent the entirety of the AccountReport template from being re-rendered -->
<tr t-att-style="'height: ' + this.props.height() + 'px;'"/>
</t>
</templates>

View File

@@ -0,0 +1,25 @@
import { Component, usePlugin } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
export class AccountReportButtonsBar extends Component {
static template = "account_reports.AccountReportButtonsBar";
controller = usePlugin(AccountReportController);
//------------------------------------------------------------------------------------------------------------------
// Buttons
//------------------------------------------------------------------------------------------------------------------
get barButtons() {
const buttons = [];
for (const button of this.controller.buttons) {
if (button.always_show) {
buttons.push(button);
}
}
return buttons;
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportButtonsBar">
<t t-foreach="this.barButtons" t-as="barButton" t-key="barButton_index">
<button
t-att-class="'btn text-nowrap' + (barButton.disabled ? ' disabled' : '') + (barButton_first ? ' btn-primary' : ' btn-secondary')"
t-on-click="(ev) => this.controller.buttonAction(ev, barButton)"
>
<t t-out="barButton.name"/>
</button>
</t>
</t>
</templates>

View File

@@ -0,0 +1,32 @@
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { Component, usePlugin } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
export class AccountReportCogMenu extends Component {
static template = "account_reports.AccountReportCogMenu";
static components = {Dropdown, DropdownItem};
controller = usePlugin(AccountReportController);
//------------------------------------------------------------------------------------------------------------------
// Buttons
//------------------------------------------------------------------------------------------------------------------
get cogButtons() {
const buttons = [];
for (const button of this.controller.buttons) {
if (!button.always_show) {
buttons.push({
...button,
onClick: (ev) => this.controller.buttonAction(ev, button),
});
}
}
return buttons;
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="account_reports.AccountReportCogMenu">
<t t-if="this.cogButtons.length">
<Dropdown>
<button class="btn p-0 ms-1 border-0">
<i class="oi oi-fw oi-filled" data-icon="settings"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.cogButtons" t-as="cogButton" t-key="cogButton_index">
<DropdownItem onSelected="cogButton.onClick">
<t t-out="cogButton.name"/>
</DropdownItem>
</t>
</t>
</Dropdown>
</t>
</t>
</templates>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
import { _t } from "@web/core/l10n/translation";
import { localization } from "@web/core/l10n/localization";
import { registry } from "@web/core/registry";
import { PopoverPlugin } from "@web/core/popover/popover_plugin";
import { NotificationPlugin } from "@web/core/notifications/notification_plugin";
import { Component, t, usePlugin, useProps } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
import { AccountReportEllipsisPopover } from "@account_reports/components/account_report/ellipsis/popover/ellipsis_popover";
export class AccountReportEllipsis extends Component {
static template = "account_reports.AccountReportEllipsis";
props = useProps({
name: t.signal(t.string()).optional(),
no_format: t.signal(t.string()).optional(),
type: t.or([t.signal(t.string()), t.function([],t.string())]).optional(),
maxCharacters: t.number(),
});
controller = usePlugin(AccountReportController);
popover = usePlugin(PopoverPlugin);
notification = usePlugin(NotificationPlugin);
//------------------------------------------------------------------------------------------------------------------
// Ellipsis
//------------------------------------------------------------------------------------------------------------------
get triggersEllipsis() {
const name = this.props.name?.();
return name && name.length > this.props.maxCharacters;
}
copyEllipsisText() {
navigator.clipboard.writeText(this.props.name?.());
this.notification.add(_t("Text copied"), { type: 'success' });
this.popoverCloseFn();
this.popoverCloseFn = null;
}
showEllipsisPopover(ev) {
ev.preventDefault();
ev.stopPropagation();
if (this.popoverCloseFn) {
this.popoverCloseFn();
this.popoverCloseFn = null;
}
this.popoverCloseFn = this.popover.add(
ev.currentTarget,
AccountReportEllipsisPopover,
{
name: this.props.name?.(),
copyEllipsisText: this.copyEllipsisText.bind(this),
},
{
closeOnClickAway: true,
position: localization.direction === "rtl" ? "left" : "right",
},
);
}
}
registry.category("account_reports.default_components").add("AccountReportEllipsis", AccountReportEllipsis);

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportEllipsis">
<t t-call="{{ this.controller.template('AccountReportEllipsis') }}"/>
</t>
<t t-name="account_reports.AccountReportEllipsisCustomizable">
<t t-set="name" t-value="this.props.name?.()"/>
<t t-if="this.props.type?.() === 'string'">
<t t-out="name ? name.substring(0, this.props.maxCharacters) : ''"/>
<i class="btn btn_ellipsis oi"
data-icon="more_horiz"
t-if="this.triggersEllipsis"
t-on-click="(ev) => this.showEllipsisPopover(ev)"
/>
</t>
<t t-else="">
<t t-out="name"/>
</t>
</t>
</templates>

View File

@@ -0,0 +1,10 @@
import { Component, t, useProps } from "@odoo/owl";
export class AccountReportEllipsisPopover extends Component {
static template = "account_reports.AccountReportEllipsisPopover";
props = useProps({
close: t.function(),
name: t.string(),
copyEllipsisText: t.function(),
});
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportEllipsisPopover">
<div class="account_report_popover_ellipsis">
<p t-out="this.props.name"/>
<button class="btn account_report_btn_clone" t-on-click="() => this.props.copyEllipsisText()">
<i class="oi" data-icon="assignment"/>
</button>
</div>
</t>
</templates>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterAccountType">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi oi-filled me-1" data-icon="person"/>Account: <t t-out="this.selectedAccountType"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.controller.cachedFilterOptions().account_type" t-as="accountTypeItem" t-key="accountTypeItem_index">
<DropdownItem
class="{ selected: accountTypeItem.selected }"
onSelected="() => this.filterClicked({ optionKey: 'account_type.' + accountTypeItem_index + '.selected', reload: true})"
closingMode="'none'"
t-out="accountTypeItem.name"
/>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportAmlIrFilters">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi oi-filled me-1" data-icon="star"/>Filters: <t t-out="this.selectedAmlIrFilters"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.controller.cachedFilterOptions().aml_ir_filters" t-as="amlIrFilter" t-key="amlIrFilter_index">
<DropdownItem
class="{ 'selected': amlIrFilter.selected }"
onSelected="() => this.filterClicked({ optionKey: 'aml_ir_filters.' + amlIrFilter_index + '.selected', reload: true})"
closingMode="'none'"
t-out="amlIrFilter.name"
/>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterAnalyticGroupby">
<Dropdown
menuClass="'account_report_filter analytic_groupby'"
>
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="group"/>Analytic
</button>
<t t-set-slot="content">
<div class="dropdown-item gap-2 align-items-center">
<label>Accounts</label>
<MultiRecordSelector t-props="this.getMultiRecordSelectorProps('account.analytic.account', 'analytic_accounts_groupby')"/>
</div>
<div class="dropdown-item gap-2 align-items-center">
<label>Plans</label>
<MultiRecordSelector t-props="this.getMultiRecordSelectorProps('account.analytic.plan', 'analytic_plans_groupby')"/>
</div>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterBudget">
<Dropdown
navigationOptions="this.dropdownProps"
>
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="bar_chart"/>Budget
</button>
<t t-set-slot="content">
<t t-foreach="this.controller.cachedFilterOptions().budgets" t-as="budget" t-key="budget_index">
<div class="o-dropdown-item dropdown-item o-navigable d-flex justify-content-between ps-4 pe-1"
t-att-class="{ 'selected': budget.selected }"
t-on-click="() => this.selectBudget(budget)"
>
<span t-out="budget.name"/>
<button class="btn p-0 px-1" t-on-click.prevent.stop="() => this.controller.openBudget(budget)">
<i class="oi oi-filled" data-icon="edit" />
</button>
</div>
</t>
<div class="dropdown-divider"/>
<t t-if="this.controller.cachedFilterOptions().budgets.filter(x => x.selected).length > 0">
<DropdownItem
class="{ 'filter_show_all_accounts_hook': true, 'selected': this.controller.cachedFilterOptions().show_all_accounts }"
onSelected="() => this.filterClicked({ optionKey: 'show_all_accounts', reload: true})"
closingMode="'none'"
>
Show All Accounts
</DropdownItem>
</t>
<div class="o-dropdown-item dropdown-item d-flex align-items-center ps-4 pe-1">
<input
class="o_input"
t-att-class="{ 'o_field_invalid': this.budgetName.invalid }"
type="text"
placeholder="Budget Name"
t-model.proxy="this.budgetName.value"
/>
<button class="btn btn-link" data-hotkey="s" t-on-click="this.createBudget">
Create
</button>
</div>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,196 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.AccountReportComparisonPeriod">
<div t-att-class="(this.controller.cachedFilterOptions().comparison.filter !== filter) ? 'invisible' : ''">
<input
min="1"
type="number"
t-att-value="this.controller.cachedFilterOptions().comparison.number_period"
t-on-change="(ev) => this.setNumberPeriods(ev)"
/>
<label>
<t t-out="this.periodLabel"/>
</label>
</div>
</t>
<t t-name="account_reports.AccountReportFilterComparison">
<Dropdown
menuClass="'account_report_filter comparison'"
navigationOptions="this.dropdownProps"
>
<button class="btn btn-secondary">
<span>Comparison</span>
<t t-if="this.controller.cachedFilterOptions().comparison.string">
<span>: </span>
<t t-if="this.controller.cachedFilterOptions().comparison.filter === 'previous_period'">
<t t-if="this.controller.cachedFilterOptions().comparison.number_period === 1">
<span>Previous Period</span>
</t>
<t t-elif="this.controller.cachedFilterOptions().comparison.number_period > 1">
<t t-out="`${ this.controller.cachedFilterOptions().comparison.number_period } `"/>
<span>Previous Periods</span>
</t>
</t>
<t t-elif="this.controller.cachedFilterOptions().comparison.filter === 'same_last_year'">
<t t-if="this.controller.cachedFilterOptions().comparison.number_period === 1">
<span>Previous Year</span>
</t>
<t t-elif="this.controller.cachedFilterOptions().comparison.number_period > 1">
<t t-out="`${ this.controller.cachedFilterOptions().comparison.number_period } `"/>
<span>Previous Years</span>
</t>
</t>
<t t-else="">
<t t-out="`${ this.controller.cachedFilterOptions().comparison.string }`"/>
</t>
</t>
<t t-elif="this.controller.cachedFilterOptions().comparison.filter === 'report_line' &amp;&amp; this.controller.cachedFilterOptions().comparison.base_report_line?.name ">
<t t-set="reportLineName" t-value="this.controller.cachedFilterOptions().comparison.base_report_line.name"/>
<span>: </span>
<span t-out="reportLineName.slice(0, 25)"/>
<span t-if="reportLineName.length > 25" t-att-title="reportLineName">...</span>
</t>
</button>
<t t-set-slot="content">
<DropdownItem
class="{ 'selected': (this.controller.cachedFilterOptions().comparison.filter === 'no_comparison') }"
onSelected="() => this.filterClicked({ optionKey: 'comparison.filter', optionValue: 'no_comparison', reload: true})"
closingMode="'none'"
>
No Comparison
</DropdownItem>
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().comparison.filter === 'previous_period', 'dropdown-item': true, 'period': true }"
onSelected="() => this.filterClicked({ optionKey: 'comparison.filter', optionValue: 'previous_period', reload: true})"
closingMode="'none'"
>
<label class="d-flex align-items-center">
Previous Period
</label>
<t t-call="account_reports.AccountReportComparisonPeriod" filter="'previous_period'"/>
</DropdownItem>
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().comparison.filter === 'same_last_year', 'dropdown-item': true, 'period': true }"
attrs="{ 'name': 'filter_comparison_same_period_last_year' }"
onSelected="() => this.filterClicked({ optionKey: 'comparison.filter', optionValue: 'same_last_year', reload: true})"
closingMode="'none'"
>
<label class="d-flex align-items-center">
Same Period Last Year
</label>
<t t-call="account_reports.AccountReportComparisonPeriod" filter="'same_last_year'"/>
</DropdownItem>
<t t-if="this.controller.filters.show_line_comparison">
<div class="dropdown-item o-navigable d-flex gap-2 align-items-center"
t-att-class="{ 'selected': this.controller.cachedFilterOptions().comparison.filter === 'report_line' }"
>
<label class="me-2 mb-0">Percentage of </label>
<div>
<RecordSelector t-props="this.reportLineComparisonProps" />
</div>
</div>
</t>
<t t-if="this.isRangeMode">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().comparison.filter === 'custom', 'dropdown-item': true, 'date': true }"
attrs="{ 'name': 'filter_comparison_custom' }"
onSelected="() => this.filterClicked({ optionKey: 'comparison.filter', optionValue: 'custom', reload: true})"
closingMode="'none'"
>
<label class="d-flex align-items-center">
Custom Dates
</label>
<div class="d-flex flex-row"
t-att-class="(this.controller.cachedFilterOptions().comparison.filter !== 'custom') ? 'invisible' : ''">
<DateTimeInput
type="'date'"
value="this.dateFrom('comparison')"
onChange="(dateFrom) => this.setCustomComparisonDate('from', dateFrom)"
/>
<label class="d-flex align-items-center">
to
</label>
<DateTimeInput
type="'date'"
value="this.dateTo('comparison')"
onChange="(dateTo) => this.setCustomComparisonDate('to', dateTo)"
/>
</div>
</DropdownItem>
</t>
<t t-if="!this.isRangeMode">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().comparison.filter === 'custom', 'dropdown-item': true, 'date': true }"
onSelected="() => this.filterClicked({ optionKey: 'comparison.filter', optionValue: 'custom', reload: true})"
closingMode="'none'"
>
<label class="d-flex align-items-center">
Specific Date
</label>
<div t-att-class="(this.controller.cachedFilterOptions().comparison.filter !== 'custom') ? 'invisible' : ''">
<DateTimeInput
type="'date'"
value="this.dateTo('comparison')"
onChange="(dateTo) => this.setCustomComparisonDate('to', dateTo)"
/>
</div>
</DropdownItem>
</t>
<t t-if="!this.controller.cachedFilterOptions().comparison.hide_period_order_filter">
<div class="dropdown-divider"/>
<div class="dropdown-item period order">
<label class="d-flex align-items-center pe-none">
Period order
</label>
<div>
<select name="select_order"
class="o_input pe-3"
t-on-change="(ev) => this.filterClicked({ optionKey: 'comparison.period_order', optionValue: ev.target.value, reload: true})">
<option t-foreach="this.availablePeriodOrder"
t-as="order"
t-key="order_index"
t-att-value="order"
t-att-selected="this.availablePeriodOrder[order] === this.periodOrder"
t-out="this.availablePeriodOrder[order]"
/>
</select>
</div>
</div>
</t>
<t t-if="!this.controller.cachedFilterOptions().hide_growth_display_filter">
<div class="dropdown-item period order">
<label class="d-flex align-items-center pe-none">
Comparison in
</label>
<div>
<select name="select_growth_display"
class="o_input pe-3"
t-on-change="(ev) => this.filterClicked({ optionKey: 'growth_display', optionValue: ev.target.value, reload: true })">
<option value="percent" t-att-selected="this.controller.cachedFilterOptions().growth_display === 'percent'">Percentage</option>
<option value="amount" t-att-selected="this.controller.cachedFilterOptions().growth_display === 'amount'">Amount</option>
</select>
</div>
</div>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterDate">
<Dropdown
t-if="this.controller.cachedFilterOptions().report_id == this.dateFilterState.reportId"
menuClass="'account_report_filter date'"
navigationOptions="this.dateNavigationOptions"
>
<button class="btn btn-secondary">
<i class="oi oi-filled me-1" data-icon="calendar_today"/>
<t t-out="this.getDateDescription()"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.availableDateFiltersSorted" t-as="dateFilter" t-key="dateFilter.key">
<DropdownItem
t-if="this.isFilterVisible(dateFilter.key)"
tag="'div'"
class="{
'd-flex justify-content-between date_filter': true,
'date_filter_month': dateFilter.key === 'month',
'date_filter_quarter': dateFilter.key === 'quarter',
'date_filter_year': dateFilter.key === 'year',
'selected': this.isFilterDateSelected(dateFilter.key),
}"
attrs="{
'data-period-type': dateFilter.key,
'date-mode': this.isRangeMode ? 'range' : 'single'
}"
onSelected="() => this.selectDateFilter(dateFilter.key)"
closingMode="'none'"
>
<t t-if="dateFilter.key === 'today'" t-out="dateFilter.label"/>
<t t-else="">
<div class="filter_name" t-out="dateFilter.label"/>
<div class="d-flex justify-content-between">
<button
class="btn_previous_date oi"
data-icon="arrow_left"
t-on-click="() => this.selectNewPeriod(dateFilter, -1)"
/>
<t t-set="date_display" t-value="this.getFilterDateDisplay(dateFilter)"/>
<input
class="o_input input_current_date"
type="text"
t-att-data-value="date_display"
t-att-value="date_display"
t-att="{'readonly': this.dateFilterState.editing !== dateFilter.key}"
t-on-change="ev => this.writeDate(dateFilter, ev.target)"
/>
<button
class="btn_next_date oi"
data-icon="arrow_right"
t-on-click="() => this.selectNewPeriod(dateFilter, 1)"
/>
</div>
</t>
</DropdownItem>
</t>
<div id="filter_date_divider_single" class="dropdown-divider"/>
<DropdownItem
tag="'div'"
class="{
'date d-flex justify-content-between': true,
'selected': this.isFilterDateSelected('custom'),
}"
attrs="{
'data-period-type': 'custom',
'date-mode': this.isRangeMode ? 'range' : 'single'
}"
onSelected="() => this.selectDateFilter('custom')"
closingMode="'none'"
>
<div t-if="!this.isRangeMode" class="filter_name">
Specific Date
</div>
<div t-else="" class="filter_name">
Custom Dates
</div>
<div
t-if="!this.isRangeMode and (this.isFilterDateSelected('custom') or this.isFilterDateSelected('year'))"
class="d-flex justify-content-center flex-grow-1"
>
<DateTimeInput
type="'date'"
class="'o-navigable'"
value="this.customDateTo"
onChange="(dateTo) => this.setCustomDateTo(dateTo)"
/>
</div>
<div t-elif="this.isFilterDateSelected('custom') or this.isFilterDateSelected('year')" class="d-flex justify-content-center flex-grow-1">
<DateTimeInput
type="'date'"
class="'o-navigable'"
value="this.customDateFrom"
onChange="(dateFrom) => this.setCustomDateFrom(dateFrom)"
/>
<span class="d-flex align-items-center">
to
</span>
<DateTimeInput
type="'date'"
class="'o-navigable'"
value="this.customDateTo"
onChange="(dateTo) => this.setCustomDateTo(dateTo)"
minDate="this.customDateFrom"
/>
</div>
</DropdownItem>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterExtraOptions">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="tune"/>
<t t-if="this.selectedExtraOptions">
<t t-out="this.selectedExtraOptions"/>
</t>
<t t-else="">
Options
</t>
</button>
<t t-set-slot="content">
<t
t-foreach="Object.entries(this.filterExtraOptionsData)"
t-as="filter"
t-key="filter[0]"
>
<t t-if="!filter[1].ui_filter and this.isExtraOptionFilterShown(filter[0])">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions()[filter[0]] }"
onSelected="() => this.filterClicked({ optionKey: filter[0], reload: true})"
closingMode="'none'"
>
<t t-out="filter[1].name"/>
</DropdownItem>
</t>
</t>
<div class="dropdown-divider" t-if="this.hasUIFilter"/>
<t
t-foreach="Object.entries(this.filterExtraOptionsData)"
t-as="filter"
t-key="filter[0]"
>
<t t-if="filter[1].ui_filter and this.isExtraOptionFilterShown(filter[0])">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions()[filter[0]] }"
onSelected="filter[1].onSelect"
>
<t t-out="filter[1].name"/>
</DropdownItem>
</t>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterHorizontalGroups">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi oi-filled me-1" data-icon="filter_alt"/>Group: <t t-out="this.selectedHorizontalGroupName"/>
</button>
<t t-set-slot="content">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().selected_horizontal_group_id === null }"
onSelected="() => this.selectHorizontalGroup(null)"
closingMode="'none'"
>
None
</DropdownItem>
<t t-foreach="this.controller.cachedFilterOptions().available_horizontal_groups" t-as="horizontalGroup" t-key="horizontalGroup_index">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().selected_horizontal_group_id === horizontalGroup.id }"
onSelected="() => this.selectHorizontalGroup(horizontalGroup.id)"
closingMode="'none'"
>
<t t-out="horizontalGroup.name"/>
</DropdownItem>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterJournal">
<Dropdown disabled="!this.controller.cachedFilterOptions().journals.length">
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="book"/>
<t t-out="this.controller.cachedFilterOptions().name_journal_group"/>
</button>
<t t-set-slot="content">
<t t-if="this.controller.cachedFilterOptions().journal_groups.length > 0">
<div t-att-class="'d-flex dropdown-header w-100 align-items-center'">
<span>
Multi-ledger
</span>
</div>
<t t-foreach="this.controller.cachedFilterOptions().journal_groups" t-as="group" t-key="group_index">
<DropdownItem
class="{ 'selected': group.selected, 'ps-4': true }"
onSelected="() => this.selectGroup(group)"
closingMode="'none'"
t-out="group.name"
/>
</t>
</t>
<t t-if="this.controller.cachedFilterOptions().filters.show_journals">
<t t-foreach="Object.entries(this.companyName2Journals)" t-as="companyJournal" t-key="companyJournal[0]">
<div t-att-class="'d-flex dropdown-header w-100 align-items-center pt-0 ps-0 mx-0 my-1'">
<button class="btn btn_foldable d-flex align-items-center w-100 border-0"
t-on-click="() => this.unfoldCompanyJournals(companyJournal[0])"
>
<i class="oi" t-att-data-icon="companyJournal[1][0].unfolded ? 'arrow_drop_down' : 'arrow_right'"/>
<span class="pt-0 mt-0 ps-2 dropdown-header" t-out="companyJournal[0]"/>
</button>
</div>
<t t-foreach="companyJournal[1]" t-as="journal" t-key="journal_index">
<DropdownItem
class="{ 'selected': journal.selected, 'ps-4': true, 'd-none': !journal.visible }"
onSelected="() => this.selectJournal(journal)"
closingMode="'none'"
t-out="journal.name"
/>
</t>
</t>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterPartner">
<Dropdown
menuClass="'account_report_filter partner'"
>
<button class="btn btn-secondary">
<i class="oi oi-filled me-1" data-icon="folder_open"/>
<t t-out="this.selectedPartnerFilters"/>
</button>
<t t-set-slot="content">
<div class="dropdown-item gap-2 align-items-center">
<label>Partners</label>
<MultiRecordSelector t-props="this.getMultiRecordSelectorProps('res.partner', 'partner_ids')" domain="['|', ['parent_id', '=', false], ['is_company', '=', true]]"/>
</div>
<div class="dropdown-item gap-2 align-items-center">
<label>Tags</label>
<MultiRecordSelector t-props="this.getMultiRecordSelectorProps('res.partner.category', 'partner_categories')"/>
</div>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterRoundingUnit">
<Dropdown>
<button class="btn btn-secondary">
<t t-out="this.roundingUnitName(this.controller.cachedFilterOptions().rounding_unit)"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.controller.cachedFilterOptions().rounding_unit_names" t-as="roundingUnitValue" t-key="roundingUnitValue_index">
<DropdownItem
class="{ 'selected': (this.controller.cachedFilterOptions().rounding_unit == roundingUnitValue) }"
onSelected="() => this.filterRoundingUnit(roundingUnitValue)"
>
<t t-out="this.roundingUnitName(roundingUnitValue)"/>
</DropdownItem>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterTaxUnit">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="home"/>Tax Unit: <t t-out="this.selectedTaxUnitName"/>
</button>
<t t-set-slot="content">
<t t-if="this.controller.cachedUserGroups.account_readonly">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().tax_unit === 'company_only' }"
onSelected="() => this.filterClicked({ optionKey: 'tax_unit', optionValue: 'company_only', reload: true})"
>
Company Only
</DropdownItem>
</t>
<t t-foreach="this.controller.cachedFilterOptions().available_tax_units" t-as="taxUnit" t-key="taxUnit_index">
<t t-if="taxUnit_first">
<div class="dropdown-divider"/>
</t>
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().tax_unit === taxUnit.id }"
onSelected="() => this.filterTaxUnit(taxUnit)"
t-out="taxUnit.name"
/>
</t>
</t>
</Dropdown>
</t>
</templates>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilterVariant">
<Dropdown>
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="book"/>Report: <t t-out="this.selectedVariantName"/>
</button>
<t t-set-slot="content">
<t t-foreach="this.controller.cachedFilterOptions().available_variants" t-as="variant" t-key="variant_index">
<DropdownItem
class="{ 'selected': this.controller.cachedFilterOptions().selected_variant_id === variant.id }"
onSelected="() => this.filterVariant(variant.id)"
t-out="variant.name"
/>
</t>
<t t-if="this.controller.cachedFilterOptions().has_inactive_variants">
<div role="separator" class="dropdown-divider"/>
<DropdownItem onSelected="(ev) => this.controller.reportAction(ev, 'action_view_all_variants', {})">
Enable more ...
</DropdownItem>
</t>
</t>
</Dropdown>
</t>
</templates>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,114 @@
.account_report_filter {
&.date {
.date_filter:hover .btn_previous_date,
.date_filter:hover .btn_next_date:not(:disabled) {
color: $o-gray-600;
}
.filter_name {
min-width: 20ch;
padding: 1px 0;
border: var(--border-width) solid transparent;
border-width: 0 0 var(--border-width) 0;
margin-right: 16px;
}
.btn_previous_date, .btn_next_date {
background: inherit;
border: var(--border-width) solid transparent;
border-width: 0 0 var(--border-width) 0;
color: $o-gray-300;
padding: 1px 0;
text-align: center;
width: 20px;
}
.date_filter .o_input {
min-width: 20ch;
padding: 0 4px;
margin: 0 8px;
border-color: var(--o-input-border-color);
text-align: center;
&[readonly] {
cursor: pointer;
}
&[readonly]:not(:focus) {
border-color: transparent;
}
&:not([readonly]):focus {
@include print-variable(o-input-border-color, $o-action);
}
}
}
&.date, &.comparison {
.dropdown-item.date {
display: flex;
justify-content: space-between;
.o_datetime_input {
display: inline;
width: 10ch;
margin: 0 8px;
text-align: center;
}
}
}
&.comparison, &.intervals {
.dropdown-item.period, .dropdown-item.interval {
display: flex;
justify-content: space-between;
&.order:hover {
background-color: unset;
color: unset;
cursor: default;
}
input[type=number] {
display: inline;
width: 86px;
margin: 0 8px;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 1px solid var(--o-input-border-color);
text-align: center;
background-color: inherit;
}
}
.dropdown-item.date {
.o_datetime_input {
display: inline;
width: 86px;
margin: 0 8px;
padding: 0 4px;
text-align: center;
}
}
.dropdown-item.link {
cursor: default;
&.focus, &.selected:hover, &.selected:focus { background-color: inherit; }
}
}
&.analytic_groupby, &.partner {
.dropdown {
display: inherit;
}
.dropdown-item {
display: flex;
label { width: 60px }
}
.dropdown-item.focus, .dropdown-item.selected:hover, .dropdown-item.selected:focus { background-color: inherit; }
.o_input_dropdown { width: 100% }
.o_field_tags {
margin-left: 8px;
flex-direction: column;
flex-grow: 9;
.o_tag { width: fit-content }
}
}
}

View File

@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportFilters">
<t t-call="{{ this.controller.template('AccountReportFilters') }}"/>
</t>
<t t-name="account_reports.AccountReportFiltersCustomizable">
<!-- Date filter -->
<t t-if="'date' in this.controller.cachedFilterOptions()">
<div id="filter_date" class="filter_date">
<t t-call="account_reports.AccountReportFilterDate"/>
</div>
</t>
<!-- Comparison filter -->
<t t-if="this.controller.filters.show_period_comparison">
<div id="filter_comparison" class="filter_comparison">
<t t-call="account_reports.AccountReportFilterComparison"/>
</div>
</t>
<!-- Journal filter -->
<t t-if="'journals' in this.controller.cachedFilterOptions()">
<div id="filter_journal">
<t t-call="account_reports.AccountReportFilterJournal"/>
</div>
</t>
<!-- Account type filter -->
<t t-if="'account_type' in this.controller.cachedFilterOptions()">
<div id="filter_account_type">
<t t-call="account_reports.AccountReportFilterAccountType"/>
</div>
</t>
<!-- Analytic groupby filter -->
<t t-if="this.hasAnalyticGroupbyFilter">
<div id="filter_analytic_groupby" class="filter_analytic_groupby">
<t t-call="account_reports.AccountReportFilterAnalyticGroupby"/>
</div>
</t>
<!-- Horizontal groups filter -->
<t t-if="this.controller.cachedFilterOptions().available_horizontal_groups.length > 0">
<div id="filter_horizontal_groups">
<t t-call="account_reports.AccountReportFilterHorizontalGroups"/>
</div>
</t>
<!-- Partner filter -->
<t t-if="'partner' in this.controller.cachedFilterOptions()">
<div id="filter_partner" class="filter_partner">
<t t-call="account_reports.AccountReportFilterPartner"/>
</div>
</t>
<!-- Extra cachedFilterOptions filter -->
<t t-if="this.hasExtraOptionsFilter">
<div id="filter_extra_options">
<t t-call="account_reports.AccountReportFilterExtraOptions"/>
</div>
</t>
<!-- Variant filter -->
<t t-if="this.controller.cachedFilterOptions().available_variants.length > 1">
<div id="filter_variant">
<t t-call="account_reports.AccountReportFilterVariant"/>
</div>
</t>
<!-- Tax unit filter -->
<t t-if="'available_tax_units' in this.controller.cachedFilterOptions() and this.controller.cachedFilterOptions().available_tax_units.length > 0">
<div id="filter_tax_unit">
<t t-call="account_reports.AccountReportFilterTaxUnit"/>
</div>
</t>
<!-- Budget filter -->
<t t-if="'budgets' in this.controller.cachedFilterOptions()">
<div id="filter_budget">
<t t-call="account_reports.AccountReportFilterBudget"/>
</div>
</t>
<!-- User defined filter on journal items -->
<t t-if="'aml_ir_filters' in this.controller.cachedFilterOptions() and this.controller.cachedFilterOptions().aml_ir_filters.length > 0">
<div id="filter_aml_ir_filters">
<t t-call="account_reports.AccountReportAmlIrFilters"/>
</div>
</t>
<div id="filter_rounding_unit">
<t t-call="account_reports.AccountReportFilterRoundingUnit"/>
</div>
<t t-if="this.debugMode.isActive()">
<div id="filter_configuration" class="o-dropdown dropdown o-dropdown--no-caret">
<button
class="btn btn-secondary"
t-on-click="(ev) => this.controller.reportAction(ev, 'action_open_report_form', {}, true)"
>
<i class="oi me-1" data-icon="settings_applications"/>
</button>
</div>
</t>
</t>
</templates>

View File

@@ -0,0 +1,138 @@
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { registry } from "@web/core/registry";
import { Component, usePlugin } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
export class AccountReportHeader extends Component {
static template = "account_reports.AccountReportHeader";
static components = {
Dropdown,
DropdownItem,
};
controller = usePlugin(AccountReportController);
// -----------------------------------------------------------------------------------------------------------------
// Headers
// -----------------------------------------------------------------------------------------------------------------
get columnHeaders() {
const columnHeaders = [];
this.controller.options().column_headers.forEach((columnHeader, columnHeaderIndex) => {
let columnHeadersRow = [];
if (columnHeaderIndex !== 0 || columnHeader.length !== 1) {
for (let i = 0; i < this.controller.columnHeadersRenderData.level_repetitions[columnHeaderIndex]; i++) {
columnHeadersRow = [ ...columnHeadersRow, ...columnHeader];
}
columnHeaders.push(columnHeadersRow);
}
});
return columnHeaders;
}
get companiesHeaderColspan() {
let colspan = this.controller.options().columns.length;
if (this.controller.needsColumnPercentComparison) {
colspan ++;
}
if (this.controller.hasDebugColumn) {
colspan ++;
}
return colspan + 1; // extra +1 because to add colspan for the line name column
}
columnHeadersColspan(column_index, header, compactOffset = 0) {
const firstRowHeader = this.controller.options().column_headers[0];
if (firstRowHeader.length === 1) {
column_index += 1;
}
let colspan = header.colspan || this.controller.columnHeadersRenderData.level_colspan[column_index]
// In case of we need the total column for horizontal we need to increase the colspan of the first row
if(this.controller.options().show_horizontal_group_total && column_index === 0) {
colspan += 1;
}
return colspan;
}
columnHeadersRowspan(header) {
return header?.forced_options?.no_subheader_division
? this.controller.options().column_headers.length - 1
: 1;
}
//------------------------------------------------------------------------------------------------------------------
// Subheaders
//------------------------------------------------------------------------------------------------------------------
get subheaders() {
const columns = JSON.parse(JSON.stringify(this.controller.options().columns));
const columnsPerGroupKey = {};
columns.forEach((column) => {
columnsPerGroupKey[`${column.column_group_index}_${column.expression_label}`] = column;
});
return this.controller.lines[0].columns.map((column) => {
if (columnsPerGroupKey[`${column.column_group_index}_${column.expression_label}`]) {
return columnsPerGroupKey[`${column.column_group_index}_${column.expression_label}`];
} else {
return {
expression_label: "",
sortable: false,
name: "",
colspan: 1,
};
}
});
}
// -----------------------------------------------------------------------------------------------------------------
// Custom subheaders
// -----------------------------------------------------------------------------------------------------------------
get customSubheaders() {
const customSubheaders = [];
this.controller.columnHeadersRenderData.custom_subheaders.forEach(customSubheader => {
customSubheaders.push(customSubheader);
});
return customSubheaders;
}
// -----------------------------------------------------------------------------------------------------------------
// Sortable
// -----------------------------------------------------------------------------------------------------------------
sortableClasses(columnIndex) {
switch (this.controller.linesCurrentOrderByColumn(columnIndex)) {
case "ASC":
return "north";
case "DESC":
return "south";
default:
return "swap_vert";
}
}
async sortLinesByColumn(columnIndex, column) {
if (column.sortable) {
switch (this.controller.linesCurrentOrderByColumn(columnIndex)) {
case "default":
await this.controller.sortLinesByColumnAsc(columnIndex);
break;
case "ASC":
await this.controller.sortLinesByColumnDesc(columnIndex);
break;
case "DESC":
this.controller.sortLinesByDefault();
break;
default:
throw new Error(`Invalid value: ${ this.controller.linesCurrentOrderByColumn(columnIndex) }`);
}
}
}
}
registry.category("account_reports.default_components").add("AccountReportHeader", AccountReportHeader);

View File

@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportHeader">
<t t-call="{{ this.controller.template('AccountReportHeader') }}"/>
</t>
<t t-name="account_reports.AccountReportHeaderCustomizable">
<thead id="table_header" class="sticky">
<!-- Headers -->
<tr data-id="column_companies_row">
<th t-if="this.controller.options().companies.length > 1" t-att-colspan="this.companiesHeaderColspan">
<span class="companies_header" t-out="this.controller.options().companies.map(company => company.name).join(', ')"/>
</th>
</tr>
<t t-foreach="this.columnHeaders" t-as="columnHeader" t-key="columnHeader_index">
<tr data-id="column_headers_row">
<!-- First empty column -->
<th/>
<!-- Other columns -->
<t t-foreach="columnHeader" t-as="header" t-key="header_index">
<th
class="column_header"
t-att-colspan="this.columnHeadersColspan(columnHeader_index, header)"
t-att-rowspan="this.columnHeadersRowspan(header)"
>
<t t-out="header.name"/>
</th>
</t>
<t t-if="this.controller.options().show_horizontal_group_total">
<th class="column_header">
<t>Total</t>
</th>
</t>
<!-- Growth comparison column -->
<t t-if="this.controller.needsColumnPercentComparison">
<!-- We only want to display it once on the first row -->
<t t-if="columnHeader_first">
<th class="column_percent_comparison_header" t-att-rowspan="this.columnHeaders.length">
<t t-if="this.controller.options().growth_display === 'amount'">
Change (<t t-out="this.controller.options().rounding_unit_names.units"/>)
</t>
<t t-else="">
Change (%)
</t>
</th>
</t>
</t>
<!-- Analytic coverage column -->
<t t-if="this.controller.needsAnalyticCoverageColumn">
<t t-if="columnHeader_first">
<th>
<t>Analytic coverage</t>
</th>
</t>
</t>
<!-- Debug column -->
<t t-if="this.controller.hasDebugColumn">
<!-- We only want to display it once on the first row -->
<t t-if="columnHeader_first">
<th class="debug_header">
<i class="oi" data-icon="bug_report"/>
</th>
</t>
</t>
</tr>
</t>
<!-- Custom subheaders -->
<t t-if="this.controller.hasCustomSubheaders">
<tr data-id="column_custom_subheaders_row">
<!-- First empty column -->
<th/>
<!-- Other columns -->
<t t-foreach="this.customSubheaders" t-as="customSubheader" t-key="customSubheader_index">
<th
t-att-colspan="customSubheader.colspan || 1"
t-att-data-expression_label="customSubheader.expression_label"
>
<t t-out="customSubheader.name"/>
</th>
</t>
<!-- Debug column -->
<t t-if="this.controller.hasDebugColumn">
<!-- Empty to prevent a gap beneath the debug label -->
<th/>
</t>
</tr>
</t>
<!-- Subheaders -->
<tr data-id="column_subheaders_row">
<!-- First empty column -->
<th/>
<!-- Other columns -->
<t t-foreach="this.subheaders" t-as="subheader" t-key="subheader_index">
<th
t-att-colspan="subheader.colspan || 1"
t-att-class="subheader.class"
t-att-data-expression_label="subheader.expression_label"
>
<!-- Sortable -->
<t t-if="subheader.sortable">
<button
class="btn btn_sortable"
t-on-click="() => this.sortLinesByColumn(subheader_index, subheader)"
>
<i class="oi" t-att-data-icon="this.sortableClasses(subheader_index)"/>
</button>
</t>
<t t-if="subheader.template">
<t t-call="{{ subheader.template }}"/>
</t>
<t t-else="">
<t t-out="subheader.name"/>
</t>
</th>
</t>
<!-- Debug column -->
<t t-if="this.controller.hasDebugColumn">
<!-- Empty to prevent a gap beneath the debug label -->
<th/>
</t>
<t t-if="this.controller.options().show_horizontal_group_total">
<th>
<!-- Since we have only one column possible with horizontal group totals taking the first element is ok -->
<t t-out="this.subheaders[0].name"/>
</th>
</t>
</tr>
</thead>
</t>
</templates>

View File

@@ -0,0 +1,178 @@
import { localization } from "@web/core/l10n/localization";
import { registry } from "@web/core/registry";
import { PopoverPlugin } from "@web/core/popover/popover_plugin";
import { Component, computed, signal, t, useEffect, usePlugin, useProps } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
import { AccountReportDebugPopover } from "@account_reports/components/account_report/line/popover/debug_popover";
import { AccountReportLineCellEditable } from "@account_reports/components/account_report/line_cell_editable/line_cell_editable";
export class AccountReportLine extends Component {
static template = "account_reports.AccountReportLine";
static components = {
AccountReportLineCellEditable,
};
props = useProps({
line: t.object(),
lineIndex: t.signal(t.number()),
virtualLineIndex: t.number(),
numberOfVirtualLines: t.signal(t.number()),
});
controller = usePlugin(AccountReportController);
popover = usePlugin(PopoverPlugin);
lineRef = signal.ref();
growthComparisonClasses = computed(() => this.getGrowthComparisonClasses());
horizontalGroupTotalClasses = computed(() => this.getHorizontalGroupTotalClasses());
shouldHide = computed(() => this.props.virtualLineIndex >= this.props.numberOfVirtualLines());
hasComparisonData = computed(() => Boolean(this.props.line.column_percent_comparison_data?.figure_type()));
hasDebugData = computed(() => Boolean(this.props.line.debug_popup_data?.()));
isLevel0 = computed(() => this.props.line.level() === 0);
lineClasses = "";
setup() {
useEffect(() => {
const classes = this.getLineClasses();
if (classes === this.lineClasses) return;
const prevLineClasses = this.lineClasses;
this.lineClasses = classes;
const prev = prevLineClasses ? prevLineClasses.trim().split(/\s+/).filter(Boolean) : [];
const next = classes ? classes.trim().split(/\s+/).filter(Boolean) : [];
this.controller.scheduleClassUpdate(this.lineRef, prev, next);
});
}
// -----------------------------------------------------------------------------------------------------------------
// Line
// -----------------------------------------------------------------------------------------------------------------
getLineClasses() {
const line = this.props.line;
let classes = "level" in line ? `line_level_${line.level()}` : "line_level_default";
if (line.unfolded?.() && this.hasVisibleChild())
classes += " unfolded";
if (this.controller.isTotalLine(line.id()))
classes += " total";
if (line.css_class?.())
classes += ` ${line.css_class()}`;
return classes;
}
hasVisibleChild() {
if (!this.controller.data()) return false;
let nextLineIndex = this.props.lineIndex() + 1;
while (this.controller.isNextLineChild(nextLineIndex, this.props.line.id())) {
if (this.controller.lines[nextLineIndex].visible && this.controller.lines[nextLineIndex].search_match !== false)
return true;
nextLineIndex += 1;
}
return false;
}
// -----------------------------------------------------------------------------------------------------------------
// Growth comparison
// -----------------------------------------------------------------------------------------------------------------
getGrowthComparisonClasses() {
let classes = "text-end fw-bold";
switch (this.props.line.column_percent_comparison_data.comparison_mode?.()) {
case "green":
classes += " text-success";
break;
case "muted":
classes += " muted";
break;
case "red":
classes += " text-danger";
break;
}
return classes;
}
// -----------------------------------------------------------------------------------------------------------------
// Total Horizontal Group
// -----------------------------------------------------------------------------------------------------------------
getHorizontalGroupTotalClasses() {
let classes = "text-end";
switch (Math.sign(this.props.line.horizontal_group_total_data?.no_format())) {
case 1:
break;
case 0:
classes += " muted";
break;
case -1:
classes += " text-danger";
break;
}
return classes;
}
//------------------------------------------------------------------------------------------------------------------
// Debug popover
//------------------------------------------------------------------------------------------------------------------
showDebugPopover(ev) {
const close = () => {
this.popoverCloseFn();
this.popoverCloseFn = null;
};
if (this.popoverCloseFn)
close();
this.popoverCloseFn = this.popover.add(
ev.currentTarget,
AccountReportDebugPopover,
{
expressionsDetail: JSON.parse(this.props.line.debug_popup_data()).expressions_detail,
onClose: close,
},
{
closeOnClickAway: true,
position: localization.direction === "rtl" ? "left" : "right",
},
);
}
//------------------------------------------------------------------------------------------------------------------
// Virtual Grid
//------------------------------------------------------------------------------------------------------------------
/** Return the height of a *stored* line in pixels.
*
* If you are adding a custom line and this line is higher than normal line, you will need to override this function.
* Make sure to check if it's 0 first, as this function also checks if a line is visible or not.
*
* @param {AccountReportController} controller
* @param {'left' | 'right'} side The side of the horizontal split we want to know the line is on
* @param {Object} line
* @param {number} normalLineHeight The height in px of a rendered line without anything except some text
* @param {Record<string, number | undefined>} customClassesHeights A map of css_class to their height which were rendered using
* some text and the css_class on the tr.
*/
static getLineHeight(controller, side, line, normalLineHeight) {
if (line.visible === false) return 0;
if (line.search_match === false) return 0;
if (controller.options().horizontal_split && line.horizontal_split_side !== side) return 0;
let height = normalLineHeight;
if (line.level === 0) { // since an empty line is added above the line
height += normalLineHeight;
}
return height;
}
}
registry.category("account_reports.default_components").add("AccountReportLine", AccountReportLine);

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLine">
<t t-call="{{ this.controller.template('AccountReportLine') }}"/>
</t>
<t t-name="account_reports.AccountReportLineCustomizable">
<!-- Adds an empty row above line with level 0 to add some spacing (it is the easiest and cleanest way) -->
<tr class="empty" t-if="this.isLevel0() and !this.shouldHide()"/>
<!-- the 'o_hidden' class need to be kept here, since we want it to be reflected instantly if it changes, even if that mean an extra render of the line -->
<tr
data-id="line"
t-att-class="this.lineClasses + (this.shouldHide() ? ' o_hidden' : '')"
t-ref="this.lineRef"
>
<!-- Name column -->
<t t-component="this.controller.component('AccountReportLineName')" t-props="{
lineIndex: this.props.lineIndex,
line: this.props.line,
}"/>
<!-- Value columns -->
<t data-id="line_column" t-foreach="this.props.line.columns" t-as="cell" t-key="cell_index">
<t t-if="this.controller.options().column_groups[cell.column_group_index?.()]?.compute_budget or cell.edit_popup_data?.()">
<AccountReportLineCellEditable line="this.props.line" cell="cell" cellIndex="cell_index"/>
</t>
<t t-else="">
<t t-component="this.controller.component('AccountReportLineCell')" line="this.props.line" cell="cell" cellIndex="cell_index"/>
</t>
</t>
<!-- Growth comparison column -->
<t t-if="this.controller.needsColumnPercentComparison || this.controller.needsAnalyticCoverageColumn">
<t t-if="this.hasComparisonData() and !(this.controller.filters.show_totals and this.props.line.unfolded?.())">
<td t-att-class="this.growthComparisonClasses()">
<t t-out="this.props.line.column_percent_comparison_data.name()"/>
</td>
</t>
<t t-else="">
<td/>
</t>
</t>
<!-- Debug column -->
<t t-if="this.controller.hasDebugColumn">
<td class="text-center">
<i t-if="this.hasDebugData()" class="btn btn_debug oi" data-icon="info" t-on-click="(ev) => this.showDebugPopover(ev)"/>
</td>
</t>
<t t-if="this.controller.options().show_horizontal_group_total">
<td t-att-class="this.horizontalGroupTotalClasses()">
<t t-out="this.props.line.horizontal_group_total_data?.name()"/>
</td>
</t>
</tr>
</t>
</templates>

View File

@@ -0,0 +1,10 @@
import { Component, t, useProps } from "@odoo/owl";
export class AccountReportDebugPopover extends Component {
static template = "account_reports.AccountReportDebugPopover";
props = useProps({
close: t.function(),
expressionsDetail: t.array(),
onClose: t.function(),
});
}

View File

@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportDebugPopover">
<div class="account_report_popover_debug">
<t t-foreach="this.props.expressionsDetail" t-as="expressionEngineAndTotals" t-key="expressionEngineAndTotals_index">
<t t-set="expressionEngine" t-value="expressionEngineAndTotals[0]"/>
<t t-set="expressionTotals" t-value="expressionEngineAndTotals[1]"/>
<div class="line_debug">
<span>Engine</span>
<span class="fw-bold" t-out="expressionEngine"/>
</div>
<t t-foreach="expressionTotals" t-as="labelAndInfo" t-key="labelAndInfo_index">
<t t-set="expressionLabel" t-value="labelAndInfo[0]"/>
<t t-set="expressionInfo" t-value="labelAndInfo[1]"/>
<div class="line_debug">
<span>Label</span>
<span t-out="expressionLabel"/>
</div>
<div class="line_debug">
<span>Formula</span>
<code t-out="expressionInfo.formula"/>
</div>
<t t-if="expressionInfo.subformula">
<div class="line_debug">
<span>Subformula</span>
<code t-out="expressionInfo.subformula"/>
</div>
</t>
<div class="line_debug">
<span>Value</span>
<span t-out="expressionInfo.value.toString()"/>
</div>
<t t-if="!labelAndInfo_last">
<div class="totals_separator"/>
</t>
</t>
<t t-if="!expressionEngineAndTotals_last">
<div class="engine_separator"/>
</t>
</t>
</div>
</t>
</templates>

View File

@@ -0,0 +1,164 @@
import { localization } from "@web/core/l10n/localization";
import { registry } from "@web/core/registry";
import { ORM } from "@web/core/orm_plugin";
import { PopoverPlugin } from "@web/core/popover/popover_plugin";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
import { Component, computed, markup, signal, t, useEffect, usePlugin, useProps } from "@odoo/owl";
import { AccountReportCarryoverPopover } from "@account_reports/components/account_report/line_cell/popover/carryover_popover";
import { AccountReportController } from "@account_reports/components/account_report/controller";
export class AccountReportLineCell extends Component {
static template = "account_reports.AccountReportLineCell";
props = useProps({
line: t.object().optional(),
cell: t.object(),
cellIndex: t.number(),
});
action = usePlugin(ActionPlugin);
controller = usePlugin(AccountReportController);
popover = usePlugin(PopoverPlugin);
orm = usePlugin(ORM);
noFormatSign = computed(() => {
const sign = Math.sign(this.props.cell.no_format?.());
// Slight optimization to prevent invalidating getCellClasses when the switch branch wont change afterward.
if (isNaN(sign)) return 1;
if (Object.is(sign, -0)) return 0;
return sign;
});
hasCellLabel = computed(() => Boolean(this.props.cell.cell_label?.()));
hasInfoPopupData = computed(() => Boolean(this.props.cell.info_popup_data?.()));
cellRef = signal.ref();
cellClasses = "";
setup() {
useEffect(() => {
const classes = this.getCellClasses();
if (classes === this.cellClasses) return;
const prevCellClasses = this.cellClasses;
this.cellClasses = classes;
const prev = prevCellClasses ? prevCellClasses.trim().split(/\s+/).filter(Boolean) : [];
const next = classes ? classes.trim().split(/\s+/).filter(Boolean) : [];
this.controller.scheduleClassUpdate(this.cellRef, prev, next);
});
}
// -----------------------------------------------------------------------------------------------------------------
// Attributes
// -----------------------------------------------------------------------------------------------------------------
getCellClasses() {
switch (this.props.cell.comparison_mode?.()) {
case "green":
return "text-end text-success";
case "muted":
return "text-end muted";
case "red":
return "text-end text-danger";
}
let classes = "";
if (this.props.cell.auditable?.()) {
classes += " auditable";
}
const css_class = this.props.cell.css_class?.();
switch(this.props.cell.figure_type()) {
case "date":
classes += " date";
break;
case "string":
classes += " text";
break;
case "float":
case "integer":
case "monetary":
case "percentage":
classes += " numeric";
if (!css_class)
switch (this.noFormatSign()) {
case 1:
break;
case 0:
classes += " muted";
break;
case -1:
classes += " text-danger";
break;
}
break;
}
if (this.props.cellIndex % 2) {
classes += " line_cell_odd";
}
if (css_class) {
classes += ` ${css_class}`;
}
return classes;
}
// -----------------------------------------------------------------------------------------------------------------
// Audit
// -----------------------------------------------------------------------------------------------------------------
async audit() {
const auditAction = await this.orm.call(
"account.report",
"dispatch_report_action",
[
this.controller.options().report_id,
this.controller.options(),
"action_audit_cell",
{
report_line_id: this.props.cell.report_line_id?.(),
expression_label: this.props.cell.expression_label(),
calling_line_dict_id: this.props.line.id(),
column_group_index: this.props.cell.column_group_index(),
},
],
{
context: this.controller.context,
}
);
if (auditAction.help) {
auditAction.help = markup(auditAction.help);
}
return this.action.doAction(auditAction);
}
//------------------------------------------------------------------------------------------------------------------
// Carryover popover
//------------------------------------------------------------------------------------------------------------------
carryoverPopover(ev) {
if (this.popoverCloseFn) {
this.popoverCloseFn();
this.popoverCloseFn = null;
}
this.popoverCloseFn = this.popover.add(
ev.currentTarget,
AccountReportCarryoverPopover,
{
carryoverData: JSON.parse(this.props.cell.info_popup_data()),
options: this.controller.options(),
context: this.controller.context,
},
{
closeOnClickAway: true,
position: localization.direction === "rtl" ? "bottom" : "right",
},
);
}
}
registry.category("account_reports.default_components").add("AccountReportLineCell", AccountReportLineCell);

View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCell">
<t t-call="{{ this.controller.template('AccountReportLineCell') }}"/>
</t>
<t t-name="account_reports.AccountReportLineCellCustomizable">
<td
data-id="line_cell"
class="line_cell"
t-att-class="this.cellClasses"
t-ref="this.cellRef"
t-att-data-expression_label="this.props.cell.expression_label?.()"
>
<t t-if="!this.controller.options().filters.show_totals or !this.props.line.unfolded?.()" data-id="content">
<a
t-if="this.hasInfoPopupData()"
class="oi cursor-pointer me-2"
data-icon="help"
t-on-click="(ev) => this.carryoverPopover(ev)"
/>
<div t-if="this.hasCellLabel()" class="me-auto pe-2 muted">
<t t-component="this.controller.component('AccountReportEllipsis')" t-props="{
name: this.props.cell.cell_label,
type: () => 'string',
maxCharacters: 50,
}"/>
</div>
<t t-if="this.props.cell.auditable?.()">
<a class="cursor-pointer" t-on-click="() => this.audit()">
<t t-component="this.controller.component('AccountReportEllipsis')" t-props="{
name: this.props.cell.name,
no_format: this.props.cell.no_format,
type: this.props.cell.figure_type,
maxCharacters: 50,
}"/>
</a>
</t>
<t t-else="">
<t t-component="this.controller.component('AccountReportEllipsis')" t-props="{
name: this.props.cell.name,
no_format: this.props.cell.no_format,
type: this.props.cell.figure_type,
maxCharacters: 50,
}"/>
</t>
</t>
</td>
</t>
</templates>

View File

@@ -0,0 +1,38 @@
import { ORM } from "@web/core/orm_plugin";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
import { Component, t, usePlugin, useProps } from "@odoo/owl";
export class AccountReportCarryoverPopover extends Component {
static template = "account_reports.AccountReportCarryoverPopover";
props = useProps({
close: t.function(),
carryoverData: t.object(),
options: t.object(),
context: t.object(),
});
actionPlugin = usePlugin(ActionPlugin);
orm = usePlugin(ORM);
//------------------------------------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------------------------------------
async viewCarryoverLinesAction(expressionId, columnGroupKey) {
const viewCarryoverLinesAction = await this.orm.call(
"account.report.expression",
"action_view_carryover_lines",
[
expressionId,
this.props.options,
columnGroupKey,
],
{
context: this.props.context,
}
);
this.props.close();
return this.actionPlugin.doAction(viewCarryoverLinesAction);
}
}

View File

@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportCarryoverPopover">
<table class="carryover_popover">
<t t-if="this.props.carryoverData.carryover || this.props.carryoverData.applied_carryover">
<tr>
<td>
<strong>Carryover</strong>
</td>
<td/>
</tr>
<t t-if="this.props.carryoverData.applied_carryover">
<tr>
<td colspan="2">
<span>
<strong t-out="this.props.carryoverData.applied_carryover"/> were carried over to this line from previous period.
</span>
</td>
</tr>
</t>
<t t-if="this.props.carryoverData.carryover">
<tr>
<td colspan="2">
<t t-if="this.props.carryoverData.carryover_target">
<span>
<strong t-out="this.props.carryoverData.carryover"/> will be carried over to <strong t-out="this.props.carryoverData.carryover_target"/> in the next period.
</span>
</t>
<t t-else="">
<span>
<strong t-out="this.props.carryoverData.carryover"/> will be carried over to this line in the next period.
</span>
</t>
</td>
</tr>
</t>
<t t-if="this.props.carryoverData.allow_carryover_audit">
<tr>
<td/>
<td>
<button
class="btn btn-secondary"
t-on-click="() => this.viewCarryoverLinesAction(this.props.carryoverData.expression_id, this.props.carryoverData.column_group_index)"
>
View Carryover Lines
</button>
</td>
</tr>
</t>
</t>
</table>
</t>
</templates>

View File

@@ -0,0 +1,64 @@
import { computed } from "@odoo/owl";
import { AccountReportLineCell } from "@account_reports/components/account_report/line_cell/line_cell";
import { AccountReportLineCellEditableBoolean } from "./line_cell_editable_boolean";
import { AccountReportLineCellEditableDateTime } from "./line_cell_editable_datetime";
import { AccountReportLineCellEditableLiteral } from "./line_cell_editable_literal";
import { AccountReportLineCellEditableMany2One } from "./line_cell_editable_many2one";
import { AccountReportLineCellEditableSelection } from "./line_cell_editable_selection";
export class AccountReportLineCellEditable extends AccountReportLineCell {
static template = "account_reports.AccountReportLineCellEditable";
static components = {
AccountReportLineCellEditableBoolean,
AccountReportLineCellEditableDateTime,
AccountReportLineCellEditableLiteral,
AccountReportLineCellEditableMany2One,
AccountReportLineCellEditableSelection,
};
figureType = computed(() => this.props.cell.figure_type());
hasEditPopupData = computed(() => Boolean(this.props.cell.edit_popup_data?.()));
isSelection = computed(() => Boolean(this.hasEditPopupData() && this.props.cell.edit_popup_data().includes("selection_options")));
async onChange(editValue) {
const cellEditData = this.hasEditPopupData()
? JSON.parse(this.props.cell.edit_popup_data())
: {};
const res = await this.orm.call(
"account.report",
"action_modify_manual_value",
[
this.controller.options().report_id,
this.props.line.id(),
this.controller.options(),
cellEditData.column_group_index,
editValue,
cellEditData.target_expression_id,
cellEditData.rounding,
this.controller.columnGroupsTotals,
],
{
context: this.controller.context,
},
);
this.controller.lines = res.lines;
this.controller.columnGroupsTotals = res.column_groups_totals;
}
getCellClasses() {
let classes = super.getCellClasses();
if (this.hasEditPopupData()) classes += " editable-cell";
return classes;
}
get editableCellProps() {
return {
cell: this.props.cell,
onChange: this.onChange.bind(this),
audit: this.audit.bind(this),
};
}
}

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditable" t-inherit="account_reports.AccountReportLineCellCustomizable" t-inherit-mode="primary">
<xpath expr="//t[@data-id='content']" position="replace">
<t t-if="this.hasEditPopupData()">
<t t-if="['date', 'datetime'].includes(this.figureType())" data-id="date">
<AccountReportLineCellEditableDateTime t-props="this.editableCellProps"/>
</t>
<t t-elif="this.figureType() === 'boolean'" data-id="boolean">
<AccountReportLineCellEditableBoolean t-props="this.editableCellProps"/>
</t>
<t t-elif="this.figureType() === 'many2one'" data-id="many2one">
<AccountReportLineCellEditableMany2One t-props="this.editableCellProps"/>
</t>
<t t-elif="this.isSelection()" data-id="selection">
<AccountReportLineCellEditableSelection t-props="this.editableCellProps"/>
</t>
<t t-else="" data-id="literal">
<AccountReportLineCellEditableLiteral t-props="this.editableCellProps"/>
</t>
</t>
<t t-else="">$0</t>
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,25 @@
import { Component, signal, t, useProps } from "@odoo/owl";
export class AccountReportLineCellEditableBoolean extends Component {
static template = "account_reports.AccountReportLineCellEditableBoolean";
props = useProps({
onChange: t.function(),
cell: t.object(),
audit: t.function(),
});
inputRef = signal.ref();
toggleBooleanValue() {
this.props.onChange(this.inputRef().dataset.noFormat === "0" ? 1 : 0);
}
get inputNoFormatValue() {
return this.props.cell?.no_format();
}
get inputValue() {
return this.props.cell?.name();
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditableBoolean">
<input type="text"
class="o_input text-end user-select-none"
t-ref="this.inputRef"
t-att-data-no-format="this.inputNoFormatValue"
t-on-click.prevent.stop="this.toggleBooleanValue"
t-att-value="this.inputValue"
readonly=""
/>
<i class="oi oi-filled" data-icon="edit"
t-on-click.prevent.stop="this.toggleBooleanValue"
/>
</t>
</templates>

View File

@@ -0,0 +1,97 @@
import { formatDate, formatDateTime } from "@web/core/l10n/dates";
import { useDateTimePicker } from "@web/core/datetime/datetime_picker_hook";
import { Component, computed, signal, t, usePlugin, useProps } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
const { DateTime } = luxon;
export class AccountReportLineCellEditableDateTime extends Component {
static template = "account_reports.AccountReportLineCellEditableDateTime";
props = useProps({
onChange: t.function(),
cell: t.object(),
audit: t.function(),
});
controller = usePlugin(AccountReportController);
datetime = computed(
() => this.props.cell.no_format() ? DateTime.fromISO(this.props.cell.no_format()) : null,
{set: this.props.cell.no_format.set},
);
inputDateRef = signal.ref();
setup() {
this.datetimePicker = useDateTimePicker({
target: this.inputDateRef,
showSeconds: false,
tz: this.tz,
pickerProps: this.pickerProps,
onApply: newDate => {
this.datetime.set(newDate);
this.props.onChange(newDate);
},
});
}
get pickerProps() {
return {
value: this.datetime(),
type: this.figureType,
};
}
onClickEdit() {
this.datetimePicker.open();
}
onBlur() {
this.datetimePicker.close();
}
onMouseDown(ev) {
/**
* This function has for purpose to prevent the input focus via the click without
* blocking the click when the element is focus.
*/
if (!this.datetimePicker.isOpen()) {
ev.preventDefault();
}
}
audit() {
if (this.datetimePicker.isOpen()) {
return;
}
this.props.audit();
}
get tz() {
return this.controller.context?.tz || "UTC";
}
get inputValue() {
const value = this.datetime();
if (value) {
if (this.figureType === "datetime") {
return formatDateTime(value, { tz: this.tz });
} else if (this.figureType === "date") {
return formatDate(value, { tz: this.tz });
} else {
throw new Error(
`Bad figure type to format. Expected: date, datetime. Got: ${this.figureType}`
);
}
}
return "";
}
get figureType() {
return this.props.cell.figure_type();
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditableDateTime">
<t t-if="this.props.cell.auditable?.()">
<input type="text"
class="o_input text-end text-primary cursor-pointer"
t-ref="this.inputDateRef"
t-att-value="this.inputValue"
t-on-click.stop.capture="this.audit"
t-on-mousedown="this.onMouseDown"
/>
</t>
<t t-else="">
<input type="text"
class="o_input text-end text-body cursor-default"
t-ref="this.inputDateRef"
t-att-value="this.inputValue"
t-on-mousedown="this.onMouseDown"
/>
</t>
<i class="oi oi-filled cursor-pointer" data-icon="edit"
t-on-click.prevent.stop="this.onClickEdit"
/>
</t>
</templates>

View File

@@ -0,0 +1,130 @@
import { localization } from "@web/core/l10n/localization";
import { useHotkey } from "@web/core/hotkeys/hotkey_hook";
import { formatFloat } from "@web/core/utils/numbers";
import { parseFloat } from "@web/views/fields/parsers";
import { Component, signal, t, useProps } from "@odoo/owl";
export class AccountReportLineCellEditableLiteral extends Component {
static template = "account_reports.AccountReportLineCellEditableLiteral";
props = useProps({
onChange: t.function(),
cell: t.object(),
audit: t.function(),
});
input = signal.ref();
editPopupData = this.parseEditPopupData();
isFocused = signal(false);
inputRef = signal.ref();
setup() {
useHotkey(
"Enter",
ev => { ev.target.blur(); },
{ bypassEditableProtection: true },
);
}
parseEditPopupData() {
try {
return JSON.parse(this.props.cell.edit_popup_data() || "{}");
} catch {
return {};
}
}
get isLocaleFormatType() {
return ["float", "integer", "monetary", "percentage"].includes(this.props.cell.figure_type());
}
get editableNumericValue() {
const no_format = this.props.cell.no_format?.();
if (no_format == null || no_format === "") {
return no_format;
}
const numericValue = Number(no_format);
if (Number.isNaN(numericValue)) {
return no_format;
}
return formatFloat(numericValue, {
digits: [0, this.editPopupData.rounding || 2],
thousandsSep: "",
grouping: [],
trailingZeros: false,
});
}
get editableValue() {
const value = this.isLocaleFormatType
? this.editableNumericValue
: this.props.cell.no_format();
return value == null ? "" : String(value);
}
onClickEdit() {
this.inputRef().focus();
}
async onChange() {
let editValue = this.inputRef().value;
if (this.isLocaleFormatType) {
const otherDecimalSeparator = localization.decimalPoint === "." ? "," : ".";
const localeThousandsSeparator = localization.thousandsSep || "";
if (
this.inputRef().value.split(localization.decimalPoint || ".").length >= 3 ||
(this.inputRef().value.includes(otherDecimalSeparator) &&
otherDecimalSeparator !== localeThousandsSeparator)
) {
editValue = this.inputRef().value;
} else {
try {
editValue = parseFloat(this.inputRef().value).toString();
} catch {
editValue = this.inputRef().value;
}
}
}
await this.props.onChange(editValue);
this.isFocused.set(false);
}
onFocus() {
this.isFocused.set(true);
this.inputRef().value = this.editableValue;
this.inputRef().select();
}
onBlur() {
if (this.editableValue === this.inputRef().value) {
this.isFocused.set(false);
}
}
onMouseDown(ev) {
/**
* This function has for purpose to prevent the input focus via the click without
* blocking the click when the element is focus.
*/
if (!this.isFocused()) ev.preventDefault();
}
audit() {
if (this.isFocused()) return;
this.props.audit();
}
get inputValue() {
return this.isFocused() ? this.editableValue : this.props.cell.name();
}
}

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditableLiteral">
<t t-if="this.props.cell.auditable?.()">
<input type="text"
class="o_input text-end text-primary cursor-pointer"
t-att-class="{'focused': this.isFocused()}"
t-ref="this.inputRef"
t-on-change="this.onChange"
t-on-focus="this.onFocus"
t-on-blur="this.onBlur"
t-att-value="this.inputValue"
t-on-click.stop.capture="this.audit"
t-on-mousedown="this.onMouseDown"
/>
</t>
<t t-else="">
<input type="text"
class="o_input text-end text-body"
t-att-class="{
'focused': this.isFocused(),
'cursor-default': !this.isFocused()
}"
t-ref="this.inputRef"
t-on-change="this.onChange"
t-on-focus="this.onFocus"
t-on-blur="this.onBlur"
t-att-value="this.inputValue"
t-on-mousedown="this.onMouseDown"
/>
</t>
<i class="oi oi-filled cursor-pointer" data-icon="edit"
t-on-click.prevent.stop="this.onClickEdit"
t-att-class="{'invisible': this.isFocused()}"
/>
</t>
</templates>

View File

@@ -0,0 +1,73 @@
import { Many2OneField } from "@web/views/fields/many2one/many2one_field";
import { Record } from "@web/model/record";
import { useService } from "@web/core/utils/hooks";
import { Component, asyncComputed, computed, onWillStart, t, useProps } from "@odoo/owl";
export class AccountReportLineCellEditableMany2One extends Component {
static template = "account_reports.AccountReportLineCellEditableMany2One";
static components = { Many2OneField, Record };
props = useProps({
onChange: t.function(),
cell: t.object(),
audit: t.function(),
});
value = computed(() => this.getValue());
setup() {
this.nameService = useService("name");
this.name = asyncComputed(() => this.loadDisplayName());
// Wait for the name to load so it's not fetch here AND in the Many2OneField.
onWillStart(async () => await this.name.currentPromise());
}
async loadDisplayName() {
const [resModel, resId] = this.value().split(':');
const id = parseInt(resId);
if (!id) {
return '';
}
const names = await this.nameService.loadDisplayNames(resModel, [id]);
return names[id] || '';
}
async update(value) {
const resModel = this.value().split(':')[0];
const resId = value.data.id.id || 0;
await this.props.onChange(`${resModel}:${resId}`);
}
getValue() {
const no_format = this.props.cell.no_format();
if (no_format) return no_format;
const edit_popup_data = this.props.cell?.edit_popup_data();
if (!edit_popup_data) return '';
const cellEditData = JSON.parse(edit_popup_data);
return `${cellEditData.target_model}:0`;
}
get recordProps() {
const name = this.name();
const [resModel, resId] = this.value().split(':');
const id = parseInt(resId) || false;
const fields = {
id: {
type: "many2one",
relation: resModel,
},
};
return {
hooks: { onRecordChanged: (r, _) => this.update(r) },
values: {
id: id && name !== undefined ? [id, name] : id,
},
resModel,
fields,
activeFields: fields,
};
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditableMany2One">
<Record t-props="this.recordProps" t-slot-scope="data">
<div class="o_field_widget o_field_many2one o_external_reference">
<Many2OneField id="'id'" name="'id'" record="data.record"/>
</div>
</Record>
</t>
</templates>

View File

@@ -0,0 +1,66 @@
import { Component, computed, signal, t, useProps } from "@odoo/owl";
import { SelectMenu } from "@web/core/select_menu/select_menu";
export class AccountReportLineCellEditableSelection extends Component {
static template = "account_reports.AccountReportLineCellEditableSelection";
static components = { SelectMenu };
props = useProps({
onChange: t.function(),
cell: t.object(),
audit: t.function(),
});
selectionRef = signal.ref();
selectionChoices = computed(() => this.parseSelectionOptions());
isFocused = signal(false);
parseSelectionOptions() {
try {
const editPopupData = JSON.parse(this.props.cell.edit_popup_data() ?? "{}");
if (!editPopupData.selection_options) {
return [];
}
const choices = [];
for (const [value, label] of Object.entries(editPopupData.selection_options)) {
choices.push({ value, label });
}
return choices;
} catch {
return [];
}
}
getSelectedChoiceLabel(value) {
return this.selectionChoices().find((choice) => choice.value === value)?.label;
}
onClickSelection() {
const el = this.selectionRef().querySelector(".o_select_menu_toggler, input");
if (el) {
this.isFocused.set(true);
// Focus and click both are needed since focus helps user to type in options in input, and click shows dropdown
el.focus();
el.click();
}
}
onSelectOpened() {
this.isFocused.set(true);
}
onSelectClosed() {
this.isFocused.set(false);
}
async onSelectChoice(choice) {
await this.props.onChange(this.getSelectedChoiceLabel(choice));
this.isFocused.set(false);
}
get selectionValue() {
return (
this.selectionChoices().find((option) => option.label === this.props.cell.name?.())?.value ||
""
);
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineCellEditableSelection">
<div
class="content d-inline-block"
t-ref="this.selectionRef"
>
<SelectMenu
choices="this.selectionChoices()"
value="this.selectionValue"
togglerClass="'w-100 text-end'"
searchPlaceholder.translate="Select or type a value"
onSelect.bind="this.onSelectChoice"
onOpened.bind="this.onSelectOpened"
onClosed.bind="this.onSelectClosed"
menuClass="'w-auto'"
/>
</div>
<i class="oi oi-filled cursor-pointer" data-icon="edit"
t-on-click.prevent.stop="this.onClickSelection"
t-att-class="{'invisible': this.isFocused()}"
/>
</t>
</templates>

View File

@@ -0,0 +1,252 @@
import { Dropdown } from "@web/core/dropdown/dropdown";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { registry } from "@web/core/registry";
import { ORM } from "@web/core/orm_plugin";
import { UIPlugin } from "@web/core/ui/ui_plugin";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
import { Component, computed, t, usePlugin, useProps } from "@odoo/owl";
import { parseLineId } from "@account_reports/js/util";
import { AccountReportController } from "@account_reports/components/account_report/controller";
import { AccountReviewStateSelectionBadge } from "@account/components/account_review_state_selection/account_review_state_selection_badge";
export class AccountReportLineName extends Component {
static template = "account_reports.AccountReportLineName";
static components = {
Dropdown,
DropdownItem,
AccountReviewStateSelectionBadge,
};
props = useProps({
lineIndex: t.signal(t.number()),
line: t.object(),
});
action = usePlugin(ActionPlugin);
controller = usePlugin(AccountReportController);
orm = usePlugin(ORM);
ui = usePlugin(UIPlugin);
isLoadMore = computed(() => this.controller.isLoadMoreLine(this.props.line.id()));
isChatterAnnotated = computed(() => Boolean(this.props.line.visible_annotations?.()));
isChatterSelected = computed(() => this.props.line.id() === this.controller.chatterState.lineId());
hasAction = computed(() => Boolean(this.props.line.action_id?.()));
hasCaretOptions = computed(() => this.caretOptions?.length > 0);
hasAccountStatus = computed(() => Boolean(this.props.line.account_status?.id()));
hasChatter = computed(() => Boolean(this.props.line.chatter?.model()));
modelName = computed(() => parseLineId(this.props.line.id()).at(-1)[1]);
get accountStatusBadgeOptions() {
return {
todo: { decoration: "info" },
reviewed: { decoration: "success" },
supervised: { decoration: "success" },
anomaly: { decoration: "danger" },
};
}
onAccountStatusChange(value) {
if (this.props.line.account_status?.status) {
this.props.line.account_status.status.set(value);
}
}
//------------------------------------------------------------------------------------------------------------------
// Caret options
//------------------------------------------------------------------------------------------------------------------
get caretOptions() {
if (!this.controller.data()) return [];
return this.controller.caretOptions[this.props.line.caret_options?.()];
}
async caretAction(caretOption) {
const res = await this.orm.call(
"account.report",
"dispatch_report_action",
[
this.controller.options().report_id,
this.controller.options(),
caretOption.action,
{
line_id: this.props.line.id(),
action_param: caretOption.action_param,
},
],
{
context: this.controller.context,
},
);
return this.action.doAction(res);
}
// -----------------------------------------------------------------------------------------------------------------
// Classes
// -----------------------------------------------------------------------------------------------------------------
get lineNameClasses() {
const line = this.props.line;
let classes = "text";
if (line.unfoldable?.())
classes += " unfoldable";
if (line.is_draft?.())
classes += " draft";
if (line.css_class?.())
classes += ` ${ line.css_class() }`;
return classes;
}
// -----------------------------------------------------------------------------------------------------------------
// Action
// -----------------------------------------------------------------------------------------------------------------
async triggerAction() {
const res = await this.orm.call(
"account.report",
"execute_action",
[
this.controller.options().report_id,
this.controller.options(),
{
id: this.props.line.id(),
actionId: this.props.line.action_id?.(),
},
],
{
context: this.controller.context,
},
);
return this.action.doAction(res);
}
// -----------------------------------------------------------------------------------------------------------------
// Load more
// -----------------------------------------------------------------------------------------------------------------
async loadMore() {
const linesByParent = {};
for (const line of this.controller.lines) {
if (!line['parent_id']) continue;
(linesByParent[line['parent_id']] ??= []).push(line);
}
const lineToExpandId = this.props.line.parent_id?.();
const alreadyLoadedChildLineIds = this.retrieveAllLoadedChildLines(linesByParent, lineToExpandId).map(l => l.id);
const newLines = await this.orm.call(
"account.report",
this.controller.options().readonly_query ? "get_expanded_lines_readonly" : "get_expanded_lines",
[
this.controller.options().report_id,
this.controller.options(),
lineToExpandId,
this.props.line.groupby?.(),
this.props.line.expand_function?.(),
this.props.line.horizontal_split_side?.(),
this.controller._retrieve_line_comparison_base_value(),
true,
alreadyLoadedChildLineIds, // So that we avoid recomputing uselessly groupby of already unfolded and loaded lines
],
);
this.controller.setLineVisibility(newLines);
// Insert the new lines at the right positions, keeping the result of previously unfolded lines
const linesToInsert = [];
for (const newLine of newLines) {
linesToInsert.push(newLine);
linesToInsert.push(...this.retrieveAllLoadedChildLines(linesByParent, newLine['id']));
}
let parentIndex = null;
const lines = this.controller.lines;
for (let i = this.props.lineIndex() - 1; i >= 0; i--){
if (lines[i].id === lineToExpandId) {
parentIndex = i;
break;
}
}
const nberLinesToRemove = this.props.lineIndex() - parentIndex;
// Sorting is done before inserting the lines, so that linesOrder is properly set on the controller before triggering a UI refresh.
if (this.controller.areLinesOrdered()) {
const newLinesOrder = await this.controller.loadLinesOrder(linesToInsert);
const linesOrder = this.controller.linesOrder();
// Modify the indices of the sublines so that they come all just after their parent's
for (let i = 0 ; i < newLinesOrder.length ; i++) {
newLinesOrder[i] += parentIndex + 1;
}
// Modify all indices stored in linesOrder for lines which will come after parent once the lines have been inserted
let parentLineOrderIndex;
for (let i = 0 ; i < linesOrder.length ; i++) {
if (linesOrder[i] === parentIndex) {
parentLineOrderIndex = i;
}
else if (linesOrder[i] > parentIndex) {
linesOrder[i] += newLinesOrder.length - nberLinesToRemove;
}
}
// Remove elements that would already be present in linesOrder before injecting the order of unfolded lines
const reloadedIndices = new Set(newLinesOrder);
const kept = linesOrder.filter(x => !reloadedIndices.has(x));
kept.splice(parentLineOrderIndex + 1, 0, ...newLinesOrder);
linesOrder.length = 0;
linesOrder.push(...kept);
}
else {
// Reset linesOrder to use the indices of the lines directly, making sure it stays consistent with the newly loaded lines
this.controller.linesOrder.set(null);
}
// Insert lines, refreshing the UI
this.controller.insertLines(parentIndex + 1, nberLinesToRemove, linesToInsert);
}
retrieveAllLoadedChildLines(linesByParent, lineId) {
const rslt = [];
if (lineId in linesByParent) {
for (const childLine of linesByParent[lineId]) {
rslt.push(childLine);
rslt.push(...this.retrieveAllLoadedChildLines(linesByParent, childLine['id']));
}
}
return rslt;
}
// -----------------------------------------------------------------------------------------------------------------
// Fold / Unfold
// -----------------------------------------------------------------------------------------------------------------
toggleFoldable() {
if (!this.props.line.unfoldable?.()) return;
if (this.props.line.unfolded())
this.controller.foldLine(this.props.lineIndex());
else
this.controller.unfoldLine(this.props.lineIndex());
}
// -----------------------------------------------------------------------------------------------------------------
// Chatter
// -----------------------------------------------------------------------------------------------------------------
async openChatter(ev) {
ev.stopPropagation();
if (!this.props.line.chatter?.id()) return;
this.controller.toggleLineChatter({
resModel: this.props.line.chatter.model(),
resId: this.props.line.chatter.id(),
lineId: this.props.line.id(),
});
}
}
registry.category("account_reports.default_components").add("AccountReportLineName", AccountReportLineName);

View File

@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportLineName">
<t t-call="{{ this.controller.template('AccountReportLineName') }}"/>
</t>
<t t-name="account_reports.AccountReportLineNameCustomizable">
<td
data-id="line_name"
class="line_name"
t-att-class="this.lineNameClasses"
t-on-click="() => this.toggleFoldable()"
t-att-colspan="this.props.line.colspan?.() || 1"
tabindex="-1"
>
<!-- Foldable -->
<i t-if="this.props.line.unfoldable?.()"
data-id="btn_foldable"
class="btn btn_foldable oi"
tabindex="-1"
t-att-data-icon="this.props.line.unfolded() ? 'arrow_drop_down' : 'arrow_right'"
/>
<t data-id="content">
<t t-if="this.hasAction()">
<!-- Actions -->
<a class="clickable cursor-pointer" t-on-click="this.triggerAction" tabindex="-1" t-out="this.props.line.name()"/>
</t>
<t t-elif="this.isLoadMore()">
<!-- Load more -->
<a class="clickable cursor-pointer" t-on-click="this.loadMore" tabindex="-1" t-out="this.props.line.name()"/>
</t>
<t t-else="">
<t t-component="this.controller.component('AccountReportEllipsis')" t-props="{
name: this.props.line.name,
type: () => 'string',
maxCharacters: 80,
}"/>
<AccountReviewStateSelectionBadge
t-if="this.hasAccountStatus()"
options="this.accountStatusBadgeOptions"
record="this.controller.accountStatuses[this.props.line.account_status.id()]"
readonly="false"
name="'status'"
class="'ms-2'"
size="'small'"
onChange="this.onAccountStatusChange.bind(this)"
/>
<!-- Caret options -->
<Dropdown position="'right-start'" t-if="this.hasCaretOptions()">
<i class="btn btn_dropdown oi" data-icon="more_vert" tabindex="-1"/>
<t t-set-slot="content">
<div data-id="caret_options">
<t t-foreach="this.caretOptions" t-as="caretOption" t-key="caretOption_index">
<DropdownItem onSelected="() => this.caretAction(caretOption)">
<t t-out="caretOption.name"/>
</DropdownItem>
</t>
</div>
</t>
</Dropdown>
<i tabindex="-1"
t-if="this.hasChatter()"
class="btn btn_annotation oi"
t-att-class="{
'o_account_report_chatter_selected oi-filled': this.isChatterSelected(),
'o_account_report_chatter_annotated oi-filled': this.isChatterAnnotated(),
}"
t-on-click="this.openChatter"
data-icon="mode_comment"
/>
<t data-id="line_buttons" t-if="!this.props.line.hide_line_buttons?.()"/>
</t>
</t>
</td>
</t>
</templates>

View File

@@ -0,0 +1,78 @@
import { Component, onMounted, signal, t, usePlugin, useProps } from "@odoo/owl";
import { AccountReportController } from "@account_reports/components/account_report/controller";
export class AccountReportSearchBar extends Component {
static template = "account_reports.AccountReportSearchBar";
props = useProps({
initialQuery: t.string().optional(),
});
controller = usePlugin(AccountReportController);
searchBarInputRef = signal.ref();
setup() {
onMounted(() => {
if (!this.props.initialQuery) return;
this.searchBarInputRef().value = this.props.initialQuery || "";
this.search();
});
}
//------------------------------------------------------------------------------------------------------------------
// Search
//------------------------------------------------------------------------------------------------------------------
async search() {
const inputText = this.searchBarInputRef().value.trim();
const query = inputText.toLowerCase();
// Since the search bar is loaded before the report data, we need to wait for it
await this.controller.reportLoadingPromise;
if (query.length) {
const parentLines = [];
let parentLineId = undefined;
for (const line of this.controller.lines) {
while (parentLines.length && parentLines.at(-1).level >= line.level) {
parentLines.pop();
}
if (parentLineId && !line.id.startsWith(`${parentLineId}|`)) {
parentLineId = undefined;
}
line.search_match = false;
if (line.name) {
const lineName = line.name.trim().toLowerCase();
const match = (lineName.indexOf(query) !== -1);
if (match) {
line.search_match = true;
// update parent lines to be visible if a child line matches the search
for (let i = parentLines.length - 1; i >= 0; i--) {
parentLines[i].search_match = true;
}
if (!parentLineId || !line.id.startsWith(`${parentLineId}|`)) {
parentLineId = line.id;
}
}
}
if (parentLineId && line.id.startsWith(`${parentLineId}|`)) {
line.search_match = true;
}
parentLines.push(line);
}
this.controller.updateOption("filter_search_bar", inputText);
} else {
for (const line of this.controller.lines) {
line.search_match = true;
}
this.controller.deleteOption("filter_search_bar");
}
this.controller.invalidateVisibleLines(); // This update search_match on the stored lines.
}
}

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.AccountReportSearchBar">
<div class="o_searchview form-control d-print-contents d-flex align-items-center py-1 w-auto" role="search" aria-autocomplete="list">
<i class="o_searchview_icon oi d-print-none me-2"
data-icon="search"
role="img"
aria-label="Search..."
title="Search..."
/>
<div class="o_searchview_input_container d-flex flex-grow-1 flex-wrap gap-1">
<input type="text"
class="o_searchview_input o_input d-print-none flex-grow-1 w-auto border-0"
accesskey="Q"
placeholder="Search..."
role="searchbox"
t-ref="this.searchBarInputRef"
t-on-input="() => this.search()"
/>
</div>
</div>
</t>
</templates>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates>
<t t-name="account_reports.common_warning_tax_unit">
This company is part of a tax unit. You're currently not viewing the whole unit.
</t>
<t t-name="account_reports.common_warning_draft_in_period">
There are
<a type="button" t-on-click="(ev) => this.controller.reportAction(ev, 'open_unposted_moves', {})">unposted Journal Entries</a>
prior or included in this period.
</t>
<t t-name="account_reports.common_link_account_return">
<t t-if="warningParams['submitted']">
View submitted
<a type="button" class="ps-1" t-on-click="(ev) => this.controller.reportAction(ev, 'action_open_related_returns')">Tax Return</a>
</t>
<t t-else="">
Review or submit <a type="button" class="ps-1" t-on-click="(ev) => this.controller.reportAction(ev, 'action_open_related_returns')">Tax Return</a>
</t>
</t>
<t t-name="account_reports.common_possibly_unbalanced_because_cta">
This report uses the CTA conversion method to consolidate multiple companies using different currencies,
which can lead the report to be unbalanced.
</t>
</templates>

View File

@@ -0,0 +1,13 @@
import { usePlugin } from "@odoo/owl";
import { GlobalBusPlugin } from "@web/core/global_bus_plugin";
import { registry } from "@web/core/registry";
export async function AccountReturnRefreshHandler(_, action) {
const params = action.params || {};
const bus = usePlugin(GlobalBusPlugin).bus;
bus.trigger("return_reload_model", {resIds: params.return_ids});
return params.next_action;
}
registry.category("actions").add("action_return_refresh", AccountReturnRefreshHandler)

View File

@@ -0,0 +1,13 @@
import { usePlugin } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
export async function AccountReturnCloseWizard(_, action) {
const params = action.params || {};
usePlugin(ActionPlugin).doAction({
type: 'ir.actions.act_window_close'
});
return params.next_action;
}
registry.category("actions").add("action_return_close_wizard", AccountReturnCloseWizard);

View File

@@ -0,0 +1,14 @@
import { Plugin, signal } from "@odoo/owl";
export class auditBalanceListChatterPlugin extends Plugin {
res_id = signal(undefined);
date_to = signal(undefined);
closeChatter() {
this.res_id.set(undefined);
}
openChatter(resId) {
this.res_id.set(resId);
}
}

View File

@@ -0,0 +1,43 @@
import { ListController } from "@web/views/list/list_controller";
import { auditBalanceListChatterPlugin } from "./account_audit_balance_list_chatter_plugin";
import { onWillStart, providePlugins, usePlugin } from "@odoo/owl";
import { ORM } from "@web/core/orm_plugin";
export class AccountAuditBalanceListController extends ListController {
static template = "account_reports.account_audit_balance_list_controller";
orm = usePlugin(ORM);
setup() {
providePlugins([auditBalanceListChatterPlugin]);
super.setup();
this.chatterPlugin = usePlugin(auditBalanceListChatterPlugin);
onWillStart(async () => {
const working_file_id = this.props.context?.working_file_id;
if (!working_file_id) {
return;
}
const working_file = await this.orm.searchRead(
"account.return",
[["id", "=", working_file_id]],
["date_to"],
{ limit: 1 }
);
if (working_file.length === 1) {
this.chatterPlugin.date_to.set(working_file[0].date_to);
}
});
}
openJournalItems() {
this.actionService.doActionButton({
context: this.model.root.context,
resModel: this.model.root.resModel,
name: "action_audit_account",
type: "object",
resIds: this.model.root.selection.map((record) => record.data.code),
});
}
}

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="account_reports.account_audit_balance_list_controller" t-inherit="web.ListView">
<xpath expr="//t[@t-set-slot='control-panel-navigation-additional']" position="inside">
<button
data-tooltip="Chatter"
class="btn btn-secondary o_switch_view o_kanban active"
t-att-class="{
'd-none': !this.chatterPlugin.res_id(),
'd-md-inline': this.chatterPlugin.res_id(),
}">
<i class="oi oi-fw mt-1" data-icon="close"/>
</button>
</xpath>
<xpath expr="//SelectionBox" position="before">
<div t-if="this.model.root.selection.length &gt; 1" t-on-click="this.openJournalItems">
<button class="btn btn-secondary">
<i class="oi me-1" data-icon="format_list_bulleted"></i>
<span>Journal Items</span>
</button>
</div>
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,48 @@
import { signal, useEffect, usePlugin } from "@odoo/owl";
import { UIPlugin } from "@web/core/ui/ui_plugin";
import { ListRenderer } from "@web/views/list/list_renderer";
import { AccountReportChatter } from "@account_reports/components/mail/chatter";
import { auditBalanceListChatterPlugin } from "./account_audit_balance_list_chatter_plugin";
export class AccountAuditBalanceListRenderer extends ListRenderer {
static template = "account_reports.account_audit_balance_list_renderer";
static components = {
...ListRenderer.components,
AccountReportChatter,
};
AuditChatterRef = signal.ref();
ui = usePlugin(UIPlugin);
chatterPlugin = usePlugin(auditBalanceListChatterPlugin);
setup() {
super.setup();
useEffect(() => {
if (this.props.list.editedRecord) {
this.chatterPlugin.openChatter(this.props.list.editedRecord.evalContext.id);
} else {
this.chatterPlugin.closeChatter();
}
});
}
onGlobalClick(event) {
if (this.AuditChatterRef().contains(event.target)) {
// ignore clicks inside the chatter as we dont want it to close when clicking inside it
return;
}
super.onGlobalClick(event);
}
getCellClass(column, record) {
const classNames = super.getCellClass(column, record);
if (column.name === 'audit_balance' && record.data.audit_balance_show_warning
|| column.name === 'audit_previous_balance' && record.data.audit_previous_balance_show_warning) {
return `${classNames} table-warning`;
}
return classNames;
}
}

View File

@@ -0,0 +1,55 @@
.o_account_report_chatter {
// Dont use transition here, the recalculation of the width of the columns of the table is only done after
// the width stabilizes, so the transition will not be smooth.
border-left: 1px solid var(--border-color);
max-width: calc(#{$o-mail-Chatter-minWidth} + 20px + var(--Chatter-asideExtraWidth));
.o-mail-Chatter-topbar {
padding-top: 0.25rem;
}
&.o_account_report_chatter_hidden {
max-width: 0;
height: 0 !important;
.o-mail-Chatter-top, .o-mail-Chatter-content{
--Chatter-default-padding-x: 0;
--ChatterAsideForm-padding-left: 0;
}
}
}
.o_account_report_audit_balance_list .o_data_row.o_selected_row {
position: relative;
// We need to have this instead of using the default one with the :focus-within selector
// since we want to detect when a row is selected to open the chatter.
$-focus-bg: rgba(var(--#{$variable-prefix}emphasis-color-rgb), #{$table-hover-bg-factor * 2});
--#{$variable-prefix}table-accent-bg: #{$-focus-bg};
--#{$variable-prefix}table-striped-bg: #{$-focus-bg};
td:first-of-type::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 3px;
background-color: rgba(var(--link-color-rgb), 0.7);
}
td:focus-within {
// To prevent --table-accent-bg and --table-striped-bg to be set to none which removes the background color of the selected row.
--#{$variable-prefix}table-accent-bg: #{$-focus-bg} !important;
--#{$variable-prefix}table-striped-bg: #{$-focus-bg} !important;
}
td.text-muted {
color: var(--body-color) !important;
}
}
th[data-name=last_message], td[name=last_message] {
max-width: 300px;
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="account_reports.account_audit_balance_list_renderer" t-inherit="web.ListRenderer">
<xpath expr="//div[@t-ref='this.rootRef']" position="after">
<div t-att-class="{'o_account_report_chatter_hidden': !this.chatterPlugin.res_id() or this.ui.isSmall()}"
class="o_account_report_chatter o-mail-ChatterContainer h-100 o-aside d-flex flex-column border-start"
t-ref="this.AuditChatterRef">
<AccountReportChatter
threadId="this.chatterPlugin.res_id()"
threadModel="'account.account'"
date_to="this.chatterPlugin.date_to()"
list="this.props.list"
/>
</div>
</xpath>
<xpath expr="//div[@t-ref='this.rootRef']" position="attributes">
<attribute name="class" add="o_account_report_audit_balance_list" separator=" "/>
</xpath>
</t>
</templates>

View File

@@ -0,0 +1,14 @@
import { registry } from "@web/core/registry";
import { listView } from "@web/views/list/list_view";
import { AccountAuditBalanceListRenderer } from "./account_audit_balance_list_renderer";
import { AccountAuditBalanceListController } from "./account_audit_balance_list_controller";
import { AccountReturnCheckControlPanel } from "./account_return_check_control_panel";
export const accountAuditBalanceList = {
...listView,
Renderer: AccountAuditBalanceListRenderer,
Controller: AccountAuditBalanceListController,
ControlPanel: AccountReturnCheckControlPanel,
};
registry.category("views").add("account_audit_balance_list", accountAuditBalanceList);

View File

@@ -0,0 +1,10 @@
import { registry } from "@web/core/registry";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { AccountReturnBaseKanbanRenderer } from "./account_return_base_kanban_renderer";
export const accountReturnAuditKanbanView = {
...kanbanView,
Renderer: AccountReturnBaseKanbanRenderer,
};
registry.category("views").add("account_return_audit_kanban", accountReturnAuditKanbanView);

View File

@@ -0,0 +1,52 @@
import { onMounted, usePlugin } from "@odoo/owl";
import { ORM } from "@web/core/orm_plugin";
import { evaluateExpr } from "@web/core/py_js/py";
import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
const { DateTime } = luxon;
export class AccountReturnBaseKanbanRenderer extends KanbanRenderer
{
orm = usePlugin(ORM);
setup() {
super.setup();
// Retrieve the allowed categories from xml arch
const optionsArch = this.props.archInfo.xmlDoc.getAttribute('options');
this.allowedCategories = ['account_return']
if (optionsArch) {
const options = evaluateExpr(optionsArch);
this.allowedCategories = options.allowed_categories;
}
onMounted(() => {this.runAllReturnChecks()});
}
async runAllReturnChecks() {
const additionalDomain = [
['date_from', '<=', DateTime.now().endOf("month").toISODate()],
['return_type_category', 'in', this.allowedCategories],
]
const returnIds = await this.orm.call(
'account.return',
'get_next_returns_ids',
[
null,
additionalDomain,
true, //allow_multiple_by_types
],
);
await this.orm.call(
'account.return',
'refresh_checks',
[returnIds]
);
// reload records
await this.props.list.model.load();
}
}

View File

@@ -0,0 +1,12 @@
import { CalendarController } from "@web/views/calendar/calendar_controller";
export class AccountReturnCalendarController extends CalendarController {
async editRecord(record, context) {
const action = await this.orm.call("account.return", "action_open_account_return", [record.id]);
if (!action)
return
return this.action.doAction(action);
}
}

View File

@@ -0,0 +1,10 @@
import { calendarView } from "@web/views/calendar/calendar_view";
import { AccountReturnCalendarController } from "./account_return_calendar_controller";
import { registry } from "@web/core/registry";
const AccountReturnCalendarView = {
...calendarView,
Controller: AccountReturnCalendarController,
};
registry.category("views").add("account_return_calendar", AccountReturnCalendarView);

View File

@@ -0,0 +1,15 @@
import { ControlPanel } from "@web/search/control_panel/control_panel";
import { AccountReturnCheckEmbeddedActionsPanel } from "./account_return_check_embedded_actions_panel";
export class AccountReturnCheckControlPanel extends ControlPanel {
static template = "account_reports.account_return_check_control_panel";
static components = {
...ControlPanel.components,
EmbeddedActionsPanel: AccountReturnCheckEmbeddedActionsPanel,
};
setup() {
super.setup();
this.embeddedPanelState.embeddedInfos.showEmbedded = true;
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.account_return_check_control_panel" t-inherit="web.ControlPanel">
<button name="embedded_actions" position="replace"/>
</t>
</templates>

View File

@@ -0,0 +1,9 @@
import { EmbeddedActionsPanel } from "@web/search/control_panel/embedded_actions";
export class AccountReturnCheckEmbeddedActionsPanel extends EmbeddedActionsPanel {
static template = "account_reports.account_return_check_embedded_actions_panel";
isEmbeddedActionVisible(_action) {
return true;
}
}

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.account_return_check_embedded_actions_panel" t-inherit="web.EmbeddedActionsPanel">
<t t-call="web.EmbeddedActionsDropdown" position="replace"/>
</t>
</templates>

View File

@@ -0,0 +1,39 @@
import { onMounted, onPatched } from "@odoo/owl";
import { useSubEnv } from "@web/owl2/utils";
import { useSetupAction } from "@web/search/action_hook";
import { KanbanController } from "@web/views/kanban/kanban_controller";
export class AccountReturnCheckKanbanController extends KanbanController {
setup() {
super.setup();
useSubEnv({
reload: () => this.model.load(),
})
useSetupAction({
rootRef: this.rootRef,
getLocalState: () => {
const renderer = this.rootRef()?.querySelector(".kanban_return_and_checks_cards");
return {
rendererScrollPositions: {
top: renderer?.scrollTop || 0,
},
};
},
});
let { rendererScrollPositions } = this.props.state || {};
const restoreScrollPosition = () => {
if (rendererScrollPositions) {
const renderer = this.rootRef().querySelector(".kanban_return_and_checks_cards");
if (renderer) {
renderer.scrollTop = rendererScrollPositions.top;
rendererScrollPositions = null;
}
}
};
onMounted(restoreScrollPosition);
onPatched(restoreScrollPosition);
}
}

View File

@@ -0,0 +1,3 @@
.o_account_return_check_kanban_view .o_cp_pager {
display: none;
}

View File

@@ -0,0 +1,162 @@
import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
import { onWillStart, signal, useScope, usePlugin, status } from "@odoo/owl";
import { useService, useBus } from "@web/core/utils/hooks";
import { registry } from "@web/core/registry";
import { parseXML } from "@web/core/utils/xml";
import { extractFieldsFromArchInfo } from "@web/model/relational_model/utils";
import { RelationalModel } from "@web/model/relational_model/relational_model";
import { isNull } from "@web/views/utils";
import { AccountReturnKanbanRecord } from "./account_return_kanban_record";
import { Chatter } from "@mail/chatter/web_portal_project/chatter";
import { focusNextFlatCard } from "./account_return_kanban_renderer";
import { GlobalBusPlugin } from "@web/core/global_bus_plugin";
import { ORM } from "@web/core/orm_plugin";
import { useEnv } from "@web/owl2/utils";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
const viewRegistry = registry.category("views");
export class AccountReturnCheckKanbanRenderer extends KanbanRenderer {
static template = "account_reports.account_return_check_kanban_renderer";
static components = {
...KanbanRenderer.components,
AccountReturnKanbanRecord,
Chatter,
};
checkCardsRef = signal.ref();
orm = usePlugin(ORM);
action = usePlugin(ActionPlugin);
viewService = useService("view");
record = signal(undefined);
bus = usePlugin(GlobalBusPlugin).bus;
scope = useScope();
setup() {
super.setup();
const context = this.props.list.context;
if (context.active_model === "account.return") {
this.currentReturnId = context.active_id;
useBus(this.bus, "return_reload_model", async (ev) => {
const recordIds = ev.detail.resIds;
if (recordIds.includes(this.currentReturnId)) {
await this.props.list.model.load();
}
});
onWillStart(async () => {
if (!this.currentReturnId) return;
const { fields, relatedModels, views } = await this.viewService.loadViews({
resModel: "account.return",
context: context,
views: [[context.account_return_view_id, "kanban"]],
});
const { ArchParser } = viewRegistry.get("kanban");
const xmlDoc = parseXML(views["kanban"].arch);
this.returnArchInfo = new ArchParser().parse(xmlDoc, relatedModels, 'account.return');
const extractedFields = extractFieldsFromArchInfo(this.returnArchInfo, fields);
// The model is instantiated outside of a synchronous setup (in an async hook), so we
// run it in the component's scope for `usePlugin()` (e.g. the offline plugin) to resolve.
const model = this.scope.run(
() => new RelationalModel(useEnv(), this.getReturnModelParams({ ...context, in_checks_view: true }, extractedFields.activeFields, extractedFields.fields, this.currentReturnId), {orm: this.orm})
);
await model.load();
const originalChecksLoadFunction = this.props.list.model.load.bind(this.props.list.model);
this.props.list.model.load = async (params) => {
if (status(this) === "destroyed") return;
// Reload return card
const result = await this.scope.run(() => originalChecksLoadFunction(params));
if (status(this) === "destroyed") return;
await this.scope.run(() => this.record().load());
if (status(this) === "destroyed") return;
// Reload chatter messages
this.scope.run(
() => this.bus.trigger("MAIL:RELOAD-THREAD", {
model: "account.return",
id: this.currentReturnId,
})
);
return result;
};
this.record.set(model.root);
// Update records checks
const records = this.props.list.records;
if (records.length > 0) {
const checkResults = this.orm.call("account.return", "refresh_checks", [this.currentReturnId])
checkResults.then(() => {
this.scope.run(async () => {
await this.props.list.model.load();
})
});
}
});
}
}
getReturnModelParams(context, activeFields, fields, resId) {
const modelConfig = {
resId: resId,
resIds: [resId],
context: context,
resModel: 'account.return',
fields,
activeFields,
openGroupsByDefault: true,
isMonoRecord: true,
mode: 'readonly',
};
return {
config: modelConfig,
groupsLimit: Number.MAX_SAFE_INTEGER,
limit: 1,
countLimit: 1,
};
}
get groups() {
const { list } = this.props;
if (!list.isGrouped) {
return false;
}
return list.groups.map((group, index) => ({
...group,
key: isNull(group.value) ? `group_key_${index}` : String(group.value),
}));
}
focusNextCard(area, direction) {
return focusNextFlatCard(area, direction);
}
async openRecord(record, params) {
const recordId = record.resId;
if (record.resModel === "account.return.check") {
const result = await this.orm.call(
record.resModel,
"action_review",
[recordId]
);
if (result) {
this.action.doAction(result);
}
}
}
}

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="account_reports.account_return_check_kanban_renderer">
<div class="kanban_checks_view d-flex h-100 overflow-hidden" t-ref="this.rootRef">
<div class="kanban_return_and_checks_cards o_kanban_renderer position-relative flex-grow-1 overflow-x-hidden">
<div class="kanban_return_card position-lg-sticky top-0 z-2 bg-view" t-if="this.record()">
<AccountReturnKanbanRecord
archInfo="this.returnArchInfo"
record="this.record()"
openAction="this.returnArchInfo.openAction"
canOpenRecords="this.returnArchInfo.canOpenRecords"
/>
</div>
<div id="account_return_check_cards" class="kanban_checks_cards pt-2 pb-4 mx-2 w-xxl-75 mx-xxl-auto" t-ref="this.checkCardsRef">
<t t-if="this.groups">
<t t-foreach="this.groups" t-as="group" t-key="group.key">
<t t-if="group.count > 0">
<span class="h5 d-block mt-4 mb-3 fw-bold fs-4">
<t t-out="group.displayName"/>
</span>
<t t-call="account_reports.return_check_list" list="group.list"/>
</t>
</t>
</t>
<t t-else="" t-call="account_reports.return_check_list" list="this.props.list"/>
</div>
</div>
<div class="o_account_return_chatter o-mail-ChatterContainer h-100 w-100 o-aside d-none d-lg-flex flex-column overflow-y-scroll">
<Chatter
threadId="this.currentReturnId"
threadModel="'account.return'"
saveRecord="this.props.list.model.load.bind(this.props.list.model)"
isAttachmentBoxVisibleInitially="this.props.list.context.open_attachments_in_chatter"
/>
</div>
</div>
</t>
<t t-name="account_reports.return_check_list">
<t t-foreach="list.records" t-as="record" t-key="record.id">
<KanbanRecord
record="record"
archInfo="this.props.archInfo"
Compiler="this.props.Compiler"
openRecord.bind="this.openRecord"
canOpenRecords="record.data.action"
/>
</t>
</t>
</templates>

View File

@@ -0,0 +1,15 @@
import { registry } from "@web/core/registry";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { AccountReturnCheckKanbanRenderer } from "./account_return_check_kanban_renderer";
import { AccountReturnCheckKanbanController } from "./account_return_check_kanban_controller";
import { AccountReturnCheckControlPanel } from "./account_return_check_control_panel";
export const accountReturnCheckKanbanView = {
...kanbanView,
Renderer: AccountReturnCheckKanbanRenderer,
Controller: AccountReturnCheckKanbanController,
ControlPanel: AccountReturnCheckControlPanel,
};
registry.category("views").add("account_return_check_kanban", accountReturnCheckKanbanView);

View File

@@ -0,0 +1,31 @@
import { KanbanRecord } from "@web/views/kanban/kanban_record";
export class AccountReturnKanbanRecord extends KanbanRecord {
setup() {
super.setup();
if (this.props.record.data.activity_type_icon === 'check') {
this.props.record.data.activity_type_icon = 'checklist';
}
}
getCardClasses() {
let classes = super.getCardClasses();
// Remove the cursor on the card of the return when being on the checks kanban view
if (this.props.record.context?.in_checks_view) {
classes = classes.replace(/\bcursor-pointer\b/, "");
}
else {
if (this.props.record.data.is_completed) {
classes += " _o_left_border_success";
}
else if (this.props.record.data.days_to_deadline < 0) {
classes += " _o_left_border_danger";
}
else if(this.props.record.data.days_to_deadline <= 7) {
classes += " _o_left_border_warning";
}
}
return classes;
}
}

View File

@@ -0,0 +1,114 @@
import { useBus } from "@web/core/utils/hooks";
import { isNull } from "@web/views/utils";
import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
import {AccountReturnKanbanRecord} from "./account_return_kanban_record";
import { AccountReturnBaseKanbanRenderer } from "./account_return_base_kanban_renderer";
import { useDeleteRecords } from "@web/views/view_hook";
import { usePlugin } from "@odoo/owl";
import { ORM } from "@web/core/orm_plugin";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
import { GlobalBusPlugin } from "@web/core/global_bus_plugin";
/**
* Focus the previous/next card, treating every card of the area as a flat list.
*
* The account return kanban templates lay their cards out in a single column and
* don't render the `.o_kanban_group` elements the standard
* `KanbanRenderer.focusNextCard` relies on, hence this flat implementation.
* Only up/down navigation is supported.
*
* @param {HTMLElement} area
* @param {"down"|"up"|"right"|"left"} direction
* @returns {true|undefined} true if the next card has been focused
*/
export function focusNextFlatCard(area, direction) {
if (direction !== "up" && direction !== "down") {
return;
}
const closestCard = document.activeElement.closest(".o_kanban_record");
if (!closestCard) {
return;
}
const cards = [...area.querySelectorAll(".o_kanban_record")];
const iCard = cards.indexOf(closestCard);
if (iCard === -1) {
return;
}
const nextCard = cards[direction === "down" ? iCard + 1 : iCard - 1];
if (nextCard) {
nextCard.focus();
return true;
}
}
export class AccountReturnKanbanRenderer extends AccountReturnBaseKanbanRenderer {
static template="account_reports.account_return_kanban_renderer";
static components = {
...KanbanRenderer.components,
AccountReturnKanbanRecord
};
orm = usePlugin(ORM);
actionPlugin = usePlugin(ActionPlugin);
setup() {
super.setup();
this.deleteRecordsWithConfirmation = useDeleteRecords(this.props.list.model);
useBus(usePlugin(GlobalBusPlugin).bus, "return_reload_model", (ev) => {
const recordIds = ev.detail.resIds;
let recordToReload = this.records.filter((record) => recordIds.includes(record.resId));
for (let record of recordToReload) {
record.model.load();
}
});
}
deleteRecord(record) {
this.deleteRecordsWithConfirmation({}, [record]);
}
focusNextCard(area, direction) {
return focusNextFlatCard(area, direction);
}
async openRecord(record, params) {
if (record.context?.in_checks_view) {
return
}
const action = await this.orm.call("account.return", "action_open_account_return", [record.resIds]);
if (!action)
return
return this.actionPlugin.doAction(action);
}
get records() {
const { list } = this.props;
if (list.isGrouped) {
return list.groups.flatMap((group) => group.list.records);
}
else {
return list.records;
}
}
get maxStateCount() {
return Math.max(1, ...this.records.map(r => r.data.visible_states.length));
}
get groups() {
const { list } = this.props;
if (!list.isGrouped) {
return false;
}
return list.groups.map((group, i) => ({
...group,
key: isNull(group.value) ? `group_key_${i}` : String(group.value),
}));
}
}

View File

@@ -0,0 +1,30 @@
.o_account-return-kanban {
._o_left_border_success {
box-shadow: inset 5px 0 0 0 var(--success);
}
._o_left_border_danger {
box-shadow: inset 5px 0 0 0 var(--danger);
}
._o_left_border_warning {
box-shadow: inset 5px 0 0 0 var(--warning);
}
.o_kanban_record {
&:focus-visible {
outline: none;
box-shadow: inset 0 0 0 3px var(--KanbanColumn__highlight-selected-border);
}
[data-icon="schedule"] {
opacity: 0;
transition: opacity 0.2s ease;
}
&:hover [data-icon="schedule"] {
opacity: 1;
}
}
}

View File

@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<templates>
<t t-name="account_reports.account_return_kanban_renderer">
<div class="o_kanban_renderer o_renderer o_account-return-kanban mx-lg-2 mx-xl-auto mw-xl-75"
t-ref="this.rootRef"
t-attf-style="--kanban-max-states: #{this.maxStateCount};">
<div t-if="this.groups" class="py-2">
<t t-foreach="this.groups" t-as="group" t-key="group.key">
<div t-if="group.count > 0" class="d-flex flex-column flex-xl-row gap-xl-3 py-2">
<div
class="o_account_return_padding d-xl-flex flex-column align-items-end flex-xl-grow-1 px-lg-0 pt-3 pb-2 fw-bold fs-4"
>
<div
class="text-xl-end py-1"
t-att-class="{'position-sticky top-0 z-1 bg-100': group.list.count &gt; 1}"
t-out="group.displayName"
/>
<div t-if="group.list.count &gt; 1"
class="d-none d-xl-block flex-grow-1 text-400 border-bottom pt-3 mb-4 pe-2 me-1"
>
<span class="vr h-100"/>
</div>
</div>
<div class="col-xl-10 flex-grow-0 flex-shrink-0">
<t t-call="account_reports.return_list" list="group.list"/>
</div>
</div>
</t>
</div>
<div t-else="" class="py-4">
<t t-call="account_reports.return_list" list="this.props.list"/>
</div>
<t t-if="this.showNoContentHelper">
<ActionHelper noContentHelp="this.props.noContentHelp"/>
</t>
</div>
</t>
<t t-name="account_reports.return_list">
<t t-foreach="list.records" t-as="record" t-key="record.id">
<AccountReturnKanbanRecord
record="record"
archInfo="this.props.archInfo"
Compiler="this.props.Compiler"
readonly="false"
forceGlobalClick="false"
canOpenRecords="this.props.archInfo.canOpenRecords"
canResequence="false"
deleteRecord.bind="this.deleteRecord"
openAction="this.props.archInfo.openAction"
openRecord.bind="this.openRecord"
/>
</t>
</t>
</templates>

View File

@@ -0,0 +1,11 @@
import { registry } from "@web/core/registry";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { AccountReturnKanbanRenderer } from "./account_return_kanban_renderer";
export const accountReturnKanbanView = {
...kanbanView,
Renderer: AccountReturnKanbanRenderer
};
registry.category("views").add("account_return_kanban", accountReturnKanbanView);

View File

@@ -0,0 +1,12 @@
import { ActivityMenu } from "@mail/core/web/activity_menu";
import { patch } from "@web/core/utils/patch";
patch(ActivityMenu.prototype, {
availableViews(group) {
if (group.model !== "account.return") {
return super.availableViews(...arguments);
}
return [[false, "kanban"]];
},
});

View File

@@ -0,0 +1,37 @@
import { Component } from "@odoo/owl";
import { DropdownItem } from "@web/core/dropdown/dropdown_item";
import { rpc } from "@web/core/network/rpc";
import { registry } from "@web/core/registry";
import { useEnv } from "@web/owl2/utils";
const cogMenuRegistry = registry.category("cogMenu");
export class RefreshAccountReturns extends Component {
static template = "account_reports.RefreshAccountReturns";
static components = { DropdownItem };
env = useEnv();
async refresh_all_account_returns() {
await rpc("/web/dataset/call_kw/account.return/action_refresh_all_returns", {
model: "account.return",
method: "action_refresh_all_returns",
args: [],
kwargs: {},
});
await this.env.model.load();
}
}
export const refreshAccountReturns = {
Component: RefreshAccountReturns,
groupNumber: 5,
isDisplayed: ({ config }) => {
return config.actionType === "ir.actions.act_window" &&
["kanban"].includes(config.viewType) &&
["account_return_kanban"].includes(config.viewSubType);
},
};
cogMenuRegistry.add("refresh-account-returns-menu", refreshAccountReturns, { sequence: 10 });

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="account_reports.RefreshAccountReturns">
<DropdownItem class="'o_import_menu'" onSelected.bind="this.refresh_all_account_returns">
<i class="oi me-1" data-icon="refresh"/>
Refresh
</DropdownItem>
</t>
</templates>

View File

@@ -0,0 +1,64 @@
import { registry } from "@web/core/registry";
import { _t } from "@web/core/l10n/translation";
import { CharField, charField, charFieldProps } from "@web/views/fields/char/char_field";
import { exprToBoolean } from "@web/core/utils/strings";
import { t, usePlugin, useProps } from "@odoo/owl";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
export class AccountAuditClickableCharField extends CharField {
static template = "account_reports.AccountAuditClickableCharField";
props = useProps({
...charFieldProps,
onclick: t.string(),
});
actionPlugin = usePlugin(ActionPlugin);
async onClickField() {
const test = {
context: this.props.record.context,
resModel: this.props.record.resModel,
name: this.props.onclick,
type: "object",
resId: this.props.record.resId,
};
this.actionPlugin.doActionButton(test);
}
}
export const accountAuditClickableCharField = {
...charField,
component: AccountAuditClickableCharField,
supportedOptions: [
{
label: _t("Dynamic Placeholder"),
name: "placeholder_field",
type: "field",
availableTypes: ["char", "text"],
help: _t(
"Displays the value of the selected field as a textual hint. If the selected field is empty, the static placeholder attribute is displayed instead."
),
},
{
label: _t("OnClick Handler"),
name: "onclick",
type: "function",
availableTypes: ["char", "text"],
help: _t(
"Name of the function to call when the cell value is clicked."
),
},
],
extractProps: ({ attrs, options, placeholder }) => ({
isPassword: exprToBoolean(attrs.password),
dynamicPlaceholder: options.dynamic_placeholder || false,
dynamicPlaceholderModelReferenceField:
options.dynamic_placeholder_model_reference_field || "",
autocomplete: attrs.autocomplete,
placeholder,
onclick: options.onclick,
}),
};
registry.category("fields").add("accountAuditClickableCharField", accountAuditClickableCharField);

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.AccountAuditClickableCharField" t-inherit="web.CharField" t-inherit-mode="primary">
<span t-out="this.formattedValue" position="replace">
<a type="button" aria-label="Audit account" t-on-click="this.onClickField" class="btn-link">
<span t-out="this.formattedValue" />
</a>
</span>
</t>
</templates>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.AccountAuditProgresbar" t-inherit="web.ProgressBarField" t-inherit-mode="primary">
<t t-else="" position="replace">
<t t-else="">
<t t-if="!this.hasMaxValue">
<span class="mx-1">None</span>
</t>
<t t-else="">
<input
t-if="this.isEditable and this.props.isCurrentValueEditable"
t-ref="this.currentValueRef"
class="o_input h-100 text-center"
type="text"
inputmode="decimal"
autocomplete="off"
t-on-focus="this.onInputFocus"
t-on-blur="this.onInputBlur"
/>
<span t-else="" class="mx-1" t-out="this.formatCurrentValue(true)"/>
/
<input
t-if="this.isEditable and this.props.isMaxValueEditable"
class="o_input h-100 text-center"
type="text"
inputmode="decimal"
autocomplete="off"
t-on-focus="this.onInputFocus"
t-on-blur="this.onInputBlur"
/>
<span t-else="" class="mx-1" t-out="this.formatMaxValue(true)"/>
</t>
</t>
</t>
</t>
</templates>

View File

@@ -0,0 +1,28 @@
import { ProgressBarField, progressBarField } from "@web/views/fields/progress_bar/progress_bar_field"
import { registry } from "@web/core/registry";
export class AccountAuditProgressbar extends ProgressBarField {
static template = "account_reports.AccountAuditProgresbar";
get progressBarColorClass() {
if (this.maxValue == 0) {
return "";
}
return this.currentValue > this.maxValue ? this.props.overflowClass : "bg-success";
}
get maxValue() {
return this.props.record.data[this.props.maxValueField];
}
get hasMaxValue() {
return this.props.record.data.hasOwnProperty(this.props.maxValueField)
}
}
export const AccountAuditProgressBarField = {
...progressBarField,
component: AccountAuditProgressbar,
};
registry.category("fields").add("account_audit_progressbar", AccountAuditProgressBarField);

View File

@@ -0,0 +1,23 @@
import { FileModel } from "@web/core/file_viewer/file_model";
export class CheckAttachment extends FileModel {
constructor(fileData) {
super();
this.data = fileData;
for (const property of [
"access_token",
"checksum",
"extension",
"filename",
"id",
"mimetype",
"name",
"type",
"tmpUrl",
"url",
"uploading",
]) {
this[property] = this.data[property];
}
}
}

View File

@@ -0,0 +1,73 @@
import { registry } from "@web/core/registry";
import { useFileViewer } from "@web/core/file_viewer/file_viewer_hook";
import { Component, usePlugin, useProps } from "@odoo/owl";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
import { CheckAttachment } from "./account_return_check_attachment_model";
import { downloadFile } from "@web/core/network/download";
import { ORM } from "@web/core/orm_plugin";
class AccountReturnCheckAttachmentViewer extends Component {
static template = "account_reports.AccountReturnCheckAttachmentViewer";
static components = {
};
props = useProps(standardWidgetProps);
orm = usePlugin(ORM);
setup() {
super.setup();
this.fileViewer = useFileViewer();
}
async openAttachments() {
let result = await this.orm.read(
this.props.record.resModel,
[this.props.record.resId],
["attachment_ids"]
);
if (result) {
const attachmentIds = result[0].attachment_ids;
const attachmentsData = await this.orm.read(
'ir.attachment',
attachmentIds,
[
"access_token",
"checksum",
"id",
"name",
"store_fname",
"type",
"url",
"mimetype",
]
);
let attachments = [];
for (let attachmentData of attachmentsData) {
const splittedName = attachmentData.name.split('.');
const extension = splittedName[splittedName.length - 1];
attachments.push(new CheckAttachment(
{
...attachmentData,
filename: attachmentData.name,
extension: extension,
}
))
}
const viewableFiles = attachments.filter((file) => file.isViewable);
const unviewableFiles = attachments.filter((file) => !file.isViewable);
for (let unviewableFile of unviewableFiles) {
downloadFile(unviewableFile.downloadUrl);
}
if (viewableFiles.length) {
this.fileViewer.open(viewableFiles[0], viewableFiles);
}
}
}
}
export const accountReturnCheckAttachmentViewer = {
component: AccountReturnCheckAttachmentViewer,
}
registry.category("view_widgets").add("account_return_check_attachment_viewer", accountReturnCheckAttachmentViewer)

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.AccountReturnCheckAttachmentViewer">
<button class="btn btn-secondary" data-bs-toggle="button" t-on-click="this.openAttachments">
Open Document
</button>
</t>
</templates>

View File

@@ -0,0 +1,52 @@
import { registry } from "@web/core/registry";
import { Component, usePlugin, useProps } from "@odoo/owl";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
import { FileUploader } from "@web/views/fields/file_handler";
import { ORM } from "@web/core/orm_plugin";
class CustomAccountReturnFileUploaderComponent extends FileUploader {
static template = "account_reports.CustomAccountReturnFileUploaderComponent"
}
class AccountReturnCheckFileUploader extends Component {
static template = "account_reports.AccountReturnCheckFileUploader";
static components = {
FileUploader: CustomAccountReturnFileUploaderComponent
};
props = useProps(standardWidgetProps);
orm = usePlugin(ORM);
attachmentIds = [];
async onFileUploaded(file) {
const att_data = {
name: file.name,
mimetype: file.type,
raw: file.data,
res_model: this.props.record.resModel,
res_id: this.props.record.resId,
};
const [att_id] = await this.orm.create(
"ir.attachment",
[att_data],
{ context: this.props.record.context}
);
this.attachmentIds.push(att_id);
}
async onUploadCompleted() {
await this.orm.write(this.props.record.resModel, [this.props.record.resId], { attachment_ids: this.attachmentIds });
this.attachmentIds = [];
this.props.record.model.load();
}
async onClick(event) {
event.stopPropagation();
}
}
export const accountReturnCheckFileUploader = {
component: AccountReturnCheckFileUploader,
}
registry.category("view_widgets").add("account_return_check_file_uploader", accountReturnCheckFileUploader)

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.AccountReturnCheckFileUploader">
<FileUploader
multiUpload="true"
onUploaded.bind="this.onFileUploaded"
onUploadComplete.bind="this.onUploadCompleted"
onClick.bind="this.onClick"
>
<t t-set-slot="toggler">
<button class="btn btn-secondary">
Upload File
</button>
</t>
</FileUploader>
</t>
<t t-name="account_reports.CustomAccountReturnFileUploaderComponent" t-inherit="web.FileUploader" t-inherit-mode="primary">
<input position="attributes">
<attribute name="data-bs-toggle">input</attribute>
</input>
</t>
</templates>

View File

@@ -0,0 +1,111 @@
import { registry } from "@web/core/registry";
import { formatDate, parseDate } from "@web/core/l10n/dates";
import { Component, onWillStart, proxy, usePlugin, useProps } from "@odoo/owl";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
import { _t } from "@web/core/l10n/translation";
import { ORM } from "@web/core/orm_plugin";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
const { DateTime } = luxon;
export class AccountReturnDashboardList extends Component {
static template = "account_reports.account_return_dashboard_list";
props = useProps(standardWidgetProps);
orm = usePlugin(ORM);
action = usePlugin(ActionPlugin);
state = proxy({ accountReturns: [] });
setup() {
onWillStart(this.fetchNextReturns);
}
formatReturn(accountReturn) {
const deadlineDate = parseDate(accountReturn.date_deadline);
const now = DateTime.now().startOf('day');
const daysDiff = deadlineDate.diff(now, 'days').days;
let deadlineClass = '';
if (daysDiff < 0) { // Overdue
deadlineClass = 'text-danger';
} else if (daysDiff <= 7) {
deadlineClass = 'text-warning';
}
return {
id: accountReturn.id,
name: accountReturn.name,
type_id: accountReturn.type_id,
matchedReturnsCount: accountReturn.matched_returns_count,
deadline: formatDate(deadlineDate),
deadlineClass,
};
}
async fetchNextReturns() {
const applyReturns = (returns) => {
this.state.accountReturns = returns.map(this.formatReturn);
};
const returns = await this.orm
.cache({
type: "disk",
update: "always",
callback: (freshReturns, hasChanged) => {
if (hasChanged) {
applyReturns(freshReturns);
}
},
})
.call(
'account.return',
'get_next_return_for_dashboard',
[this.props.record.resId], //allow_multiple_by_types
);
applyReturns(returns);
}
/**
* Opens the Tax Return view filtered by return type.
* @param {Object} accountReturn - The account return object.
*/
async openTaxReturn(accountReturn) {
const returnTypeId = accountReturn?.type_id || '';
const [viewId, searchViewId] = await this.orm.call("account.return", "get_kanban_view_and_search_view_id", [[accountReturn.id]]);
let action;
if (accountReturn.matchedReturnsCount === 1) {
action = await this.orm.call("account.return", "action_open_account_return", [[accountReturn.id]]);
}
else {
// Open the filtered Tax Return view
action = {
name: _t("Tax Return"),
type: 'ir.actions.act_window',
res_model: 'account.return',
views: [
[viewId || false, 'kanban'],
[false, 'calendar'],
],
search_view_id: [searchViewId || false],
context: {
'search_default_groupby_deadline': 1,
'search_default_todo_returns': 1,
// Apply name filter using return type
'search_default_type_id': returnTypeId,
'max_number_opened_groups': 100000,
},
domain: [['return_type_category', '=', 'account_return']],
};
}
this.action.doAction(action);
}
}
export const accountReturnDashboardList = {
component: AccountReturnDashboardList,
}
registry.category("view_widgets").add("account_return_dashboard_list", accountReturnDashboardList);

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="account_reports.account_return_dashboard_list">
<table>
<t t-foreach="this.state.accountReturns" t-as="accountReturn" t-key="accountReturn.id">
<tr>
<td class="px-1 text-start">
<a t-att-title="accountReturn.name"
href="#"
role="button"
class="me-2"
t-on-click="() => this.openTaxReturn(accountReturn)"
t-out="accountReturn.name"/>
</td>
<td class="px-1 text-end" t-att-class="accountReturn.deadlineClass">
<t t-out="accountReturn.deadline"/>
</td>
</tr>
</t>
</table>
</t>
</templates>

View File

@@ -0,0 +1,50 @@
import { registry } from "@web/core/registry";
import { Component, onMounted, signal, t, useProps } from "@odoo/owl";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
export class AccountReturnEditable extends Component {
static template = "account_reports.AccountReturnEditableBadgeField";
props = useProps({
...standardFieldProps,
type: t.string(),
placeholder: t.string().optional(),
widget_class: t.string().optional(),
});
textareaRef = signal.ref();
setup() {
super.setup();
onMounted(() => {
if (this.textareaRef()) {
this.resize();
}
});
}
updateField(event) {
const value = event.target.value;
this.props.record.update({ [this.props.name]: value });
this.props.record.save();
}
resize() {
// This can be replaced in the future by `field-sizing: content;` on the textarea
// but it's not yet supported in all browsers (firefox and safari).
this.textareaRef().style.height = "0"; // To force recalculation of scrollHeight
this.textareaRef().style.height = this.textareaRef().scrollHeight + "px";
}
}
export const accountReturnEditableBadge = {
supportedTypes: ["char", "text"],
component: AccountReturnEditable,
extractProps: ({ placeholder, type, attrs }, dynamicInfo) => ({
placeholder,
type,
widget_class: attrs.widget_class,
readonly: dynamicInfo.readonly,
}),
};
registry.category("fields").add("account_return_editable_badge", accountReturnEditableBadge);

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="account_reports.AccountReturnEditableBadgeField" >
<t t-if="this.props.type === 'char'">
<input type="text" t-att-value="this.props.record.data[this.props.name]" class="bg-transparent border-0"
t-att-readonly="this.props.readonly"
t-on-blur="this.updateField" t-on-click="(e) => {e.stopPropagation();}" t-att-placeholder="this.props.placeholder || ''"
t-att-class="this.props.widget_class || ''"/>
</t>
<t t-elif="this.props.type === 'text'">
<textarea t-att-value="this.props.record.data[this.props.name]" class="bg-transparent border-0" style="resize: none; text-align: justify; text-justify: inter-word; overflow-x: hidden; overflow-wrap: break-word;"
t-att-readonly="this.props.readonly"
t-on-blur="this.updateField" t-on-click="(e) => {e.stopPropagation();}" t-att-placeholder="this.props.placeholder || ''"
t-att-class="this.props.widget_class || ''" t-on-input="this.resize" t-ref="this.textareaRef"/>
</t>
</t>
</templates>

View File

@@ -0,0 +1,46 @@
import { Component, t, usePlugin, useProps } from "@odoo/owl";
import { ORM } from "@web/core/orm_plugin";
import { registry } from "@web/core/registry";
import { standardWidgetProps } from "@web/views/widgets/standard_widget_props";
import { ActionPlugin } from "@web/webclient/actions/action_plugin";
class AccountReturnWizardButton extends Component {
static template = "account_reports.AccountReturnWizardButton";
props = useProps({
...standardWidgetProps,
btnClass: t.string().optional("btn btn-primary"),
string: t.string().optional(""),
call: t.string(),
});
orm = usePlugin(ORM);
action = usePlugin(ActionPlugin);
async onClick() {
if (!this.props.call) {
throw "Call props is missing";
}
const result = await this.orm.call(
this.props.record.resModel,
this.props.call,
[this.props.record.resId]
)
this.props.record.model.load();
if (result) {
this.action.doAction(result);
}
}
}
export const accountReturnWizardButton = {
component: AccountReturnWizardButton,
extractProps: ({ attrs }) => ({
btnClass: attrs.btn_class,
string: attrs.string,
call: attrs.call
})
}
registry.category("view_widgets").add("account_return_wizard_button", accountReturnWizardButton)

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="account_reports.AccountReturnWizardButton" >
<button
t-att-class="this.props.btnClass"
t-out="this.props.string"
t-on-click="this.onClick" />
</t>
</templates>

Some files were not shown because too many files have changed in this diff Show More