Help for odoo.fetch_products

Project

odoo

Function

fetch_products

Sample CLI

gway odoo fetch-products

Full Code

def fetch_products(*, name=None, latest_quotes=None):
    """
    Fetch the list of non-archived products from Odoo.
    If a name is provided, use it as a partial filter on the product name.
    """
    model = 'product.product'
    method = 'search_read'
    domain_filter = [('active', '=', True)]  # Non-archived products have active=True
    if name:
        domain_filter.append(('name', 'ilike', name))
    
    fields_to_fetch = ['name', 'list_price']  # Add fields as needed
    result = execute_kw(
        [domain_filter], {'fields': fields_to_fetch},
        model=model, method=method
    )
    return result