# Odoo Zero Amount Issue - Fixed

## Problem
Quotations and sales orders were being created in Odoo with $0.00 amounts because the portal was trying to create order lines with `product_id: 1`, which doesn't exist in Odoo.

## Root Cause
- Portal has its own product packages (Dedicated Burst Internet, Fiber to Home, etc.)
- These packages don't map to Odoo products (which are things like "10GBase-LR SFP+", "24 Port Switch", etc.)
- Code was trying to use `$package->odoo_product_id ?? 1` as fallback
- Product ID 1 doesn't exist in Odoo (products start from ID 82+)
- Order line creation was failing silently, leaving quotations with no lines and $0.00 total

## Solution
**Don't create order lines automatically.** Instead:
1. Create quotation/order in Odoo with header information only
2. Include product details (name, quantity, price) in the notes field
3. Odoo team manually adds appropriate products and finalizes pricing

## Changes Made

### 1. Updated `OdooService::createQuotation()`
```php
// Before: Tried to create order lines with product_id
// After: Adds product details to notes, no order lines created
```

### 2. Updated `OdooService::createSaleOrderDirect()`
```php
// Before: Tried to create order lines with product_id
// After: Adds product details to notes, no order lines created
```

### 3. Removed product_id from Controllers
- `QuotationController` - removed `product_id` field
- `QuotationWorkflowController` - removed `product_id` field

## Result
✅ Quotations/orders create successfully in Odoo
✅ Amount shows $0.00 until Odoo team adds products
✅ Product details visible in notes for reference
✅ No more "product.product(1,) does not exist" errors

## Workflow
1. Customer requests quotation in portal
2. Portal creates quotation in Odoo with:
   - Customer info
   - Reference number
   - Notes containing:
     ```
     === REQUESTED PRODUCTS ===
     - Dedicated Burst Internet - 10Mbps
       Quantity: 1
       Requested Price: $150.00
     
     - Installation Fee
       Quantity: 1
       Requested Price: $500.00
     
     Note: Please add appropriate products and finalize pricing in Odoo.
     ```
3. Odoo team reviews notes
4. Odoo team adds products and sets final pricing
5. Customer sees finalized quotation

## Alternative Approach (Not Implemented)
If you want order lines to be created automatically, you would need to:
1. Create a generic product in Odoo (e.g., "Portal Service Request" - ID: 2141)
2. Add `ODOO_GENERIC_PRODUCT_ID=2141` to `.env`
3. Update code to create order lines using this generic product
4. Odoo team would still need to adjust/add products as needed

**Current approach is simpler and more flexible.**

## Testing
Run: `php test-quotation-fix.php`
- Creates test quotation
- Verifies no order lines created
- Confirms product details in notes

## Files Modified
- `app/Services/OdooService.php`
- `app/Http/Controllers/API/QuotationController.php`
- `app/Http/Controllers/API/QuotationWorkflowController.php`

## Date Fixed
February 10, 2026
