Odoo 17 Enterprise offers a robust and flexible platform for managing various business operations, including sales processes. Within the Sales Order interface, the "Create quotations" option under the Action button is a common feature that some organizations may find unnecessary or wish to restrict. Hiding this option can streamline the user interface and prevent unauthorized quotation generation.
This guide provides a step-by-step approach to hiding the "Create quotations" action using a custom module in Odoo 17 Enterprise. By following these instructions, you can customize your Odoo instance to better fit your business workflows and security requirements.
Begin by creating a new custom module that will house the modifications necessary to hide the "Create quotations" option. Ensure that the module follows Odoo’s standard directory structure.
Example directory structure:
custom_addons/
└── hide_create_quotation/
├── __init__.py
├── __manifest__.py
├── models/
└── views/
└── sale_order_views.xml
Create an empty __init__.py
file to initialize the module. This file can remain empty unless you plan to add Python models or logic.
# __init__.py
The __manifest__.py
file contains metadata about your module, including its name, version, dependencies, and data files. Below is an example manifest tailored for hiding the "Create quotations" action.
{
'name': 'Hide Create Quotations Action',
'version': '17.0.1.0.0',
'category': 'Sales',
'summary': 'Hide the Create Quotations action in Sales Order',
'description': """
This module hides the 'Create Quotations' option under the Action button in the Sales Order form.
""",
'author': 'Your Name or Company',
'depends': ['sale_management'],
'data': [
'views/sale_order_views.xml',
],
'installable': True,
'application': False,
'auto_install': False,
'license': 'LGPL-3',
}
To customize the Sales Order form, you will inherit the existing view and apply modifications using XML. This approach ensures that core functionalities remain intact while allowing you to tailor specific elements.
Navigate to the views
directory within your custom module and create a new XML file named sale_order_views.xml
. This file will contain the necessary instructions to hide the "Create quotations" button.
<!-- sale_order_views.xml -->
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_order_form_inherit_hide_create_quotation" model="ir.ui.view">
<field name="name">sale.order.form.inherit.hide.create.quotation</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<!-- Locate the 'Create quotations' button and make it invisible -->
<xpath expr="//button[@name='action_quotation_send']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>
Explanation:
- The record
tag defines a new view that inherits from the existing Sales Order form view.
- The xpath
expression locates the button with the name action_quotation_send
, which is responsible for the "Create quotations" action.
- Setting the invisible
attribute to 1
hides the button from the user interface.
If you prefer to restrict the visibility of the "Create quotations" button to specific user groups rather than hiding it entirely, you can modify the XML as follows:
<!-- Conditional visibility based on user groups -->
<xpath expr="//button[@name='action_quotation_send']" position="attributes">
<attribute name="groups">sales_team.group_sale_manager</attribute>
</xpath>
In this example, only users belonging to the "Sales Manager" group will see the "Create quotations" button. Replace sales_team.group_sale_manager
with the appropriate group external ID as needed.
Ensure that the sale_order_views.xml
file is referenced in the data
section of your __manifest__.py
file. This inclusion allows Odoo to load your customizations when the module is installed or updated.
'data': [
'views/sale_order_views.xml',
],
Copy your custom module directory hide_create_quotation
into the Odoo addons
directory or any other directory specified in your Odoo configuration for custom addons.
After placing the module in the appropriate directory, restart the Odoo server to recognize the new module. This can typically be done using command-line instructions, such as:
sudo systemctl restart odoo
Hide Create Quotations Action
.
If the module is already installed and you have made further changes, use the Upgrade option instead.
After successful installation, navigate to the Sales module and open any Sales Order. Click on the Action button to verify that the "Create quotations" option is no longer visible.
If you implemented conditional visibility based on user groups, log in with different user accounts to ensure that the "Create quotations" button appears only for users within the specified groups. This step verifies that your security settings are correctly enforced.
For additional security, especially in environments with multiple user groups and complex permission structures, consider implementing record rules to control access to actions beyond the user interface.
Example of restricting action access via record rules:
<record id="hide_create_quotation_record_rule" model="ir.rule">
<field name="name">Hide Create Quotations Action</field>
<field name="model_id" ref="sale.model_sale_order"/>
<field name="domain_force">[(1, '=', 0)]</field>
<field name="groups" eval="[(4, ref('sales_team.group_sale_manager'))]"/>
</record>
This rule effectively prevents users not in the "Sales Manager" group from performing the "Create quotations" action, adding an extra layer of security.
In environments where multiple records are processed simultaneously, ensure that your customizations do not interfere with batch operations or automated workflows. Test thoroughly to maintain system integrity.
Odoo regularly releases updates that may alter the underlying structure of views and actions. To maintain compatibility, monitor updates and adjust your custom module accordingly. Using inheritance and avoiding direct modifications to core files helps minimize conflicts.
Document your customizations and maintain version control using systems like Git. Proper documentation ensures that future developers can understand and manage the custom module effectively.
inherit_id
attribute matches the exact ID of the Sales Order form view.__manifest__.py
file.__init__.py
and the manifest file, are free of syntax errors.Always use inheritance and custom modules to make changes. Directly modifying core Odoo files can lead to complications during updates and make maintenance challenging.
Choose descriptive names for your custom modules to clearly indicate their purpose. This practice aids in maintenance and collaboration.
Before deploying changes to a production instance, thoroughly test your custom module in a development or staging environment to identify and rectify issues without impacting live operations.
Document your customizations, including the purpose of changes, module structure, and any specific configurations. Proper documentation facilitates easier troubleshooting and future enhancements.
Customizing Odoo 17 Enterprise to hide the "Create quotations" option under the Action button in the Sales Order interface enhances the user experience and aligns the system with your business processes. By following the steps outlined in this guide, you can implement this customization efficiently and securely using a custom module. Remember to adhere to best practices, thoroughly test your changes, and maintain clear documentation to ensure seamless integration and future maintainability.