I am using odoo studio and there is a very nice address section in the contacts module where the word 'contact' is displayed and then a few address fields underneath to make it into a group of fields, I would like to make the user put in an address on a custom module and I want to know how to make it look similar to the one on the contacts but this module has no relation to the contacts module.
For Example I want to have the fields 'address Line 1', 'address Line 2', 'city', 'zip' etc. but I don't want it to look like completely separate fields, rather I want it to look like a group, something like this:
To achieve the same grouped design for address fields in your custom module as seen in the Contacts module, follow these steps:
1. Leverage Odoo Studio (UI Approach)
If you're using Odoo Studio, you can group fields visually to mimic the Contacts module's address section.
2. Manual XML Customization (Developer Mode)
If Odoo Studio doesn't provide enough flexibility or you're comfortable editing XML, you can directly modify the form view of your custom module.
Example:
Here’s how to create an address-like design:
3. Use the Address Formatting Style
Odoo's Contacts module uses predefined CSS styles to group address fields. You can apply the same styles to your custom module by adding o_address_format and related CSS classes.
CSS Styling (Optional):
If you want finer control over the appearance, you can add custom CSS.
Example:
4. Add Country and State Widgets
To enhance the functionality of the fields, use many2one fields for state_id and country_id, referencing the respective models (res.country.state and res.country). This provides dropdowns similar to the Contacts module.
Example:
5. Add Placeholders (Optional)
To make the fields look cleaner, you can add placeholders (like "Street...", "City...") as shown in the example XML above. These placeholders guide the user without needing labels for every field.
6. Test and Adjust