Skip to content

Commit 4bef0e4

Browse files
committed
[FIX] l10n_uy_reports_ux: Tax type filter
Before this change we were not showing tthe tax filter that let us to select between sale and purchase taxes closes #381 Signed-off-by: Julia Elizondo - jue (#l10n) <jue@adhoc.com.ar>
1 parent 23c9e12 commit 4bef0e4

5 files changed

Lines changed: 39 additions & 21 deletions

File tree

l10n_uy_reports_ux/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Part of Odoo. See LICENSE file for full copyright and licensing details.
22
{
33
"name": "Uruguay - Accounting Reports UX",
4-
"version": "19.0.1.0.0",
4+
"version": "19.0.1.0.1",
55
"author": "ADHOC SA",
66
"license": "LGPL-3",
77
"category": "Localization",

l10n_uy_reports_ux/models/l10n_uy_vat_book.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,19 @@ def _custom_options_initializer(self, report, options, previous_options):
7777
# Exporting the file is not allowed for 'purchase'. When executing the export tests, we hence always select 'sales', to avoid raising.
7878
options["uy_vat_book_tax_types_available"]["purchase"]["selected"] = False
7979

80-
options["forced_domain"] = [
81-
*options.get("forced_domain", []),
82-
("journal_id.l10n_latam_use_documents", "!=", False),
83-
]
80+
options["forced_domain"] = [
81+
*options.get("forced_domain", []),
82+
("journal_id.l10n_latam_use_documents", "!=", False),
83+
]
84+
85+
options["custom_display_config"] = {
86+
"templates": {
87+
"AccountReportFilters": "l10n_uy_reports_ux.L10nUyTaxReportFiltersCustomizable",
88+
},
89+
"components": {
90+
"AccountReportFilters": "L10nUYTaxReportFilters",
91+
},
92+
}
8493

8594
####################################################
8695
# REPORT LINES: CORE

l10n_uy_reports_ux/static/src/components/uruguayan_report/filter_tax_type.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
</button>
88

99
<t t-set-slot="content">
10-
<t t-foreach="Object.entries(controller.options.uy_vat_book_tax_types_available)" t-as="taxType" t-key="taxType[0]">
10+
<t t-foreach="Object.entries(controller.cachedFilterOptions.uy_vat_book_tax_types_available)" t-as="taxTypeUy" t-key="taxTypeUy[0]">
1111
<DropdownItem
12-
class="{ 'selected': taxType[1]['selected'] }"
13-
onSelected="() => this.selectUyVatBookTaxType(taxType[0])"
12+
class="{ 'selected': taxTypeUy[1]['selected'] }"
13+
onSelected="() => this.selectUyVatBookTaxType(taxTypeUy[0])"
1414
closingMode="'none'"
1515
>
16-
<t t-esc="taxType[1]['name']"/>
16+
<t t-esc="taxTypeUy[1]['name']"/>
1717
</DropdownItem>
1818
</t>
1919
</t>
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
import { _t } from "@web/core/l10n/translation";
2-
import { patch } from "@web/core/utils/patch";
2+
3+
import { AccountReport } from "@account_reports/components/account_report/account_report";
34
import { AccountReportFilters } from "@account_reports/components/account_report/filters/filters";
45

5-
patch(AccountReportFilters.prototype, {
6+
export class L10nUYTaxReportFilters extends AccountReportFilters {
67
get selectedUYTaxType() {
7-
const availableTypes = Object.keys(this.controller.options.uy_vat_book_tax_types_available);
8+
if (!this.controller.cachedFilterOptions.uy_vat_book_tax_types_available) {
9+
return _t("All");
10+
}
11+
const availableTypes = Object.keys(this.controller.cachedFilterOptions.uy_vat_book_tax_types_available);
812
const selectedTypes = Object.values(
9-
this.controller.options.uy_vat_book_tax_types_available,
13+
this.controller.cachedFilterOptions.uy_vat_book_tax_types_available,
1014
).filter((type) => type.selected);
1115

1216
if (selectedTypes.length === availableTypes.length || selectedTypes.length === 0) {
1317
return _t("All");
1418
}
1519

1620
return selectedTypes.map((type) => type.name).join(", ");
17-
},
21+
}
1822

1923
selectUyVatBookTaxType(taxType) {
20-
const newUyVatBookTaxTypes = Object.assign(
24+
if (!this.controller.cachedFilterOptions.uy_vat_book_tax_types_available) {
25+
return;
26+
}
27+
const newUYVatBookTaxTypes = Object.assign(
2128
{},
22-
this.controller.options.uy_vat_book_tax_types_available,
29+
this.controller.cachedFilterOptions.uy_vat_book_tax_types_available,
2330
);
24-
newUyVatBookTaxTypes[taxType]["selected"] = !newUyVatBookTaxTypes[taxType]["selected"];
25-
this.filterClicked({ optionKey: "uy_vat_book_tax_types_available", optionValue: newUyVatBookTaxTypes, reload: true});
26-
},
27-
});
31+
newUYVatBookTaxTypes[taxType]["selected"] = !newUYVatBookTaxTypes[taxType]["selected"];
32+
this.filterClicked({ optionKey: "uy_vat_book_tax_types_available", optionValue: newUYVatBookTaxTypes, reload: true});
33+
}
34+
}
35+
36+
AccountReport.registerCustomComponent(L10nUYTaxReportFilters);

l10n_uy_reports_ux/static/src/components/uruguayan_report/filters.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<templates>
3-
<t t-name="l10n_uy_reports_ux.L10nUyReportsFiltersCustomizable" t-inherit="account_reports.GenericTaxReportFiltersCustomizable">
3+
<t t-name="l10n_uy_reports_ux.L10nUyTaxReportFiltersCustomizable" t-inherit="account_reports.AccountReportFiltersCustomizable">
44
<xpath expr="//div[@id='filter_variant']" position="after">
55
<div class="acc_rep_filter_tax_unit">
66
<t t-call="l10n_uy_reports_ux.L10nUyReportsFilterTaxType"/>

0 commit comments

Comments
 (0)