Auto-assign CRM teams to partners based on ZIP code patterns using regular expressions.
Features
- Auto-assign CRM teams to partners based on ZIP code patterns
- Support for Python regular expressions with validation constraints
- Multi-company support
- Geographic filtering by countries and states
- Priority-based assignment when multiple teams match
- Exclusion flag for partners who should not be auto-assigned
- Real-time regex pattern validation prevents invalid patterns
- Contextual action for manual assignment from partner views
- Conditional assignment using pre-zip match conditions: teams can specify a domain expression (Odoo domain syntax) that must be satisfied by the partner before ZIP regex matching is performed. This allows for advanced filtering, e.g., only assign if the partner is a company or meets other criteria.
Assignment Logic
The assignment is triggered on partner create/write when ZIP, company, country, state, or exclusion flag changes. A contextual action is also available from partner views for manual assignment. The system:
- Finds all active teams with ZIP assignment enabled in the partner's company
- Filters teams by matching countries and states (if specified)
- For each eligible team, evaluates the optional pre-zip match condition (Odoo domain expression). If the partner does not satisfy the condition, the team is skipped.
- Tests each remaining team's regex patterns against the partner's ZIP code
- Selects the team with highest priority if multiple matches exist
- Logs assignment activity for audit purposes
Assignment Rules
- Only active teams with "Active ZIP Assignment" enabled are considered
- Only teams in the same company as the partner are considered
- Teams must have matching countries (partner's country must be in team's countries)
- Teams must have matching states (partner's state must be in team's states, if team has states defined)
- If a team has a pre-zip match condition, the partner must satisfy the condition (Odoo domain) before ZIP regex matching is performed. If not set, all partners are considered.
- Partners without a company, ZIP code, country, or state are not assigned
- Partners with "Exclude from ZIP Assignment" checked are not assigned
- When multiple teams match, the team with highest priority is selected
- Invalid regex patterns are prevented by validation constraints at input time
auto_awesome What this module does
AI-generated from the code · Odoo 16.0Automatically assigns CRM sales teams to contacts based on their ZIP code, country and state. Teams are configured with ZIP patterns, priority and optional extra conditions, and partners can be excluded from the automatic assignment.
This module lets you route contacts to the right CRM team automatically using their ZIP code. On each CRM team you can tick 'Enable Auto ZIP Assignment' and then define the countries and states the team covers, one or more ZIP patterns (regular expressions such as '^1[0-5].*'), an assignment priority and an optional extra condition on the contact.
- When a contact is created or when its ZIP, company or exclusion flag is changed, Odoo looks for teams that are enabled, cover the contact's country and state and belong to the same company. Teams whose extra condition is not met are skipped, and the contact's ZIP must match one of the team's patterns.
- If several teams match, the one with the highest priority wins (higher number = higher priority); ties are broken by team order.
- A contact is only processed if it has a ZIP, a company, a country, a state and is of type 'contact'. Contacts flagged 'Exclude from ZIP Assignment' are never auto-assigned.
- A manual action 'Assign CRM Team By Zip' is available on contacts in form and list views to run the assignment on demand.
Configuration appears on the CRM team form under 'ZIP Auto Assignment Settings' and a 'ZIP Patterns' tab, and on the contact form next to the tags. Patterns are validated as real regular expressions and cannot be duplicated for the same team. A company is required when auto assignment is enabled.
Depends on
Models and fields (3)
- crm.team · extends an existing modelstate_ids (States), country_ids (Countries), zip_regex_ids (ZIP Regex), pre_zip_match_condition (Pre-Zip Match Condition), zip_assignment_priority (Assignment Priority), enable_zip_auto_assignment (Enable Auto ZIP Assignment)
- res.partner · extends an existing modelexclude_from_zip_assign (Exclude from ZIP Assignment)
- crm.team.zip.pattern · new modelname, pattern (ZIP Pattern), team_id (CRM Team)
Text generated by AI (DeepSeek) from reading the Odoo 16.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub
Availability by version
Reviewed: 2026-11-03Confirmation status: 1 confirmed, 8 with no information of 9 versions.
Sources · Odoo 16.0
Confirmed on 2026-11-03 in branch 16.0 of OCA/crm.
terminal Installation and usage
OCA documentation · Odoo 16.0Usage
Source · Odoo 16.0Setting up CRM Teams
- Go to CRM → Configuration → Sales Teams
- Edit or create a CRM team
- Enable "Active ZIP Assignment" checkbox
- Set "ZIP Assignment Priority" (higher number = higher priority)
- Configure geographic coverage:
- Select "Countries" where this team operates (required)
- Select "States" within those countries (required)
- Add ZIP patterns in the "ZIP Patterns" tab
- (Optional) Set a "Pre-Zip Match Condition" using Odoo domain syntax to restrict assignment to partners matching specific criteria (e.g., only companies, only certain types, etc.)
Geographic Coverage
- **Countries**: Teams will only be considered for partners located in the selected countries
- **States**: Teams will only be considered for partners in the selected states
- **Domain Filtering**: State selection is automatically filtered based on selected countries
Pre-Zip Match ConditionYou can further restrict team assignment by specifying a domain condition in the "Pre-Zip Match Condition" field. This uses Odoo's domain syntax (e.g., [('is_company', '=', True)]). Only partners matching this condition will be considered for ZIP pattern matching for this team.
Pre-Zip Match Condition Examples
Some example domain conditions:
- `[('is_company', '=', True)]` — Only assign to partners that are companies
- `[('type', '=', 'contact')]` — Only assign to contacts
- `[('industry_id', '!=', False)]` — Only assign to partners with an industry set
You can combine multiple conditions, e.g. `[('is_company', '=', True), ('country_id', '=', ref('base.us'))]`
ZIP Pattern ExamplesAll patterns are validated in real-time to ensure they are valid Python regular expressions:
^1[0-5].*- ZIP codes starting with 10-15^2[0-9].*- ZIP codes starting with 20-29^751.*- ZIP codes starting with 751.*123$- ZIP codes ending with 123^[1-3].*- ZIP codes starting with 1, 2, or 3^(10|20|30).*- ZIP codes starting with 10, 20, or 30
Pattern Validation
The system validates regex patterns when they are entered:
- Invalid patterns will show an error message immediately
- Error messages include the specific regex error for debugging
- Only valid patterns can be saved to the database
Partner Configuration
---------------------
Partners have an "Exclude from ZIP Assignment" checkbox to prevent automatic assignment.
Teams can have a "Pre-Zip Match Condition" to restrict assignment to partners matching specific criteria before ZIP pattern matching is performed.
Usage
-----
Automatic AssignmentPartners are automatically assigned to CRM teams when:
- A partner is created with complete geographic information (ZIP, country, state)
- A partner's ZIP code is modified
- A partner's country or state is changed
- A partner's company is changed
- The exclusion flag is modified
For each team, if a "Pre-Zip Match Condition" is set, the partner must match this condition before ZIP pattern matching is performed. If not set, all partners are considered for ZIP matching.
Manual Assignment
You can also trigger assignment manually:
- Use the contextual action available in partner views
- This is useful for reassigning existing partners after updating team configurations or after addon installation
Assignment RequirementsFor automatic assignment to work, partners must have:
- A ZIP code
- A country
- A state
- A company
- "Exclude from ZIP Assignment" must be unchecked
No verified information in OCA: Installation, Configuration.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.