Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][FIX] partner_stage: Add 'order' in _read_group_stage_id to fix group… #1985

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions partner_stage/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def _get_default_stage_id(self):
)

@api.model
def _read_group_stage_id(self, states, domain, order):
return states.search([])
def _read_group_stage_id(self, stages, domain, order=None):
order = order or "sequence, id"
return stages.search([], order=order)
Comment on lines +18 to +19
Copy link
Member

Choose a reason for hiding this comment

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

Even simpler, sparing 1 LOC?

Suggested change
order = order or "sequence, id"
return stages.search([], order=order)
return stages.search([], order=order or "sequence, id")

Comment on lines +17 to +19
Copy link

@celm1990 celm1990 Feb 21, 2025

Choose a reason for hiding this comment

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

I'm not sure if this change is correct.
According to the definition, the order parameter should be removed because only two parameters are expected: groups, domain, not order:
https://github.com/odoo/odoo/blob/6caa783991dad7272391ae8ea0e76f32eadc9401/odoo/models.py#L2330

The original order should be preserved, like this:

Suggested change
def _read_group_stage_id(self, stages, domain, order=None):
order = order or "sequence, id"
return stages.search([], order=order)
def _read_group_stage_id(self, stages, domain):
order = order or "sequence, id"
return stages.search([], order=stages._order)

Additionally, for consistency, this function should now be renamed to _read_group_stage_ids in both the function definition and the corresponding field definition.
For example:
https://github.com/odoo/odoo/blob/6caa783991dad7272391ae8ea0e76f32eadc9401/addons/maintenance/models/maintenance.py#L405-L410


stage_id = fields.Many2one(
comodel_name="res.partner.stage",
Expand Down