Skip to content

[16.0][ADD] portal_pager_size - #1201

Open
halbtonjazz wants to merge 1 commit into
OCA:16.0from
xxp-odoo-erp:16.0-t0350-website_portal_pager_limit
Open

halbtonjazz wants to merge 1 commit into
OCA:16.0from
xxp-odoo-erp:16.0-t0350-website_portal_pager_limit

Conversation

@halbtonjazz

Copy link
Copy Markdown

Description

New module that adds a configurable page size selector to the portal
pager. Portal users can pick how many records are shown per page
(10/20/40/80/100 by default) via a dropdown next to the pagination
controls. The choice is applied through a limit query parameter and
kept while paginating, sorting, filtering and searching.

Allowed values are whitelisted through the
website_portal_pager_limit.options system parameter; any invalid or
out-of-list value falls back to the standard portal page size (80), so a
misconfiguration can never break pagination.

How it works

  • Controller exposes _items_per_page as a property reading the
    validated limit, so every /my/* route benefits without overriding
    each route.
  • portal.pager is inherited to render the selector (kept visible even
    on single-page lists).
  • Frontend JS propagates the limit to pager links.

Task: 0350

@OCA-git-bot OCA-git-bot added series:16.0 mod:website_portal_pager_limit Module website_portal_pager_limit labels Jun 16, 2026

@geomer198 geomer198 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check code review result.

param = (
request.env["ir.config_parameter"]
.sudo()
.get_param(OPTIONS_PARAM, default="10,20,40,80,100")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better use default value=False and then use DEFAULT_LIMIT_OPTIONS const without split methods?

param = request.env["ir.config_parameter].sudo().get_param(OPTIONS_PARAM, default=False)
if not param:
    return DEFAULT_LIMIT_OPTIONS
return [int(x.strip()) for x in param.split(",") if x.strip().isdigit()] or DEFAULT_LIMIT_OPTIONS

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

_request_stack.pop()


class TestPagerLimitOptions(TestPortalPagerLimitCommon):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this file.
Use for each test class separate file for tests.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@geomer198 geomer198 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check proposed changes.

"""
param = request.env["ir.config_parameter"].sudo().get_param(OPTIONS_PARAM)
if not param:
return list(DEFAULT_LIMIT_OPTIONS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you convert list to list?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was meant as a defensive copy against append, sort, etc. I just didn't notice the constant was already a list, not a tuple. Reworked the constant into a tuple, now list() actually makes sense (a fresh mutable list from an immutable constant)

if not param:
return list(DEFAULT_LIMIT_OPTIONS)
options = [int(x.strip()) for x in param.split(",") if x.strip().isdigit()]
return options or list(DEFAULT_LIMIT_OPTIONS)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same


def _prepare_portal_layout_values(self):
values = super()._prepare_portal_layout_values()
values.update(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment this with describe about new functional.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# honors the ``limit`` query parameter without overriding each route.
@property
def _items_per_page(self):
limit = request.httprequest.args.get("limit", "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring is missing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@geomer198 geomer198 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Bearnard21 Bearnard21 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@Bearnard21

Copy link
Copy Markdown

@pedrobaeza Hello, could you please take a look? Thank you.

@pedrobaeza pedrobaeza added this to the 16.0 milestone Jun 28, 2026
@pedrobaeza

Copy link
Copy Markdown
Member

portal can work without website, and limit express a restriction more than a configuration IMO, so I would call it portal_pager_size.

@OCA-git-bot OCA-git-bot added mod:portal_pager_size Module portal_pager_size and removed mod:website_portal_pager_limit Module website_portal_pager_limit labels Aug 22, 2026
@halbtonjazz

Copy link
Copy Markdown
Author

portal can work without website, and limit express a restriction more than a configuration IMO, so I would call it portal_pager_size.

@pedrobaeza
fixed, please check

@halbtonjazz halbtonjazz changed the title [16.0][ADD] website_portal_pager_limit [16.0][ADD] portal_pager_size Aug 24, 2026
Comment thread portal_pager_size/templates/portal_templates.xml Outdated
@halbtonjazz

Copy link
Copy Markdown
Author

@pedrobaeza
Could you please take a look at this PR when you have a chance?
Thanks

@pedrobaeza

Copy link
Copy Markdown
Member

Formally, this should be squashed into one commit. About the module itself, I can't say.

Add a page size selector to portal pager lists. Users pick how many
records per page via a whitelisted limit query parameter configurable
in system parameters.

Task: 0350
@halbtonjazz
halbtonjazz force-pushed the 16.0-t0350-website_portal_pager_limit branch from 732e117 to 1982169 Compare September 13, 2026 16:52
@halbtonjazz

Copy link
Copy Markdown
Author

Formally, this should be squashed into one commit. About the module itself, I can't say.

Done,
the commits are squashed and rebased, please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants