[IMP] rma: Use _prepare_home_portal_values() function.

This commit is contained in:
Víctor Martínez
2022-09-02 17:58:23 +02:00
parent 9a53ea0035
commit 171fd36ef2
3 changed files with 16 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
{ {
"name": "Return Merchandise Authorization Management", "name": "Return Merchandise Authorization Management",
"summary": "Return Merchandise Authorization (RMA)", "summary": "Return Merchandise Authorization (RMA)",
"version": "15.0.1.0.1", "version": "15.0.1.1.0",
"development_status": "Production/Stable", "development_status": "Production/Stable",
"category": "RMA", "category": "RMA",
"website": "https://github.com/OCA/rma", "website": "https://github.com/OCA/rma",

View File

@@ -1,4 +1,5 @@
# Copyright 2020 Tecnativa - Ernesto Tejeda # Copyright 2020 Tecnativa - Ernesto Tejeda
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import _, exceptions, http from odoo import _, exceptions, http
@@ -10,12 +11,16 @@ from odoo.addons.portal.controllers.portal import CustomerPortal, pager as porta
class PortalRma(CustomerPortal): class PortalRma(CustomerPortal):
def _prepare_portal_layout_values(self): def _prepare_home_portal_values(self, counters):
values = super()._prepare_portal_layout_values() values = super()._prepare_home_portal_values(counters)
if request.env["rma"].check_access_rights("read", raise_exception=False): if "rma_count" in counters:
values["rma_count"] = request.env["rma"].search_count([]) rma_model = request.env["rma"]
else: rma_count = (
values["rma_count"] = 0 rma_model.search_count([])
if rma_model.check_access_rights("read", raise_exception=False)
else 0
)
values["rma_count"] = rma_count
return values return values
def _rma_get_page_view_values(self, rma, access_token, **kwargs): def _rma_get_page_view_values(self, rma, access_token, **kwargs):
@@ -36,6 +41,9 @@ class PortalRma(CustomerPortal):
def portal_my_rmas(self, page=1, date_begin=None, date_end=None, sortby=None, **kw): def portal_my_rmas(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
values = self._prepare_portal_layout_values() values = self._prepare_portal_layout_values()
rma_obj = request.env["rma"] rma_obj = request.env["rma"]
# Avoid error if the user does not have access.
if not rma_obj.check_access_rights("read", raise_exception=False):
return request.redirect("/my")
domain = self._get_filter_domain(kw) domain = self._get_filter_domain(kw)
searchbar_sortings = { searchbar_sortings = {
"date": {"label": _("Date"), "order": "date desc"}, "date": {"label": _("Date"), "order": "date desc"},

View File

@@ -31,7 +31,7 @@
<t t-call="portal.portal_docs_entry"> <t t-call="portal.portal_docs_entry">
<t t-set="title">RMA Orders</t> <t t-set="title">RMA Orders</t>
<t t-set="url" t-value="'/my/rmas'" /> <t t-set="url" t-value="'/my/rmas'" />
<t t-set="count" t-value="rma_count" /> <t t-set="placeholder_count" t-value="'rma_count'" />
</t> </t>
</xpath> </xpath>
</template> </template>