hello dear community
want to ask u i created a field selection and i put values but i want to give to the user the permission so he can add values and select one of them is it possible and if it yes can please someone explain how
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
hello dear community
want to ask u i created a field selection and i put values but i want to give to the user the permission so he can add values and select one of them is it possible and if it yes can please someone explain how
Here’s how:
python
CopyEdit
from odoo import models, fields class CustomOption(models.Model): _name = 'your.model.option' _description = 'Selectable Options' name = fields.Char(string="Option", required=True)
In your main model:
python
CopyEdit
from odoo import models, fields class YourModel(models.Model): _name = 'your.model' option_id = fields.Many2one('your.model.option', string="Option")
In the form view XML:
xml
CopyEdit
<field name="option_id" options="{'no_create': False}" context="{'default_name': 'New Option'}"/>
This allows the user to:
Now users can add and choose options freely, just like a dynamic selection list.
Let me know if you want to restrict who can add options with access rights!
Hello Jihane
Users cant add a value to the selection field as its modified only using python code
However you can implement the same thing by Creating a new model and instead of using a selection field you can use a Many2one field and then give users access to this new model so they can add values
Hope this helps
Hi,
Step 1: Create a New Model for Selection Options
Create .py file
from odoo import models, fields
class CustomSelectionOption(models.Model):
_name = 'custom.selection.option'
_description = 'Editable Selection Options'
_order = 'name asc' # Sort alphabetically
name = fields.Char('Option Value', required=True)
active = fields.Boolean('Active', default=True)
Step 2: Add Many2one Field to Your Main Model
Create .py file
class YourModel(models.Model):
_inherit = 'your.model' # e.g., sale.order, product.template
custom_selection = fields.Many2one(
'custom.selection.option',
string='Custom Selection',
help="Select or create new options"
)
Step 3: Set Up Security Permissions
Create security/ir.model.access.csv:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_custom_selection,custom.selection.access,model_custom_selection_option,base.group_user,1,1,1,0
Hope it helps
Erstellen Sie heute ein Konto, um exklusive Funktionen zu nutzen und mit unserer tollen Community zu interagieren!
Registrieren
Hello jihane,
Can you tell me is the user is internal user type or portal and also where you want the user to select the field on odoo basic erp view or on website?