[REF] all: pass pre-commit on the whole repo
Needed for the lint job of the CI to go green. Mostly automatic hook fixes (black, isort, prettier, pyupgrade, autoflake, whitespace). By hand: - flake8: two unused imports, an ambiguous variable name `l`. - pylint-odoo mandatory: manifest keys equal to their default value (installable, application, data, external_dependencies). - end-of-file-fixer skips *.patch too, like trailing-whitespace: the upstream patches stay as git format-patch wrote them. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9d9e8be2d
commit
fbd43bb459
45 changed files with 330 additions and 295 deletions
|
|
@ -13,5 +13,4 @@
|
|||
"membership",
|
||||
"website_membership",
|
||||
],
|
||||
"data": [],
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, http
|
||||
from odoo import fields
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.tools.translate import _
|
||||
|
||||
|
|
@ -28,9 +29,7 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
self._add_associate_members(response, membership_id, country_id, page, post)
|
||||
return response
|
||||
|
||||
def _add_associate_members(
|
||||
self, response, membership_id, country_id, page, post
|
||||
):
|
||||
def _add_associate_members(self, response, membership_id, country_id, page, post):
|
||||
values = response.qcontext
|
||||
memberships_partner_ids = values.get("memberships_partner_ids", {})
|
||||
if not memberships_partner_ids:
|
||||
|
|
@ -67,25 +66,19 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
if associate.id not in new_memberships_partner_ids[key]:
|
||||
new_memberships_partner_ids[key].append(associate.id)
|
||||
values["memberships_partner_ids"] = {
|
||||
key: ids
|
||||
for key, ids in new_memberships_partner_ids.items()
|
||||
if ids
|
||||
key: ids for key, ids in new_memberships_partner_ids.items() if ids
|
||||
}
|
||||
|
||||
displayed_ids = set(
|
||||
pid
|
||||
for ids in values["memberships_partner_ids"].values()
|
||||
for pid in ids
|
||||
)
|
||||
displayed_ids = {
|
||||
pid for ids in values["memberships_partner_ids"].values() for pid in ids
|
||||
}
|
||||
values["partners"] = {
|
||||
p.id: p
|
||||
for p in request.env["res.partner"]
|
||||
.sudo()
|
||||
.browse(list(displayed_ids))
|
||||
for p in request.env["res.partner"].sudo().browse(list(displayed_ids))
|
||||
}
|
||||
|
||||
all_host_ids, all_free_host_ids, all_associates = (
|
||||
self._get_all_visible_ids(membership_id, country_id, post_name)
|
||||
all_host_ids, all_free_host_ids, all_associates = self._get_all_visible_ids(
|
||||
membership_id, country_id, post_name
|
||||
)
|
||||
self._recompute_countries(
|
||||
values, all_host_ids, all_free_host_ids, all_associates, country_id
|
||||
|
|
@ -134,9 +127,7 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
if membership_id == "free":
|
||||
all_host_ids = set()
|
||||
else:
|
||||
all_host_ids = self._get_all_host_ids(
|
||||
membership_id, country_id, post_name
|
||||
)
|
||||
all_host_ids = self._get_all_host_ids(membership_id, country_id, post_name)
|
||||
all_free_host_ids = (
|
||||
self._get_all_free_host_ids(country_id, post_name)
|
||||
if free_selected
|
||||
|
|
@ -214,8 +205,7 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
if country_id:
|
||||
current_country = Country.browse(country_id).read(["id", "name"])[0]
|
||||
if not any(
|
||||
x["country_id"] and x["country_id"][0] == country_id
|
||||
for x in countries
|
||||
x["country_id"] and x["country_id"][0] == country_id for x in countries
|
||||
):
|
||||
countries.append(
|
||||
{
|
||||
|
|
@ -243,16 +233,12 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
return
|
||||
partners = request.env["res.partner"].sudo().browse(map_ids)
|
||||
if country_id:
|
||||
partners = partners.filtered(
|
||||
lambda p: p.country_id.id == country_id
|
||||
)
|
||||
partners = partners.filtered(lambda p: p.country_id.id == country_id)
|
||||
if post_name:
|
||||
partners = partners.filtered(
|
||||
lambda p: self._partner_matches_search(p, post_name)
|
||||
)
|
||||
values["google_map_partner_ids"] = ",".join(
|
||||
str(pid) for pid in partners.ids
|
||||
)
|
||||
values["google_map_partner_ids"] = ",".join(str(pid) for pid in partners.ids)
|
||||
|
||||
def _update_pager(
|
||||
self,
|
||||
|
|
@ -268,9 +254,7 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
if membership_id == "free":
|
||||
displayed_host_ids = set()
|
||||
else:
|
||||
host_records = request.env["res.partner"].sudo().browse(
|
||||
list(all_host_ids)
|
||||
)
|
||||
host_records = request.env["res.partner"].sudo().browse(list(all_host_ids))
|
||||
displayed_host_ids = {
|
||||
host.id
|
||||
for host in host_records
|
||||
|
|
@ -278,7 +262,7 @@ class WebsiteMembership(BaseWebsiteMembership):
|
|||
}
|
||||
count_members = len(displayed_host_ids) + len(all_free_host_ids)
|
||||
limit = self._references_per_page
|
||||
base_url = "/members%s%s" % (
|
||||
base_url = "/members{}{}".format(
|
||||
"/association/%s" % membership_id if membership_id else "",
|
||||
"/country/%s" % country_id if country_id else "",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright 2026 Criptomart
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import api
|
||||
from odoo import models
|
||||
from odoo.osv import expression
|
||||
|
||||
|
||||
|
|
@ -41,10 +42,7 @@ class MembershipLine(models.Model):
|
|||
("website_description", "ilike", post_name),
|
||||
]
|
||||
host_ids = (
|
||||
self.env["res.partner"]
|
||||
.sudo()
|
||||
.search(associate_domain)
|
||||
.associate_member.ids
|
||||
self.env["res.partner"].sudo().search(associate_domain).associate_member.ids
|
||||
)
|
||||
if not host_ids:
|
||||
return domain
|
||||
|
|
@ -84,8 +82,7 @@ class MembershipLine(models.Model):
|
|||
AND p.is_company
|
||||
AND m.id IN %s
|
||||
ORDER BY p.id
|
||||
"""
|
||||
+ limit_clause,
|
||||
""" + limit_clause,
|
||||
(tuple(self.ids),),
|
||||
)
|
||||
return [row[0] for row in self.env.cr.fetchall()]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import HttpCase, tagged
|
||||
from odoo.tests import HttpCase
|
||||
from odoo.tests import tagged
|
||||
|
||||
from odoo.addons.membership.tests.common import TestMembershipCommon
|
||||
|
||||
|
|
@ -125,9 +126,7 @@ class TestWebsiteMembershipAssociatePagination(HttpCase, TestMembershipCommon):
|
|||
for i in range(20)
|
||||
]
|
||||
cls.paginated_hosts = cls.env["res.partner"].create(host_vals)
|
||||
invoices = cls.paginated_hosts.create_membership_invoice(
|
||||
cls.membership_1, 75.0
|
||||
)
|
||||
invoices = cls.paginated_hosts.create_membership_invoice(cls.membership_1, 75.0)
|
||||
invoices.action_post()
|
||||
cls.env["account.payment.register"].with_context(
|
||||
active_model="account.move", active_ids=invoices.ids
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue