I'm currently using the Barcode module in Odoo 14 to scan the barcode of the products. However, every time I click on an order, the module loads extremely slowly.
I figured out that the get_all_products_by_barcode method caused all of this. My database has 64000 products, and that method alone took almost 50 seconds to query and return ALL products back to the client every single time.
Does anyone have a solution for this? Thank you.
P/s: This is the default method to get all product barcodes from Odoo
@api.model
def get_all_products_by_barcode(self):
# This search_read method is really slow
products = self.env['product.product'].search_read(
[('barcode', '!=', None), ('type', '!=', 'service')],
['barcode', 'display_name', 'uom_id', 'tracking']
)
packagings = self.env['product.packaging'].search_read(
[('barcode', '!=', None), ('product_id', '!=', None)],
['barcode', 'product_id', 'qty']
)
# Some other codes below here