fix(portal): account summary 500 — open_balance can't use t-field

t-field requires a record.field_name access pattern. open_balance is a
Python float (returned by _fp_account_summary_open_balance), not a
recordset attribute, so QWeb threw AssertionError at render time and
the page 500'd. Format the value in the controller via tools.formatLang
and render it as a plain string with t-out instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-17 23:36:10 -04:00
parent 6f2bea9773
commit 3a520564a7
2 changed files with 9 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ from datetime import datetime, time as dt_time
from odoo import _, http from odoo import _, http
from odoo.exceptions import AccessError, MissingError from odoo.exceptions import AccessError, MissingError
from odoo.http import request from odoo.http import request
from odoo.tools import formatLang
from odoo.addons.portal.controllers.portal import ( from odoo.addons.portal.controllers.portal import (
CustomerPortal, CustomerPortal,
pager as portal_pager, pager as portal_pager,
@@ -551,6 +552,11 @@ class FpCustomerPortal(CustomerPortal):
step=self._FP_ACCOUNT_SUMMARY_PER_PAGE, step=self._FP_ACCOUNT_SUMMARY_PER_PAGE,
) )
currency = (
commercial.property_account_receivable_id.currency_id
if commercial.property_account_receivable_id
else request.env.company.currency_id
)
values = self._prepare_portal_layout_values() values = self._prepare_portal_layout_values()
values.update({ values.update({
'page_name': 'fp_account_summary', 'page_name': 'fp_account_summary',
@@ -561,8 +567,8 @@ class FpCustomerPortal(CustomerPortal):
'search': search, 'search': search,
'sort': sort, 'sort': sort,
'open_balance': open_balance, 'open_balance': open_balance,
'currency': commercial.property_account_receivable_id.currency_id 'open_balance_display': formatLang(request.env, open_balance, currency_obj=currency),
if commercial.property_account_receivable_id else request.env.company.currency_id, 'currency': currency,
'pager': pager, 'pager': pager,
'total': data['total'], 'total': data['total'],
}) })

View File

@@ -15,8 +15,7 @@
<div class="o_fp_badge o_fp_badge_paid" t-if="open_balance"> <div class="o_fp_badge o_fp_badge_paid" t-if="open_balance">
<span class="o_fp_badge_dot"/> <span class="o_fp_badge_dot"/>
Open Balance: Open Balance:
<span t-field="open_balance" <span t-out="open_balance_display"/>
t-options='{"widget": "monetary", "display_currency": currency}'/>
</div> </div>
<span class="o_fp_badge" t-else="" <span class="o_fp_badge" t-else=""
style="background:#f3f7f6;color:#374151"> style="background:#f3f7f6;color:#374151">