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:
@@ -10,6 +10,7 @@ from datetime import datetime, time as dt_time
|
||||
from odoo import _, http
|
||||
from odoo.exceptions import AccessError, MissingError
|
||||
from odoo.http import request
|
||||
from odoo.tools import formatLang
|
||||
from odoo.addons.portal.controllers.portal import (
|
||||
CustomerPortal,
|
||||
pager as portal_pager,
|
||||
@@ -551,6 +552,11 @@ class FpCustomerPortal(CustomerPortal):
|
||||
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.update({
|
||||
'page_name': 'fp_account_summary',
|
||||
@@ -561,8 +567,8 @@ class FpCustomerPortal(CustomerPortal):
|
||||
'search': search,
|
||||
'sort': sort,
|
||||
'open_balance': open_balance,
|
||||
'currency': commercial.property_account_receivable_id.currency_id
|
||||
if commercial.property_account_receivable_id else request.env.company.currency_id,
|
||||
'open_balance_display': formatLang(request.env, open_balance, currency_obj=currency),
|
||||
'currency': currency,
|
||||
'pager': pager,
|
||||
'total': data['total'],
|
||||
})
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
<div class="o_fp_badge o_fp_badge_paid" t-if="open_balance">
|
||||
<span class="o_fp_badge_dot"/>
|
||||
Open Balance:
|
||||
<span t-field="open_balance"
|
||||
t-options='{"widget": "monetary", "display_currency": currency}'/>
|
||||
<span t-out="open_balance_display"/>
|
||||
</div>
|
||||
<span class="o_fp_badge" t-else=""
|
||||
style="background:#f3f7f6;color:#374151">
|
||||
|
||||
Reference in New Issue
Block a user