Skip to content

Commit c58b1d7

Browse files
committed
wip
1 parent fc26b01 commit c58b1d7

6 files changed

Lines changed: 16 additions & 12 deletions

File tree

product_creation_dynamic_wizard/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
{
66
"name": "Product creation dynamic wizard",
7-
"version": "14.0.0.1.2",
7+
"version": "17.0.1.0.0",
88
"license": "AGPL-3",
99
"author": "Pierre Verkest <pierre@verkest.fr>, Odoo Community Association (OCA)",
1010
"website": "https://github.com/OCA/odoo-pim",

product_creation_dynamic_wizard/models/product_creation_question.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ProductCreationQuestion(models.Model):
3636
translate=True, tracking=True, help="The question displayed to the end user"
3737
)
3838
complete_name = fields.Char(
39-
"Complete Name", compute="_compute_complete_name", store=True, recursive=True
39+
compute="_compute_complete_name", store=True, recursive=True
4040
)
4141
parent_id = fields.Many2one(
4242
"product.creation.question",

product_creation_dynamic_wizard/tests/fake_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33

44
class FakeProduct(models.Model):
5-
_inherit = "product.product"
5+
_inherit = "product.product" # pylint: disable=consider-merging-classes-inherited
66

77
product_attribute = fields.Char()

product_creation_dynamic_wizard/views/product_creation_question.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<field name="name">product.creation.question.tree</field>
55
<field name="model">product.creation.question</field>
66
<field name="arch" type="xml">
7-
<tree string="Product creation question">
7+
<tree>
88
<field name="sequence" widget="handle" />
99
<field name="parent_id" optional="show" />
1010
<field name="name" optional="show" />

product_creation_dynamic_wizard/wizards/product_creation_dynamic_wizard.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# @author Pierre Verkest <pierre@verkest.fr>
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44
import json
5-
from typing import Optional
5+
import logging
66
from uuid import uuid4
77

88
from lxml import etree
@@ -11,6 +11,8 @@
1111

1212
from odoo.addons.base_sparse_field.models.fields import Serialized
1313

14+
logger = logging.getLogger(__name__)
15+
1416

1517
class 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

product_creation_dynamic_wizard/wizards/product_creation_dynamic_wizard.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
string="Previous"
2424
type="object"
2525
name="action_open_previous"
26-
attrs="{'invisible': [('current_step', '=', 0)]}"
26+
invisible="current_step == 0"
2727
/>
2828
<button
2929
string="Next"

0 commit comments

Comments
 (0)