22# @author Pierre Verkest <pierre@verkest.fr>
33# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44import json
5- from typing import Optional
5+ import logging
66from uuid import uuid4
77
88from lxml import etree
1111
1212from odoo .addons .base_sparse_field .models .fields import Serialized
1313
14+ logger = logging .getLogger (__name__ )
15+
1416
1517class WizardStep :
1618 record_id : int
@@ -20,15 +22,15 @@ class WizardStep:
2022 parent_index : int = - 1
2123 """parent position in the current question tree"""
2224
23- answer_id : Optional [ int ] = None
25+ answer_id : int | None = None
2426 """in case of custom question this will save the user
2527 answer"""
2628
2729 def __init__ (
2830 self ,
2931 record_id : int ,
3032 parent_index : int ,
31- answer_id : Optional [ int ] = None ,
33+ answer_id : int | None = None ,
3234 odoo_env = None ,
3335 ):
3436 self .record_id = record_id
@@ -129,8 +131,8 @@ def _populate_wizard_steps(self, wizard: Wizard, question, parent_index=-1):
129131 odoo_env = self .env ,
130132 )
131133 )
132- for question in question .child_ids :
133- self ._populate_wizard_steps (wizard , question , parent_index = index )
134+ for child_question in question .child_ids :
135+ self ._populate_wizard_steps (wizard , child_question , parent_index = index )
134136
135137 def _default_wizard_steps (self ):
136138 wizard = Wizard ()
@@ -189,7 +191,8 @@ def _apply_step_custom(self, current_step, node, result):
189191 name = "answer_id" ,
190192 attrib = {
191193 "domain" : f'[("question_id", "=", { current_step .record_id } )]' ,
192- "options" : "{'no_create': True, 'no_create_edit': True, 'no_open': True}" ,
194+ "options" : "{'no_create': True, 'no_create_edit': True, "
195+ "'no_open': True}" ,
193196 "nolabel" : "1" ,
194197 "required" : "1" if current_step .answer_required else "0" ,
195198 },
@@ -340,7 +343,8 @@ def _prepare_product_data(self):
340343 try :
341344 # useful for m2m with value such as [(0,0,{...})]
342345 field_value = json .loads (field_value )
343- except Exception :
346+ except Exception as exc :
347+ logger .warning (exception = exc )
344348 pass
345349 return {self .step .field_id .name : field_value }
346350
0 commit comments