[ADD] product_pricelist_total_margin: New module for additive margin calculation

- Add use_total_margin field to pricelist items
- Override _compute_price() to sum margins additively instead of compounding
- Support chained pricelists with custom base types (last_purchase_price)
- Add global minimum and maximum margin limits configuration
- Store limits in ir.config_parameter via res.config.settings
- Apply global limits after total margin calculation
- Add comprehensive test suite (9 tests) covering:
  * Basic additive vs compound margin behavior
  * Three-level pricelist chains
  * Global minimum/maximum margin enforcement
  * Rounding and surcharge compatibility
- Add configuration UI in Settings > Sales
- All tests passing (9/9)

This module fixes the issue where chained pricelists were compounding margins
instead of calculating total margins. Example: base 4.68€ with -5% and +25%
now correctly results in 5.616€ (20% total) instead of 5.56€ (compound).
This commit is contained in:
snt 2026-02-21 16:11:13 +01:00
parent f35bf0c5a1
commit 32f345bc44
12 changed files with 1143 additions and 0 deletions

View file

@ -138,6 +138,7 @@ class ProductProduct(models.Model):
old_price = product.lst_price
product.lst_price = product.list_price_theoritical
product.standard_price = product.last_purchase_price_received
product.last_purchase_price_updated = False
_logger.info(
"[PRICE] Product %s [%s]: List price updated from %.2f to %.2f",