How to do it...

To add the configuration options, follow the given steps:

  1. To add the needed dependency and the new XML data files, edit the __manifest__.py file like this:
{  'name': 'Cookbook code', 
    'category': 'Library', 
    'depends': ['base_setup'], 
    'data': [ 
        'security/ir.model.access.csv', 
        'security/library_security.xml', 
        'views/library_book.xml', 
        'views/res_config_settings.xml', 
    ], 
} 
  1. To add the new security group used for feature activation, edit the security/library_book.xml file and add the following record to it:
    <record id="group_release_dates" model="res.groups"> 
        <field name="name">Library: release date feature</field> 
        <field name="category_id" ref="base.module_category_hidden" /> 
    </record> 
  1. To make the book release date visible only when this option is enabled, we edit the field definition in the models/library_book.py file:
class LibraryBook(models.Model): 
    # ... 
    date_release = fields.Date( 
        'Release Date',  
        groups='my_module.group_release_dates',
)
  1. Edit the models/__init__.py file to add a new Python file for the configuration settings model:
from . import library_book 
from . import res_config_settings 
  1. To extend the core configuration wizard by adding new options to it, add the models/res_config_settings.py file with this code:
from odoo import models, fields 
 
class ConfigSettings(models.TransientModel): 
    _inherit = 'res.config.settings' 
    group_release_dates = fields.Boolean( 
            "Manage book release dates", 
            group='base.group_user', 
            implied_group='my_module.group_release_dates',
) module_note = fields.Boolean("Install Notes app")
  1. To make the options available in the UI, add views/res_config_settings.xml, extending the form view:
<?xml version="1.0" encoding="utf-8"?> 
<odoo> 
    <record id="view_general_config_library" model="ir.ui.view"> 
      <field name="name">Configuration: add Library options</field> 
      <field name="model">res.config.settings</field> 
      <field name="inherit_id" 
ref="base_setup.res_config_settings_view_form" /> <field name="arch" type="xml"> <div id="business_documents" position="before">
<div id="my_module">
<h2>Library</h2>
<!-- Release Dates option -->
<div>
<field name="group_release_dates" class="oe_inline"/>
<label for="group_release_dates" />
</div>
<!-- Notes option -->
<div>
<field name="module_note" class="oe_inline"/>
<label for="module_note" />
</div>
</div>
</div>
</field> </record> </odoo>

After upgrading the addon module, the two new configuration options should be available at Settings | General Settings. The screen should look like this: