Skip to content

Commit

Permalink
[MIG] website_membership_random_order: Migration to 17.0
Browse files Browse the repository at this point in the history
TT51560
  • Loading branch information
victoralmau committed Nov 15, 2024
1 parent d096f89 commit a5c1f75
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
2 changes: 1 addition & 1 deletion website_membership_random_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Online Members Directory - Random order",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Association",
"website": "https://github.com/OCA/vertical-association",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
5 changes: 0 additions & 5 deletions website_membership_random_order/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,3 @@ msgid ""
msgstr ""
"Este orden de aparición es aleatorio y cambia cada vez que actualiza.\n"
" <br/>"

#~ msgid ""
#~ "This order of appearance is random and changes each time you refresh."
#~ msgstr ""
#~ "Este orden de aparición es aleatorio y cambia cada vez que se refresca."
9 changes: 0 additions & 9 deletions website_membership_random_order/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,3 @@ msgstr ""
"L'ordinei di visualizzazione è causale e cambia e cambia ad ogni "
"aggiornamento.\n"
" <br/>"

#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"

#~ msgid "ID"
#~ msgstr "ID"

#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"
8 changes: 3 additions & 5 deletions website_membership_random_order/models/membership_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
class MembershipLine(models.Model):
_inherit = "membership.membership_line"

def search(self, args, offset=0, limit=None, order=None, count=False):
def search(self, domain, offset=0, limit=None, order=None):
"""If we detect the injected context, and only when the search is done with
limit (as there are 2 calls to search in the controller), we search for all
the results, randomize them, and return them. We can't do slices, as if not, we
won't be able to show all the records due to the pager and each time returning
random results.
"""
if self.env.context.get("random_membership_line_order") and limit:
record_ids = super().search(args, limit=None).ids
record_ids = super().search(domain, limit=None).ids
random.shuffle(record_ids)
return self.browse(record_ids)
return super().search(
args, offset=offset, limit=limit, order=order, count=count
)
return super().search(domain, offset=offset, limit=limit, order=order)

Check warning on line 23 in website_membership_random_order/models/membership_line.py

View check run for this annotation

Codecov / codecov/patch

website_membership_random_order/models/membership_line.py#L20-L23

Added lines #L20 - L23 were not covered by tests

0 comments on commit a5c1f75

Please sign in to comment.