[FIX] website_membership: don't display old as members

Follow-up of 5ac77c9 which solved the issue when an association was
selected, but not when "All Members" was choosen.

Before this commit, the displayed membership lines would only be the
paid ones, if an association (membership product) was selected. With
this commit this is also the case when no such association is selected.

This commit also correct the member counts in the "country" list :

* with "All members" the free members were not in the counts,
* with not "Free member", the counts didn't took the eventual current name search.

closes #9083
opw-648627
This commit is contained in:
Nicolas Lempereur 2015-10-15 11:34:49 +02:00
parent 5575f98db1
commit ba9771d6ec
1 changed files with 11 additions and 9 deletions

View File

@ -37,16 +37,16 @@ class WebsiteMembership(http.Controller):
partner_obj = request.registry['res.partner']
post_name = post.get('name', '')
current_country = None
today = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
# base domain for groupby / searches
base_line_domain = [("partner.website_published", "=", True), ('state', 'in', ['free', 'paid'])]
base_line_domain = [
("partner.website_published", "=", True), ('state', '=', 'paid'),
('date_to', '>=', today), ('date_from', '<=', today)
]
if membership_id and membership_id != 'free':
membership_id = int(membership_id)
today = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
base_line_domain += [
('membership_id', '=', membership_id), ('date_to', '>=', today),
('date_from', '<=', today), ('state', '=', 'paid')
]
base_line_domain.append(('membership_id', '=', membership_id))
membership = product_obj.browse(cr, uid, membership_id, context=context)
else:
membership = None
@ -58,12 +58,14 @@ class WebsiteMembership(http.Controller):
if membership_id != 'free':
membership_line_ids = membership_line_obj.search(cr, SUPERUSER_ID, base_line_domain, context=context)
country_domain = [('member_lines', 'in', membership_line_ids)]
if not membership_id:
country_domain = ['|', country_domain[0], ('membership_state', '=', 'free')]
else:
membership_line_ids = []
country_domain = [('membership_state', '=', 'free')]
if post_name:
country_domain += ['|', ('name', 'ilike', post_name),
('website_description', 'ilike', post_name)]
if post_name:
country_domain += ['|', ('name', 'ilike', post_name),
('website_description', 'ilike', post_name)]
countries = partner_obj.read_group(
cr, SUPERUSER_ID, country_domain + [("website_published", "=", True)], ["id", "country_id"],
groupby="country_id", orderby="country_id", context=request.context)