
from odoo import api, SUPERUSER_ID
from odoo.api import Environment

def check_pos_online():
    # Attempt to find Cheese Burger
    burger = env['product.template'].search([('name', 'ilike', 'Cheese Burger')], limit=1)
    if burger:
        print(f"PRODUCT_FOUND: {burger.name}, is_kitchen_item: {burger.is_kitchen_item}")
    else:
        print("PRODUCT_NOT_FOUND")

    config = env['pos.config'].search([('module_pos_restaurant', '=', True), ('active', '=', True)], limit=1)
    if config:
        session = env['pos.session'].search([('config_id', '=', config.id), ('state', '=', 'opened')], limit=1)
        print(f"CONFIG_FOUND: {config.name}, OPEN_SESSION: {session.id if session else 'NONE'}")
    else:
        print("REST_CONFIG_NOT_FOUND")

    online_orders = env['pos.order'].search([('is_online_order', '=', True)])
    print(f"ONLINE_ORDERS_COUNT: {len(online_orders)}")

    pending_online = env['pos.order'].search([('is_online_order', '=', True), ('online_order_status', '=', 'pending')])
    print(f"PENDING_ONLINE_ORDERS: {len(pending_online)}")

check_pos_online()
