Instead of converting templates to variants before calling super(), check the model type when processing results. If working with product.template, get the variant from the template using browse(). This preserves the expected ID mapping in the result dictionary and avoids lambda variable binding issues. Fixes: KeyError: 9 in pricelist computation |
||
|---|---|---|
| .. | ||
| i18n | ||
| migrations/18.0.2.0.0 | ||
| models | ||
| tests | ||
| views | ||
| __init__.py | ||
| __manifest__.py | ||
| CHANGELOG.md | ||
| README.md | ||
Product Sale Price from Pricelist
Automatically calculate and update product sale prices based on the last purchase price and configurable pricelists.
Features
- Automatic Price Calculation: Set sale prices based on last purchase price and a configured pricelist
- Flexible Discount Handling: Choose how to apply discounts to the cost:
- Without discounts
- First discount only
- Double discount
- Triple discount
- Manual update
- Tax-Aware Pricing: Automatically includes tax calculations in pricing
- UoM Conversion: Handles different purchase and sale units of measure
- Batch Updates: Update theoretical prices for multiple products
- Product Flags: Mark products for price updates and track status
Configuration
- Settings > Sales > Automatic Price Configuration: Select the pricelist for automatic price calculation
- Products > Products: Configure per product:
- Last purchase price: Cost at which the product was last purchased
- Last purchase price calculation type: Choose how to apply discounts
- Mark Last purchase price updated when prices need to be reviewed
Price Calculation Types
- Without Discounts: Uses base purchase price without discounts
- First Discount: Applies only the first discount
- Double Discount: Applies first and second discount
- Triple Discount: Applies first, second, and third discount
- Manual Update: Price must be set manually
Usage
- Products are priced when received from purchase orders
- System automatically updates last_purchase_price field
- Sale price is calculated from the configured pricelist using the cost price
- Taxes are automatically applied based on product tax settings
- Go to Products > Update Theoretical Prices to batch update prices
Technical Architecture
Models
All main fields and business logic are stored in product.product for proper variant handling:
product.product (Main model)
last_purchase_price_updated(Boolean): Flag for price update neededlist_price_theoritical(Float): Calculated theoretical pricelast_purchase_price_received(Float): Last purchase price receivedlast_purchase_price_compute_type(Selection): How to calculate price_compute_theoritical_price(): Main price calculation methodaction_update_list_price(): Update sale price from theoretical
product.template (Related fields)
- All fields are
relatedtoproduct_variant_idfields - Allows views on template to continue working
- Delegates actions to product variants
This architecture prevents issues with pricelist reports and ensures proper handling of product variants.
License
AGPL-3.0 or later