Chat
Search
Ithy Logo

Hiding the 'Create Quotations' Option in Odoo 17 Enterprise Sales Order

A Comprehensive Guide to Customizing Your Odoo Sales Interface

business software interface

Key Takeaways

  • Custom Module Creation: Building a custom module is essential for implementing changes without altering the core Odoo code.
  • View Inheritance: Overriding and inheriting views using XML allows for precise customization of the Odoo interface.
  • Security and Permissions: Managing user groups and permissions ensures that only authorized users can access specific actions.

Introduction

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.


Prerequisites

  • Basic understanding of Odoo modules and their structure.
  • Access to the Odoo server with appropriate permissions to install and manage modules.
  • Familiarity with XML and Python programming languages.
  • Odoo 17 Enterprise installed and running.

Step 1: Create a Custom Module

1.1. Setting Up the Module Structure

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
    

1.2. Initializing the Module

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
    

1.3. Defining the Manifest

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',
    }
    

Step 2: Modify the Sales Order View

2.1. Understanding View Inheritance

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.

2.2. Creating the View Modification XML

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.

2.3. Alternative Method: Using Groups for Conditional Visibility

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.


Step 3: Update the Module Manifest

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',
    ],
    

Step 4: Install or Upgrade the Custom Module

4.1. Placing the Module in the Addons Directory

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.

4.2. Restarting the Odoo Server

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
    

4.3. Installing the Module via Odoo Interface

  1. Log in to your Odoo instance with an account that has administrative privileges.
  2. Navigate to the Apps menu.
  3. Click on the Update App List to refresh the list of available modules.
  4. Search for your custom module, e.g., Hide Create Quotations Action.
  5. Click Install to add the module to your Odoo instance.

If the module is already installed and you have made further changes, use the Upgrade option instead.


Step 5: Verifying the Changes

5.1. Accessing the Sales Order Interface

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.

5.2. Testing User Permissions (If Applicable)

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.


Advanced Customizations

6.1. Using Record Rules for Enhanced Security

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.

6.2. Handling Multi-Record Environments

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.

6.3. Maintaining Compatibility with Future Updates

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.

6.4. Documentation and Version Control

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.


Troubleshooting

7.1. Button Still Visible After Installation

  • Clear Cache: Sometimes, browser caching can prevent immediate visibility of changes. Clear your browser cache or use an incognito window to check.
  • Check XML Syntax: Ensure that your XML files are correctly formatted. Errors in XML can prevent the view from being properly inherited.
  • Verify XML IDs: Confirm that the XML ID referenced in the inherit_id attribute matches the exact ID of the Sales Order form view.
  • Review Module Dependencies: Make sure all dependencies are correctly specified in the __manifest__.py file.

7.2. Errors During Module Installation

  • Check Logs: Review the Odoo server logs for detailed error messages.
  • Verify Python Syntax: Ensure that all Python files, especially __init__.py and the manifest file, are free of syntax errors.
  • Dependencies Missing: Ensure all required modules are installed and accessible.

7.3. Inconsistent Behavior Across Users

  • Group Assignments: Double-check that user groups are correctly assigned and that the XML attributes reference the correct group IDs.
  • Record Rules Conflicts: Ensure that there are no conflicting record rules affecting the visibility of the action.

Best Practices

8.1. Avoid Direct Core Modifications

Always use inheritance and custom modules to make changes. Directly modifying core Odoo files can lead to complications during updates and make maintenance challenging.

8.2. Use Meaningful Module Names

Choose descriptive names for your custom modules to clearly indicate their purpose. This practice aids in maintenance and collaboration.

8.3. Test in a Development Environment

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.

8.4. Maintain Proper Documentation

Document your customizations, including the purpose of changes, module structure, and any specific configurations. Proper documentation facilitates easier troubleshooting and future enhancements.


Conclusion

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.


References


Last updated January 19, 2025
Ask Ithy AI
Export Article
Delete Article