From abf03aa5b9d1e258a128888983d9f844c04b6a75 Mon Sep 17 00:00:00 2001 From: Suherdy Yacob Date: Fri, 23 Jan 2026 16:57:34 +0700 Subject: [PATCH] fix bugs ion odoo 19 --- static/src/js/SurveyFormWidget.js | 31 ++++++++++++++++++------- static/src/js/survey_form_attachment.js | 1 - 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/static/src/js/SurveyFormWidget.js b/static/src/js/SurveyFormWidget.js index e4c8e7d..1d5b589 100755 --- a/static/src/js/SurveyFormWidget.js +++ b/static/src/js/SurveyFormWidget.js @@ -1,13 +1,26 @@ /** @odoo-module */ -import SurveyFormWidget from '@survey/js/survey_form'; -SurveyFormWidget.include({ - /** Get all question answers by question type */ - _prepareSubmitValues(formData, params) { - this._super(...arguments); - this.$('[data-question-type]').each(function () { - if ($(this).data('questionType') === 'upload_file'){ - params[this.name] = [$(this).data('oe-data'), $(this).data('oe-file_name')]; - } +import { SurveyForm } from "@survey/interactions/survey_form"; +import { patch } from "@web/core/utils/patch"; + +patch(SurveyForm.prototype, { + /** + * @override + */ + prepareSubmitValues(formData, params) { + super.prepareSubmitValues(formData, params); + + // Handle upload_file question type + this.el.querySelectorAll('[data-question-type="upload_file"]').forEach((el) => { + const oeData = el.getAttribute('data-oe-data'); + const oeFileName = el.getAttribute('data-oe-file_name'); + if (oeData && oeFileName) { + try { + params[el.name] = [JSON.parse(oeData), JSON.parse(oeFileName)]; + } catch (e) { + // Fallback if not valid JSON + params[el.name] = [oeData, oeFileName]; + } + } }); }, }); diff --git a/static/src/js/survey_form_attachment.js b/static/src/js/survey_form_attachment.js index 5e62de7..b0ed6bf 100755 --- a/static/src/js/survey_form_attachment.js +++ b/static/src/js/survey_form_attachment.js @@ -1,6 +1,5 @@ /** @odoo-module */ import publicWidget from "@web/legacy/js/public/public_widget"; -import SurveyFormWidget from '@survey/js/survey_form'; import SurveyPreloadImageMixin from "@survey/js/survey_preload_image_mixin"; /** Extends publicWidget to create "SurveyFormUpload" */ publicWidget.registry.SurveyFormUpload = publicWidget.Widget.extend(SurveyPreloadImageMixin, {