Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

[ENH] - Default Values based on domains. #87

Open
wants to merge 9 commits into
base: 10.0
Choose a base branch
from

Conversation

richard-willdooit
Copy link
Contributor

No description provided.

@richard-willdooit
Copy link
Contributor Author

@PCatinean This (and my other PR's) have been rebased...

@codecov-io
Copy link

codecov-io commented May 11, 2017

Codecov Report

Merging #87 into 10.0 will increase coverage by 4.02%.
The diff coverage is 68.35%.

Impacted file tree graph

@@            Coverage Diff             @@
##             10.0      #87      +/-   ##
==========================================
+ Coverage   61.11%   65.13%   +4.02%     
==========================================
  Files          14       14              
  Lines        1368     1440      +72     
==========================================
+ Hits          836      938     +102     
+ Misses        532      502      -30
Impacted Files Coverage Δ
...configurator_wizard/wizard/product_configurator.py 46.46% <59.18%> (+13.21%) ⬆️
product_configurator/models/product_config.py 76.69% <81.25%> (+0.38%) ⬆️
product_configurator/models/product.py 74.35% <85.71%> (+0.54%) ⬆️
product_configurator_mrp/models/product.py 92.3% <0%> (+53.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89750da...b59d86e. Read the comment docs.

@PCatinean
Copy link
Contributor

Can you provide a description about this feature?

@richard-willdooit
Copy link
Contributor Author

@PCatinean

When an onchange has completed, or when the template is first parsed, any values which are blank will be examined to see if they can be populated with a default. The default can be domain based.

Eg
Default size is small.
Default colour is blue, if model is standard. Default colour is silver, if model is premium.

continue
available_val_ids = domains[k][0][2]
if isinstance(v, list):
value_ids = list(set(v[0][2]) & set(available_val_ids))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value_ids could be reduced to nothing, in which case you'd want the default value.

lambda x: x.id == cfg_step_id)
except:
cfg_step = self.env['product.config.step.line']
vals = wiz.get_form_vals(dynamic_field_vals, domains, cfg_step)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you create a condition-free default, it will be set here but changes will not cascade.

# pick one at random...
return (
set(default_line.value_ids.ids) & set(selectable_value_ids)
).pop()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work for multi, the client expects a list. For instance, adding options:armrest will cause a js error in AbstractManyField.set_value()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants