Reading list Switch to dark mode

    Odoo shell using Odoo CLI

    Updated 30 October 2023

    The Odoo Shell, also known as the Odoo CLI (Command Line Interface), is like a toolbox for your Odoo instance. It lets you use Python commands to talk to Odoo more interactively.

    With this, you can run Python code, work with your database, run queries, and take care of various administrative tasks.

    It’s a user-friendly tool that makes managing your Odoo system more convenient.

    Harnessing the capabilities of the Odoo Shell

    You may be wondering how to harness the capabilities of the Odoo Shell and put them to use.

    ./odoo-bin shell -c /etc/odoo.conf -d demo
    how to access Odoo shell
    • ./odoo-bin: This part of the command specifies the path to the Odoo binary executable (odoo-bin). The ./ at the beginning indicates that the executable is located in the current directory.
    • shell: This command tells Odoo to start a shell session. The Odoo shell allows you to interact with the Odoo system and perform various operations and queries.
    • -c /etc/odoo.conf: Here, the -c flag is used to specify the configuration file for Odoo. In this case, the configuration file is located at /etc/odoo.conf. The configuration file contains settings and options that define how Odoo should run, including database connections, server settings, and more.
    • -d demo: This part of the command specifies the name of the database to use within the Odoo shell session. In this case, it’s using a database named “demo.” Odoo can manage multiple databases, and this option allows you to select which database you want to work with.

    Performing ORM Methods in Odoo Shell

    In the Odoo shell, you can perform various ORM (Object-Relational Mapping) methods to interact with the Odoo database.

    Searching for an experienced
    Odoo Company ?
    Find out More

    Further, we have a plethora of quality Odoo apps and our Odoo development services help you get the desired Odoo customization or extension.

    Suppose you have a product in your Odoo database with an ID of 1, and you want to change its name to “odooshelltestproduct”.

    You can simply browse a product using the command:

    product = env[‘product.template’].browse(1)
    ORM methods using Odoo shell

    And you can easily change its name using the assignment operator, as commonly used in Odoo.

    Check out how to use CLOC Tools using Odoo CLI, which helps you count lines of codes using various criteria.

    field manipulation

    Note: As you may have noticed, you have to commit your changes to ensure they are saved to the database.

    NEED HELP?

    Hope you find the guide helpful! Please feel free to share your feedback in the comments below.

    If you still have any issues/queries regarding the same, please raise a ticket at the UV Desk.

    For any doubt, contact us at our support mail.

    Thanks for paying attention!!

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home