I have set some fields as required, but the red * is not displayed. Do I need to create an additional module for this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
In Odoo Community Edition, required fields are automatically marked with a red asterisk (*) in the form view when the field is set as required in the model or view. Here’s how you can ensure this works correctly:
✅ 1. Use the required=True Attribute in the Model
When you define a field with required=True in your model, Odoo automatically adds a red * in the form view.
📌 Example:
python
CopyEdit
from odoo import models, fields class MyModel(models.Model): _name = 'my.model' name = fields.Char(string="Name", required=True) # Adds a red *
✅ 2. Set required="1" in the Form View (XML)
You can also specify the required attribute directly in the form view XML.
📌 Example:
xml
CopyEdit
<field name="name" required="1"/>
Odoo will automatically display a red * next to the field label.
✅ 3. Fix Missing Red Asterisk with CSS (If Not Displayed)
In some custom themes, the red * might not appear. You can add custom CSS to enforce it:
📌 Example (SCSS in a custom module):
scss
CopyEdit
.o_required_modifier label:after { content: " *"; color: red; font-weight: bold; }
<field name="zip" placeholder="ZIP" required="1"/>
Make required="1" in your XML view
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
1
apr. 25
|
435 | ||
one2one relational field
Opgelost
|
|
3
sep. 24
|
12399 | |
|
2
feb. 24
|
1563 | ||
|
1
jul. 23
|
1772 | ||
|
2
jun. 23
|
2458 |