pledra/odoo-product-configurator

[12.0] product_configurator: field should not be readonly

matt454357 opened this issue · 2 comments

Impacted versions: 12.0

Steps to reproduce:

  • create config template:
  • create attributes
    • attr-1 (not required)
      • value-1.1
      • value-1.2
    • attr-2 (not required)
      • value-2.1
      • value-2.2
    • attr-3 (not required)
      • value-3.1
      • value-3.2
  • create restrictions
    • attr-3, value-3.1, attr-1 not in value-1.1
    • attr-3, value-3.2, attr-2 not in value-2.1
  • Configure Product

Current behavior:
The attr-3 field is readonly. Although none of the fields are required, the user must specify a value for both attr-1 and attr-2, in order to select a value for attr-3.

Expected behavior:
The attr-3 field should never be readonly, unless the user has specified attr-1=value-1.1 and attr-2=value-2.1.

Screenshots
Annotation 2020-09-14 172804

Annotation 2020-09-14 172826

The problem is, we require a value to be selected for the dependee, here:

elif domain_line.condition == 'not in':
val_ids = attr_lines.filtered(
lambda l: l.attribute_id.id == attr_id).value_ids
val_ids = val_ids - domain_line.value_ids
attr_depends[attr_field] |= set(val_ids.ids)

This addition seems to fix it:

elif domain_line.condition == 'not in':
	val_ids = attr_lines.filtered(
		lambda l: l.attribute_id.id == attr_id).value_ids
	val_ids = val_ids - domain_line.value_ids
	attr_depends[attr_field] |= set(val_ids.ids)
	# this fixes the readonly problem
	if not attr_lines.filtered(
	        lambda l: l.attribute_id.id == attr_id).required:
	    attr_depends[attr_field] |= {False}

My solution exposes another issue:
Configure a product, and specify attr-1=value-1.1.
The attr-3 field changes to not required.
The attr-3 field should be required unless the user has specified attr-1=value-1.1 and attr-2=value-2.1.