Home Blog Odoo Tips and Tricks
Odoo Tips and Tricks

Odoo Tips and Tricks

Odoo, famously known as the Open-Source Enterprise Resource Planning Software was founded in 2005. It is a Module-Based system which has been developed to support almost every functionality of the businesses.

An ERP acts as a technical solution to automate the entire process of your business. It allows you to gain insights and controls over the various departments of your business like HR, Sales, Purchase, Accounting, Social Media Management, CRM, etc.

Odoo would allow you to compile all of the information from these departments and provide it in a single platform- your Odoo Database.

If you are an Odoo Developer, you might come across situations where you may get stuck or come across a hurdle. As Odoo Partners, Kanak Infosystems LLP. understands the trouble and that is exactly why we have come up with our little tips and tricks in this blog. These partner tricks will help you and will definitely save up your time.

🎯 Ready to take your Odoo game to the next level? Discover our top tips & tricks and start implementing them now.... 

Odoo Hacks: A comprehensive list of Tips and Tricks

1. To calculate the number of lines in your module we have two commands:

(1) ./odoo-bin cloc -p <module-path> : this will give you the total number of lines your module contains.

(2) ./odoo-bin cloc -p <module-path> -v : this will give you the total number of lines of each file your module contains.

these files are excluded from the odoo cloc by default:

​__manifest__.py or __openerp__.py

the xml files included in demo or demo_xml section of the manifest

contents of static/lib

tests which are defined in tests and static/tests

and also excluded files from odoo cloc command by declaring cloc_exlude in manifest

for example:





Odoo Hacks
Odoo Hacks

2. "selection_badge" Widget

If you want to display the selection field like a badge selection, then this widget can be useful.

Applicable on which types of fields?

Answer: Can be applied only on selection type field


<field name="detailed_type" widget="selection_badge"/>

selection badge widget

3. In Odoo16 Early Payment Discount Feature is Added In Payment Terms.

If someone is doing a payment before the Due date, then they will get a discount in a payable amount.

early payment discount
early payment discount
early payment discount
early payment discount

4. How to debug QWeb templates in odoo?

By putting t-debug="pdb" in the XML template to debug the template code. It is the same as the set_trace() method of python debugger.

NOTE: Need to enable --log-level=debug in terminal then only you can debug the XML template.


<t t-debug="pdb"/>

5. Custom Icon on State Widget.

In order to add custom icons to a state like selection field in tree view you can use widget event_icon_selection in selection field and in options set icons for specific value of selection field which will show custom icons in view as value of field changes.

custom icon on state widget
custom icon on state widget

6. In odoo 16 one more feature has been added called Storno accounting.

You can enable this feature from Accounting Setting, using this feature, we can use negative debit or credit amounts to reverse original journal account entries.

storno accounting
storno accounting
storno accounting
storno accounting

7. In Order to deal with features like copy-generated URLs, developers can use the widget "CopyClipboardChar" in the attribute of the field in view.

copy clipboardchar
copy clipboardchar

This will show a copy-compatible field in view for the user to easily use to URL for refereeing purposes.

8. When creating a field in the database, Indexing is a very useful feature because the data is stored like an array, and the new values are added one by one. So if you search for a particular string, it can take a very long time to search for the last value present in the array. So to improve the speed and better sorting, the indexing method is used in fields in Odoo.

In Odoo 16, there are 3 methods of indexing introduced for fields.

1)btree or True (True was already present in earlier versions)



For example,

name = fields.Char(string="Order Reference", index='trigram')

Adding Index to the fields make the storing and searching of the values in the database faster.

9. No more '_name_search' for simple search using multiple fields. Odoo16 has a new parameter as a '_rec_names_search'.

odoo 16


class AccountMove(models.Model):

_name = "account.move"

_inherit = ['portal.mixin', 'mail.thread', 'mail.activity.mixin', 'sequence.mixin']

_description = "Journal Entry"

_order = 'date desc, name desc, id desc'

_mail_post_access = 'read'

_check_company_auto = True

_sequence_index = "journal_id"

_rec_names_search = ['name', 'partner_id.name', 'ref']

10. Odoo backend to have increment/decrement options for integer field.

1. Syntax for simple increment/decrement option:

<field name="your_integer_field" options='{"type": "number"}' />

2. Syntax for increment/decrement option with step:

<field name="your_integer_field" options='{"type": "number", 鈥渟tep鈥: 5}' />

11. Odoo 16: how to load new fields in pos models.

method prefix is fix ex: loader_params after added model name like _loader_params_res_partner

ex for _loader_params_modelname

and methods defined in possession model

example to load new field in pos model:

def _loader_params_pos_payment_method(self):

​result = super()._loader_params_pos_payment_method()


​return result

def _loader_params_model_name(self):

​result = super()._loader_params_model_name()


​return result

12. Odoo support javascript files -

1- Plain javascript files (no module system) - plain javascript files do not offer the benefits of a module system, so one needs to be careful about the order in the bundle (since the browser will execute them precisely in that order).

2- Native javascript module - Most new Odoo javascript code should use the native javascript module system. This is simpler and brings the benefits of a better developer experience with better integration with the IDE. There is a very important point to know: Odoo needs to know which files should be translated into Odoo modules and which files should not be translated. This is an opt-in system: Odoo will look at the first line of a JS file and check if it contains the string @odoo-module. If so, it will automatically be converted to an Odoo module.

3- Odoo modules (using a custom module system) - Odoo has defined a small module system (located in the file addons/web/static/src/js/boot.js, which needs to be loaded first). The Odoo module system, inspired by AMD, works by defining the function defined on the global odoo object. We then define each javascript module by calling that function. In the Odoo framework, a module is a piece of code that will be executed as soon as possible. It has a name and potentially some dependencies. When its dependencies are loaded, a module will then be loaded as well. The value of the module is then the return value of the function defining the module.

13. If the module is having any external python dependency, then we can define it in manifest (as below), so if your server didn't have installed the library, by clicking on the "Install" button on the module, will give you the warning that external dependency is not installed.

'external_dependencies': {

  ​'python': ['pyqrcode']


If you want to install an external library in odoo.sh automatically then you need to add a "requirements.txt" file with the proper version of the external library(as below) in the branch(not in module). So when you push the module on odoo.sh odoo will auto install the external library.

requirements.txt file should have below content:


14. Xpath element named "move", The position='move' has been introduced to move an element in an inherited view.

It's used as:

<field name="target_field" position="after">

​<field name="my_field" position="move"/>


In the above example my_field is placed after target_field in the parent form. So now we can inherit and have the ability to manipulate fields order in views, not only add new fields.

15. In odoo 16.0, There is an option which has been added "Switch into refund/credit note" in Invoice/Bill form view Action, using this you can convert your invoice to credit not and bill to refund, it'll automatically change Accounting entry(database contain 1 entry), up to 15.0 you can cancel entry and you have to create a new one(database contain 2 entry).

Switch into refund/credit note
Switch into refund/credit note

16. In the inventory module under the configuration operation type, odoo added a new field called Create Backorder.

This is for those Users who may have less knowledge of management and might click on Cancel when asked if they want to create a backorder. That would create a mess in records,which would make it hard to detect or track them. The Create Backorder option forces the user to choose rather than cancel the backorder option.

create backorder

17. Create a module without creating a folder inside the folder, just go to the terminal and write this command ./odoo-bin scaffold module name should be mentioned: it automatically creates a module of mentioned name after scaffold.

Create a module

18. Fix warning - In odoo-16.0 log

When running the terminal, we get the warning 

fix warning

Go home>> open .odoorc file and change longpolling-port = 8072 change gevent-port = 8072

Fix warning
fix warning

19. Odoo16: Add precompute=True option in your Computed fields to compute value before Record Create, UpTo 15.0 version Computed field value was computed after Record Create.

Kanak Infosystems LLP. believes that these technical tips and tricks may come out handy for all the Odoo Developers out there, just like they have helped the Odoo Experts at the house of Kanak.


📋 Upgrade your Odoo version now to enjoy a hassle-free and enhanced user experience. Don't miss out on the benefits of the latest version - act today!

Get In Touch with Us

Leave a Comment

Your email address will not be published.

Your comment is under review by our moderation team.