How to Add Custom Fields to Configuration Settings in Odoo 17
CelineGeorge1
980 views
17 slides
Oct 15, 2024
Slide 1 of 17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
About This Presentation
In this blog, we will explore the ability for users to customize settings in Odoo's Settings menu to align with their specific business needs, including the option to add new settings and perform corresponding operations.
Size: 851.37 KB
Language: en
Added: Oct 15, 2024
Slides: 17 pages
Slide Content
How to Add Custom Fields to Configuration Settings in Odoo 17 Enterprise
Introduction Enterpr ise In this blog, we will explore the ability for users to customize settings in Odoo's Settings menu to align with their specific business needs, including the option to add new settings and perform corresponding operations. A custom module, "sale_discount_limit," can be developed to introduce a discount limit feature for sale orders in Odoo. Users will have the option to enable or disable this functionality in Odoo's settings. When the feature is enabled, users can choose to set a discount limit as needed.
Steps Enterprise 1. Add new fields to ‘res.config.settings’ model. The Res Config Settings model in Odoo is transient, meaning that its data is regularly cleaned up. To ensure the preservation and retrieval of field data, we can incorporate the 'config_parameter' attribute into the field definition, which can be set up as follows. Config_parameter = module_name.field_name
Steps Enterprise Following the configuration of the 'config_parameter,' we can easily access the field values within the settings. In this context, we've introduced two fields, 'is_discount_limit' as a boolean and 'discount_limit' as a float field.
Enterprise
Steps Enterprise 2. Add custom view for ‘res.config.settings’ view. In Odoo 17, when adding custom fields to a view, we can inherit the existing view and specify their position using the <xpath> tag. To add custom fields to the sale settings, we should inherit the view 'sale.res_config_settings_view_form' and indicate where we want these fields to appear. A new feature introduced in Odoo 17 is the <settings> tag. The <settings> tag in Odoo automatically aligns the fields, both to the left and right, for added convenience and flexibility in customization. This tag simplifies the process of adding boolean fields, as they are automatically left-aligned within it, and it has attributes that allow for customization and placement of these fields.
Steps Enterprise We can assign a unique ID to the field, which is immensely helpful when locating it during inheritance. The string serves as the visible heading for users, and if not set, the field's label is used. Providing a brief description in the help attribute allows users to access additional information under the heading. Furthermore, the title attribute is useful for explaining the field's purpose when users hover their mouse over it. We can include documentation by specifying a documentation path, allowing users to access additional details when users click the question mark near the field.
Enterprise
Steps Enterprise I added a custom field to the 'Pricing' section of the sale settings, positioning it after the sale order line discount field. This new field is only visible when the line discount option is enabled.
Enterprise
Steps Enterprise In the first picture, the discount feature is disabled, and consequently, there's no option to enable the discount limit. However, in the following image, after enabling the discount, users can now see the discount limit option, giving them the flexibility to choose whether to enable it or not.
Enterprise
Steps Enterprise Enabling the discount limit provides users with the option to input the desired discount limit in this field. Users can access the documentation by hovering their mouse over the question mark and clicking it, which will redirect them to the relevant information.
Enterprise
Steps Enterprise With this setup, it becomes entirely feasible to implement conditions or execute actions based on these field values, enabling the creation of customized settings options within the Res Config Settings in Odoo.
Conclusion Enterprise Hence this is how we can a dd custom fields to configuration settings in Odoo 17
For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com