Sometimes you may want to limit the number of records loaded in a many2one field. Basically, you can add a domain attribute like this:
<field name="partner_id" domain="[('country_id.name', '=', 'United States')]"/>
However, if you want different domains based on the current user, for example:
If the current user is User A, the domain should be:
<field name="partner_id" domain="[('country_id.name', '=', 'United States')]"/>
If the current user is User B, the domain should be:
<field name="partner_id" domain="[('country_id.name', '=', 'Belgium')]"/>
With this app, you can easily configure the domain for many2one fields either per user or globally.
Configuration:
After intall this app, you have to enable "Custom Many2one Domain Group" option
List features:
1. USER MANY2ONE DOMAIN.
- After enabling the "Custom Many2one Domain Group" option, you will see the "Many2one Domain" tab in the user configuration.
"Model Restriction": Select Model.
"Field Restriction": Only Many2one or One2many fields can be selected.
"Apply on": Set domain for "Field Restriction" if "Field Restriction" is Many2one.
From the above configuration, it can be explained as follows: In the Sale Order form view, the user can only select customers whose country is "United States".
If "Field Restriction" is One2many, as shown in the image below
You must continue selecting "Field Many2one of One2many".
Then set domain for "Field Many2one of One2many".
From the above configuration, it can be explained as follows: On the Sale Order Line, the user can only select products with the category "Office Furniture".
2. GLOBAL MANY2ONE DOMAIN.
You can set the domain for the Many2one field and apply it to all users.
Go to Settings --> Technical --> Many2one Domain --> Configuration
You can configure it like the "User Many2one Domain" section.
Note that the configurations in the "Global Many2one Domain" section will be overridden by the "User Many2one Domain" section.
This is useful when you have domain configurations that apply to all users.
However, if you have specific domain configurations for individual users, you should configure them in the "User Many2one Domain" section.
Apps May You Like
Email Support: huynh.giang.son.gs@gmail.com
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module