# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [18.0.2.6.0] - 2026-02-14

### Fixed

- **Protected Float computed fields to always return valid numbers**
  - Error: `TypeError: value.toFixed is not a function` in product list view
  - Added explicit float() conversion in all Float computed methods
  - Ensures computed fields never return False, None, or dict values
  - This prevents JavaScript formatting errors in tree views with monetary columns

## [18.0.2.5.0] - 2026-02-14

### Fixed

- **Complete JSONB to proper types conversion for both tables**
  - Error: `TypeError: float() argument must be a string or a real number, not 'dict'` in computed fields
  - Extended migration to convert JSONB columns in BOTH product_product AND product_template tables
  - Previous migration only covered product_product, but product_template also had JSONB columns
  - Now handles conversion for all 4 fields in both tables
  - Preserves all existing data during conversion

## [18.0.2.4.0] - 2026-02-14

### Fixed

- **Clean up old ir_property records**
  - Error: `TypeError: float() argument must be a string or a real number, not 'dict'`
  - Added post-migration to delete ir_property records left over from company_dependent fields
  - This prevents dict values from being passed to Float fields during onchange
  - Migration runs after module load to ensure ir_property table exists

## [18.0.2.3.0] - 2026-02-14

### Fixed

- **Removed company_dependent from all fields**
  - Error: `column "last_purchase_price_compute_type" is of type jsonb but expression is of type character varying`
  - Removed `company_dependent=True` from all fields in product.product
  - Fields are now stored directly in product_product table
  - Migration script moves existing data from ir_property to direct columns
  - This fixes save errors and simplifies data storage

## [18.0.2.2.0] - 2026-02-14

### Fixed

- **Fixed JavaScript error in product form view**
  - Error: `TypeError: value.toFixed is not a function`
  - Added `default=0.0` to `list_price_theoritical` field
  - Added `default=0.0` to `last_purchase_price_received` field
  - This prevents JavaScript from trying to format `False` values as monetary fields

## [18.0.2.0.0] - 2026-02-12

### Changed

**BREAKING CHANGE**: Architecture refactoring to fix pricelist report issues

- **Moved all main fields from `product.template` to `product.product`**
  - `last_purchase_price_updated`
  - `list_price_theoritical`
  - `last_purchase_price_received`
  - `last_purchase_price_compute_type`

- **Created related fields in `product.template`**
  - All template fields now use `related="product_variant_id.FIELD_NAME"`
  - Fields are stored and writable for performance
  - This maintains backward compatibility with existing views

- **Moved business logic to `product.product`**
  - `_compute_theoritical_price()` method
  - `action_update_list_price()` method
  - `price_compute()` override

### Fixed

- Resolved issues with pricelist report generation
- Proper handling of product variants in price calculations
- Eliminated confusion between template and variant pricing

### Migration Notes

**This is a database schema change**. After updating:

1. Update the module: `odoo -u product_sale_price_from_pricelist`
2. Odoo will automatically migrate data from template to variant fields
3. No manual data migration needed thanks to related fields
4. All existing views continue working without modification

### Technical Details

This architecture follows Odoo best practices:
- Product-specific data belongs in `product.product` (variants)
- Template fields are related/computed from variants
- Prevents issues with pricelist reports that work at variant level
- Maintains compatibility with standard Odoo reports

## [18.0.1.0.0] - 2025-01-XX

### Added

- Initial release
- Automatic price calculation from purchase prices
- Multiple discount handling options
- Tax-aware pricing
- UoM conversion support
- Batch price updates
