Skip to content

Commit

Permalink
[FIX] Fixed code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikul-OSI committed Feb 14, 2024
1 parent d4d0491 commit 696190f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 5 additions & 2 deletions product_configurator/models/product_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,14 @@ def update_session_configuration_value(self, vals, product_tmpl_id=None):
# Add attribute values from the client except custom attribute
# If a custom value is being written, but field name is not in
# the write dictionary, then it must be a custom value!

# TODO: NC: Check M2M
if vals.get(field_name, custom_val.id) != custom_val.id:
if attr_line.multi and isinstance(vals[field_name], list):
if not vals[field_name]:
field_val = None
else:
field_val = vals[field_name][0][2]
field_val = vals[field_name][0][1]
elif not attr_line.multi and isinstance(vals[field_name], int):
field_val = vals[field_name]
else:
Expand Down Expand Up @@ -1481,8 +1483,9 @@ def flatten_val_ids(self, value_ids):
(e.g: [1, 2, 3, [4, 5, 6]])
:returns: flattened list of ids ([1, 2, 3, 4, 5, 6])"""
flat_val_ids = set()
print("\n\n========value_ids====", value_ids)
if value_ids and value_ids[0]:
for val in value_ids[0]:
for val in value_ids:
if not val:
continue
if isinstance(val, list):
Expand Down
7 changes: 1 addition & 6 deletions product_configurator/wizard/product_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ def add_dynamic_fields(self, res, dynamic_fields, wiz):
"wizard_id": wiz.id,
"field_name": field_name,
"is_m2m": attr_line.multi,
"value_ids": attr_line.value_ids.ids,
}
),
options=str(
Expand Down Expand Up @@ -1137,11 +1136,7 @@ def cleanup(vals: Dict) -> Dict:
if not field_spec:
continue

if field_spec.get("context").get("value_ids"):
co_records = self.env["product.attribute.value"].browse(
field_spec.get("context").get("value_ids")
)

co_records = self.env["product.attribute.value"]
if "order" in field_spec and field_spec["order"]:
co_records = co_records.search(
[("id", "in", co_records.ids)], order=field_spec["order"]
Expand Down

0 comments on commit 696190f

Please sign in to comment.