[FIX] project_average_acceptable_time: use Odoo 18 optional fields API

Odoo 18 replaced the ``OPTIONAL_BILLING_FIELDS`` class attribute with the
``_get_optional_fields()`` method. The portal controller still appended to
the removed attribute, raising ``AttributeError`` on every request to
``/my/account`` and making the page unavailable to all portal users.

Override ``_get_optional_fields()`` instead, as ``elabore_subscription_price``
already does, and add HTTP tests covering the page load and the default
project update on form submission.
This commit is contained in:
Stéphan Sainléger
2026-11-09 00:21:02 +01:00
parent b6c7055091
commit 82971af4d4
4 changed files with 61 additions and 5 deletions

View File

@@ -6,12 +6,13 @@ from odoo.addons.portal.controllers.portal import CustomerPortal
class CustomCustomerPortal(CustomerPortal):
def _get_optional_fields(self):
return super()._get_optional_fields() + [
"average_acceptable_time"
] # unnecessary save in res partner, but necessary to avoid error on form post
@route(["/my/account"], type="http", auth="user", website=True)
def account(self, redirect=None, **post):
self.OPTIONAL_BILLING_FIELDS.append(
"average_acceptable_time"
) # unecessary save in res partner, but necessary to avoid error on form post
response = super().account(redirect, **post)
if post and request.httprequest.method == "POST":