How to Use Dynamic Formula Expressions in Steersman's Dynamic BoMs

Dynamic formula expressions

Our Dynamic BoM customization uses condition statements to determine when a component or rule should apply to your configured product.

By writing clear conditions, you can control which components are included based on your product’s selected attributes, measurements, finishes, configuration options, and other available variables.

This guide explains how to write reliable Dynamic BoM conditions, including how to compare configuration values, combine multiple requirements, group and and or logic, and avoid common formatting mistakes.

What Is a Dynamic BoM Condition?

A Dynamic BoM condition is a single-line expression that returns either True or False.

  • True means the component or rule applies.
  • False means the component or rule does not apply.

For example:

finish_code == 'premium'

This condition returns True when your configured finish is premium.

Dynamic BoM condition fields are intended for single-line expressions. They should not contain full Python scripts, loops, imports, or function definitions.

Understand the Parts of a Condition

A condition normally compares a variable from your product configuration to a value.

For example:

finish_code == 'premium'

In this example:

  • finish_code is the variable.
  • == means “is equal to.”
  • 'premium' is the value being checked.

The variables available to your condition are determined by the attributes configured on the product. The condition itself does not create or define those variables.

You can review the variables and available values from the Variables tab of the Dynamic BoM.

Variable Names Are Case-Sensitive

Variable names must match exactly how they appear in the Variables tab.

For example, Odoo treats each of these as a separate variable name:

beam_length

Beam_Length

BEAM_LENGTH

When creating your condition, copy the variable name exactly as it appears in Odoo.

Place Text Values in Quotes

When comparing text or string values, place the value inside single quotes.

Correct

color_code == 'blue'

Incorrect

color_code == blue

Numeric values generally should not be placed in quotes unless the value itself is stored as text.

For example:

panel_count == 4

Put the Variable First

For readability, we recommend placing the variable first and the value second.

wiring == 'hardwire'

Harder to Read

'hardwire' == wiring

Both expressions may work, but placing the variable first makes the condition easier for your team or our support team to read and verify later.

Use the Correct Comparison Operator

You can use several comparison operators in your Dynamic BoM conditions:

Operator Meaning Example
== Equal to finish_code == 'premium'
!= Not equal to color_code != 'red'
> Greater than beam_length > 48
>= Greater than or equal to panel_count >= 4
< Less than beam_length < 96
<= Less than or equal to thickness <= 3.0

When comparing values, use ==.

Do not use a single equals sign.

Correct

color_code == 'blue'

Incorrect

color_code = 'blue'

Combine Multiple Requirements

You can use Boolean operators when your condition needs to evaluate more than one requirement.

The most commonly used operators are:

  • and
  • or
  • not

Use and When Every Requirement Must Be True

Use and when all parts of your condition need to be true.

For example:

finish_code == 'premium' and panel_count >= 4

This condition applies only when:

  1. The finish is premium.
  2. The panel count is at least four.

Both requirements must be true.

Use or When Either Requirement Can Be True

Use or when at least one of your requirements can be true.

For example:

color_code == 'red' or color_code == 'blue'

This condition applies when the selected color is either red or blue.

Use not to Reverse a Condition

Use not when a rule should apply when a Boolean value is false.

For example:

not is_outdoor

This condition returns True when is_outdoor is false.

Use in When Several Values Are Accepted

When the same variable can match several acceptable values, you can use in instead of repeating the variable several times.

For example:

color_code in ('red', 'blue', 'green')

This is easier to read than:

color_code == 'red' or color_code == 'blue' or color_code == 'green'

Place a comma between each accepted value.

Using in can make longer Dynamic BoM conditions much easier to review and maintain.

Use not in to Exclude Several Values

Use not in when the variable must not match any of the listed values.

For example:

finish_code not in ('archived', 'unavailable')

This condition applies when the finish is neither archived nor unavailable.

Check Numeric Ranges

When a numeric value needs to fall within a specific range, you can use a chained comparison.

For example:

24 <= beam_length <= 48

This condition returns True when beam_length is at least 24 and no more than 48.

Another example:

1.5 <= thickness <= 3.0

This is generally easier to understand than writing the minimum and maximum checks separately.

Group and and or Logic Carefully

When your condition contains both and and or, always use parentheses to clearly show how you want the condition evaluated.

This is one of the most important rules when writing Dynamic BoM conditions.

Without clear grouping, a condition may apply to product configurations you did not intend.

Example: One Requirement and Several Accepted Finishes

Consider this condition:

wiring == 'hardwire' and hardware_finish == 'satin_brass' or hardware_finish == 'patina_brass'

This is difficult to read and may not behave the way you expect.

The patina_brass portion may evaluate separately from the hardwire requirement because the or logic has not been grouped clearly.

A clearer version is:

wiring == 'hardwire' and hardware_finish in ('satin_brass', 'patina_brass')

This makes your intended rule clear:

  1. Wiring must be hardwire.
  2. Hardware finish must be either satin_brass or patina_brass.

Example: Two Sizes and One Required Finish

Suppose the component should apply when the size is either duo or trio, but the hardware finish must always be black.

You could write:

(size == 'duo' or size == 'trio') and hardware_finish == 'black'

This means:

  • The size must be duo or trio.
  • The hardware finish must be black.

An even clearer version uses in:

size in ('duo', 'trio') and hardware_finish == 'black'

Example: Either of Two Complete Configurations

Sometimes a component should apply when either of two complete configurations is selected.

For example:

(finish_code == 'premium' and color_code == 'blue') or (finish_code == 'standard' and color_code == 'green')

This condition applies when either:

  1. The finish is premium and the color is blue.

or:

  1. The finish is standard and the color is green.

Each complete configuration is placed inside its own parentheses.

This makes it clear that each pair of requirements should be evaluated together.

Determine the Correct Grouping Before Writing the Condition

One of the easiest ways to build complicated Dynamic BoM logic is to write the business rule as a sentence first.

For example:

Apply the component when the size is duo or trio, and the hardware finish is black.

Break that sentence into complete ideas.

The first idea is:

The size is duo or trio.

The second is:

The hardware finish is black.

You can then translate those requirements into:

(size == 'duo' or size == 'trio') and hardware_finish == 'black'

Or, using in:

size in ('duo', 'trio') and hardware_finish == 'black'

Thinking through the business rule first can help you avoid accidentally creating logic that produces the right result for some configurations but the wrong result for others.

Common Dynamic BoM Condition Patterns

The following patterns can be copied and adapted to your own Dynamic BoM conditions.

Replace the example variables and values with those configured for your product.

Always Apply

True

Use this when the component should always apply.

Never Apply

False

Use this when the component should never apply.

Apply for One Selected Option

Pattern:

variable == 'value'

Example:

color_code == 'blue'

Apply for Any Listed Option

Pattern:

variable in ('value_1', 'value_2')

Example:

size in ('duo', 'trio')

Exclude Listed Options

Pattern:

variable not in ('value_1', 'value_2')

Example:

finish_code not in ('archived', 'unavailable')

Require All Conditions

Pattern:

condition_a and condition_b

Example:

wiring == 'hardwire' and is_outdoor

Allow Either Condition

Pattern:

condition_a or condition_b

Example:

color_code == 'red' or color_code == 'blue'

Apply Within a Numeric Range

Pattern:

minimum <= numeric_variable <= maximum

Example:

24 <= beam_length <= 48

Require an Option and a Numeric Range

Pattern:

option_condition and range_condition

Example:

finish_code == 'premium' and 24 <= beam_length <= 48

Allow Either of Two Complete Cases

Pattern:

(case_a) or (case_b)

Example:

(size == 'duo' and color_code == 'black') or (size == 'trio' and color_code == 'white')

Work with Boolean Values

Boolean values begin with a capital letter:

True

False

Check Whether a Boolean Variable Is True

You can write:

is_outdoor

You can also write:

is_outdoor == True

The shorter version is normally easier to read.

Check Whether a Boolean Variable Is False

You can write:

not is_outdoor

You can also write:

is_outdoor == False

Avoid Common Formatting Mistakes

Small formatting errors can cause a Dynamic BoM condition to behave incorrectly or fail to evaluate.

Using One Equals Sign

Incorrect:

color_code = 'blue'

Correct:

color_code == 'blue'

Use == when comparing two values.

Leaving Text Values Unquoted

Incorrect:

color_code == blue

Correct:

color_code == 'blue'

Text values should be placed inside quotes.

Using a Lowercase Boolean

Incorrect:

is_outdoor == true

Correct:

is_outdoor == True

Or, more simply:

is_outdoor

Python Boolean values use capitalized True and False.

Mixing and and or Without Clear Grouping

Unclear:

size == 'duo' or size == 'trio' and color_code == 'black'

If your intention is for the color requirement to apply to both sizes, write:

(size == 'duo' or size == 'trio') and color_code == 'black'

An even clearer version is:

size in ('duo', 'trio') and color_code == 'black'

This makes it clear that black is required whether the selected size is duo or trio.

Repeating the Same Variable Unnecessarily

Harder to read:

color_code == 'red' or color_code == 'blue' or color_code == 'green'

Recommended:

color_code in ('red', 'blue', 'green')

Both expressions describe the same accepted values, but the second is shorter and easier to maintain.

Worked Example

Consider the following business rule:

Apply the component when wiring is hardwire and either the hardware finish or shade finish is one of the approved brass or metal finishes.

A clearly formatted condition would be:

wiring == 'hardwire' and (hardware_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter') or shade_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter'))

How This Condition Works

The first requirement is:

wiring == 'hardwire'

The and operator means this wiring requirement must be true before the entire condition can be true.

Inside the parentheses are two acceptable finish groups.

The hardware finish may be:

hardware_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter')

Or the shade finish may be:

shade_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter')

The parentheses keep these two finish options together.

This means an approved hardware or shade finish cannot bypass the hardwire requirement.

Without the parentheses, the condition could potentially apply to configurations that have an approved finish but do not use hardwire wiring.

Review Your Condition Before Saving

Before saving a Dynamic BoM condition, confirm that:

  • The condition is written on one line.
  • The condition returns True or False.
  • Your variable names match the Odoo configuration exactly.
  • Text values are placed inside quotes.
  • You use == for comparison rather than =.
  • True, False, and None begin with capital letters.
  • Several acceptable values for the same variable use in where practical.
  • Conditions containing both and and or use explicit grouping.
  • Each grouped case matches your intended business rule.
  • You have tested the condition with configurations that should match and configurations that should not match.
  • Another person can read the condition and explain what it does.

Build Dynamic BoM Logic That Is Easier to Maintain

Our Dynamic BoM customization gives you the flexibility to determine exactly when components and rules should apply to your configured products.

The most reliable conditions are not necessarily the shortest ones—they are the ones that clearly represent your business requirements and are easy for someone else to understand later.

By using consistent variable names, quoting values correctly, simplifying repeated comparisons with in, and clearly grouping and and or logic, you can build Dynamic BoM conditions that are easier for your team to configure, test, troubleshoot, and maintain.