first push message

This commit is contained in:
2026-07-01 14:41:49 +07:00
parent 6667dec2bf
commit 58b5f46cc4
2951 changed files with 316619 additions and 0 deletions
@@ -0,0 +1 @@
from . import main
+41
View File
@@ -0,0 +1,41 @@
# Copyright 2025 Tecnativa - Pilar Vargas
# Copyright 2025 Upgraded to Odoo 19.0
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.addons.survey.controllers.main import Survey
class SurveyMultiCompany(Survey):
"""Override survey controller to enforce correct company context.
In multi-company environments, a public/portal user accessing a survey
URL has no explicit active company in their session. Odoo therefore
defaults to the user's *first* allowed company, which may differ from
the company that owns the survey. This can cause:
* Wrong ir.rule evaluation → AccessError or empty recordsets
* Company-specific fields (currency, fiscal position, …) resolved
against the wrong company
* Sequence/numbering pulled from the wrong company
The fix is straightforward: after the parent resolves the survey and
answer sudo records, we call .with_company() on both of them so that
the rest of the survey flow runs in the correct company context.
Compatible with Odoo 19.0 Community where _get_access_data() still
receives (survey_token, answer_token, ensure_token=True) and returns a
dict with at minimum the keys 'survey_sudo' and 'answer_sudo'.
"""
def _get_access_data(self, survey_token, answer_token, ensure_token=True):
data = super()._get_access_data(
survey_token, answer_token, ensure_token=ensure_token
)
survey_sudo = data.get("survey_sudo")
if survey_sudo and survey_sudo.company_id:
target_company = survey_sudo.company_id
data["survey_sudo"] = survey_sudo.with_company(target_company)
answer_sudo = data.get("answer_sudo")
if answer_sudo:
data["answer_sudo"] = answer_sudo.with_company(target_company)
return data