[ADD] membership_status_in_portal: portal membership status badge

Add a generic module displaying the connected portal user's membership
status in the account sidebar, below the "Edit information" link.

The native Odoo membership label (``res.partner.membership_state`` from
the ``membership`` module) is shown as a colored badge:
- green (``text-bg-success``) for free / paid members;
- yellow (``text-bg-warning``) for waiting / invoiced members;
- red (``text-bg-danger``) otherwise.

Color, icon and label are computed in the QWeb template; no model or
field is added. Includes HttpCase tests covering member and non-member
rendering and asserting no action button is rendered.
This commit is contained in:
Stéphan Sainléger
2026-09-21 14:26:43 +02:00
parent ccdd1db968
commit 34f70b342c
7 changed files with 180 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<template
id="portal_side_content_membership_status"
name="Portal Sidebar: Membership Status"
inherit_id="portal.side_content"
priority="40"
>
<xpath expr="//a[@href='/my/account']" position="after">
<div class="o_membership_state mt-3">
<t t-set="state" t-value="user_id.partner_id.membership_state" />
<t
t-set="state_label"
t-value="dict(user_id.partner_id.fields_get(['membership_state'])['membership_state']['selection']).get(state)"
/>
<t
t-set="state_color"
t-value="{'free': 'success', 'paid': 'success', 'invoiced': 'warning', 'waiting': 'warning'}.get(state, 'danger')"
/>
<t
t-set="state_icon"
t-value="{'free': 'fa-check', 'paid': 'fa-check', 'invoiced': 'fa-clock-o', 'waiting': 'fa-clock-o'}.get(state, 'fa-remove')"
/>
<span
t-attf-class="badge rounded-pill text-bg-#{state_color} fs-6"
t-att-title="state_label"
>
<i t-attf-class="fa fa-fw #{state_icon}" role="img" />
<span t-out="state_label" class="ms-1" />
</span>
</div>
</xpath>
</template>
</odoo>