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

Steersman’s Dynamic BoM customization uses condition statements to determine when a component or rule should apply to a configured product.
This guide explains how to write clear and 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.
Truemeans the component or rule applies.Falsemeans the component or rule does not apply.
For example:
finish_code == 'premium'
This condition returns True when the 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.
Understanding the Parts of a Condition
A condition normally compares a variable from the product configuration to a value.
finish_code == 'premium'
In this example:
finish_codeis the variable.==means “is equal to.”'premium'is the value being checked.
The variables available to a condition are determined by the attributes you have configured on the Product. The condition does not create or define the variables. You can find the list of available variables and values in the “Variables” tab of the Dynamic BoM.
Variable Names Are Case-Sensitive
Variable names in the condition statement must match exactly how they are written in the “Variables” tab.
For example, these are treated as three different variable names:
beam_length
Beam_Length
BEAM_LENGTH
Copy the variable name exactly as it appears in Odoo.
Place Text/String Values in Quotes
Text/String values must be placed inside single quotes.
Correct
color_code == 'blue'
Incorrect
color_code == blue
Numeric values should not be placed in quotes unless the value is stored as text/String.
panel_count == 4
Put the Variable First
For readability, place the variable first and the value second.
Recommended
wiring == 'hardwire'
Harder to read
'hardwire' == wiring
Both expressions may work, but the variable-first format is easier for another person to read and verify.
Comparison Operators
The following operators can be used to compare values:
| 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 |
- Use == when comparing values. Do not use a single equals sign.
Correct
color_code == 'blue'
Incorrect
color_code = 'blue'
Combining Multiple Requirements
Boolean operators allow a condition to include multiple requirements.
The most commonly used Boolean operators are:
andornot
Use and When Every Requirement Must Be True
Use and when all parts of the condition must be true.
finish_code == 'premium' and panel_count >= 4
This condition applies only when:
- The finish is
premium. - The panel count is at least four.
Both requirements must be true.
Use or When Either Requirement May Be True
Use or when at least one part of the condition must be true.
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 condition should apply when a Boolean value is false.
not is_outdoor
This condition returns True when is_outdoor is false.
Use in for Several Accepted Values
When one variable can match several acceptable values, use in.
color_code in ('red', 'blue', 'green')
This is easier to read than repeating the same variable:
color_code == 'red' or color_code == 'blue' or color_code == 'green'
Place a comma between each accepted value.
Use not in to Exclude Several Values
Use not in when a variable must not match any of the listed values.
finish_code not in ('archived', 'unavailable')
This condition applies when the finish is neither archived nor unavailable.
Checking Numeric Ranges
Use a chained comparison when a numeric value must fall within a range.
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
Grouping and and or Logic
When a condition contains both and and or, always use parentheses to show how the condition should be evaluated.
This is one of the most important rules for formatting Dynamic BoM conditions.
Without parentheses, the condition may apply to configurations that were not intended.
Example: One Requirement and Several Accepted Finishes
Hard to read and potentially incorrect
wiring == 'hardwire' and hardware_finish == 'satin_brass' or hardware_finish == 'patina_brass'
This expression may allow patina_brass regardless of the selected wiring because the or portion is not grouped with the hardwire requirement.
Recommended
wiring == 'hardwire' and hardware_finish in ('satin_brass', 'patina_brass')
This condition clearly requires:
- The wiring to be
hardwire. - The hardware finish to be either
satin_brassorpatina_brass.
Example: Two Sizes and One Required Finish
Correct grouping
(size == 'duo' or size == 'trio') and hardware_finish == 'black'
This condition means:
- The size must be
duoortrio. - The hardware finish must be
black.
Clearer version using in
size in ('duo', 'trio') and hardware_finish == 'black'
Example: Either of Two Complete Cases
Sometimes a component should apply for either of two complete configurations.
(finish_code == 'premium' and color_code == 'blue') or (finish_code == 'standard' and color_code == 'green')
This condition applies when either of the following is true:
- The finish is
premiumand the color isblue. - The finish is
standardand the color isgreen.
Each complete case is placed inside its own parentheses.
How to Determine the Correct Grouping
Write the business rule as a sentence before writing the condition.
For example:
- Apply the component when the size is duo or trio, and the hardware finish is black.
The first complete idea is:
The size is duo or trio.
The second complete idea is:
The hardware finish is black.
The formatted condition is:
(size == 'duo' or size == 'trio') and hardware_finish == 'black'
The clearer version is:
size in ('duo', 'trio') and hardware_finish == 'black'
Place parentheses around each phrase that must be evaluated as one complete idea.
Common Condition Patterns
The following patterns can be copied and adapted.
Replace the example variables and values with those configured for the product.
Always apply
True
Never apply
False
Apply for one selected option
variable == 'value'
Example:
color_code == 'blue'
Apply for any listed option
variable in ('value_1', 'value_2')
Example:
size in ('duo', 'trio')
Exclude listed options
variable not in ('value_1', 'value_2')
Example:
finish_code not in ('archived', 'unavailable')
Require all conditions
condition_a and condition_b
Example:
wiring == 'hardwire' and is_outdoor
Allow either condition
condition_a or condition_b
Example:
color_code == 'red' or color_code == 'blue'
Apply within a numeric range
minimum <= numeric_variable <= maximum
Example:
24 <= beam_length <= 48
Require an option and a numeric range
option_condition and range_condition
Example:
finish_code == 'premium' and 24 <= beam_length <= 48
Allow either of two complete cases
(case_a) or (case_b)
Example:
(size == 'duo' and color_code == 'black') or (size == 'trio' and color_code == 'white')
Boolean Values
Boolean values must begin with a capital letter:
True
False
Check whether a Boolean variable is true
is_outdoor
This can also be written as:
is_outdoor == True
The shorter version is normally easier to read.
Check whether a Boolean variable is false
not is_outdoor
This can also be written as:
is_outdoor == False
Common Formatting Mistakes
Using one equals sign
Incorrect:
color_code = 'blue'
Correct:
color_code == 'blue'
Leaving text unquoted
Incorrect:
color_code == blue
Correct:
color_code == 'blue'
Using a lowercase Boolean
Incorrect:
is_outdoor == true
Correct:
is_outdoor == True
Or:
is_outdoor
Mixing and and or without grouping
Unclear:
size == 'duo' or size == 'trio' and color_code == 'black'
Correct:
(size == 'duo' or size == 'trio') and color_code == 'black'
Clearer:
size in ('duo', 'trio') and color_code == 'black'
Repeating the same variable
Harder to read:
color_code == 'red' or color_code == 'blue' or color_code == 'green'
Recommended:
color_code in ('red', 'blue', 'green')
Worked Example
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.
Formatted condition
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 the condition works
The first requirement is:
wiring == 'hardwire'
The and operator means that the wiring requirement must be true.
Inside the parentheses are two acceptable finish groups:
hardware_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter')
Or:
shade_finish in ('satin_brass', 'patina_brass', 'blackened_brass', 'pewter')
The parentheses keep the two finish groups together. An approved finish cannot bypass the hardwire requirement.
Before saving a condition, confirm that:
- The condition is written on one line.
- The condition returns
TrueorFalse. - Variable names match the Odoo configuration exactly.
- Text values are placed inside quotes.
- The comparison operator is
==, not=. True,False, andNonebegin with capital letters.- Several acceptable values for one variable use
inwhere practical. - Conditions containing both
andandoruse explicit parentheses. - Each grouped case matches the intended business rule.
- The condition has been tested with matching and nonmatching configurations.
- Another person can read the condition and explain what it does.
Related posts

Importing bulk data into Odoo using S3 fast load setup
This guide will walk you through creating importable files and getting them picked up for load into your Odoo database hosted by Steersman.

How to Set Up GA4 Events in Google Tag Manager
Tracking user behavior and ecommerce interactions accurately is essential for making data-driven decisions. If your website already sends event data to the data layer, the next step is configuring Google Tag Manager (GTM) to forward that data into Google Analytics 4 (GA4). This guide walks you through setting up ecommerce, custom, search, and login events in GTM.

Steersman Odoo website chat event tracking
Steersman Odoo chat emits browser events for integration with tracking and analytics services.

How do Odoo E-Commerce Sites from Steersman Rank?
Odoo e-commerce sites from Steersman will get you the best performance, structure, and SEO in the world. See the ratings for yourself.