[IMP] product_pricelist_total_margin: Add margin_type selector (Markup vs Commercial Margin)
- Add margin_type field to choose between calculation methods: * Markup (on cost): PVP = Cost × (1 + markup%) * Commercial Margin (on PVP): PVP = Cost / (1 - margin%) - Update _compute_price() to apply correct formula based on margin_type - Add safety cap for commercial margin >= 100% (caps at 99%) - Add detailed logging for both calculation types - Update views to show margin_type field when use_total_margin is enabled - Add 2 new tests to validate both calculation methods: * test_total_margin_markup_type: validates markup formula * test_total_margin_commercial_margin_type: validates commercial margin formula - All 11 tests passing (9 existing + 2 new) Example with Commercial Margin: Base: 4.68€, Total Margin: 20% - Markup: 4.68 × 1.20 = 5.616€ (margin = 16.67% of PVP) - Commercial Margin: 4.68 / 0.80 = 5.85€ (margin = 20% of PVP) ✓
This commit is contained in:
parent
cafa19ffea
commit
0f239601ce
4 changed files with 107 additions and 11 deletions
|
|
@ -5,12 +5,16 @@
|
|||
<field name="model">product.pricelist.item</field>
|
||||
<field name="inherit_id" ref="product.product_pricelist_item_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<!-- Add use_total_margin field after compute_price -->
|
||||
<!-- Add use_total_margin and margin_type fields after compute_price -->
|
||||
<field name="compute_price" position="after">
|
||||
<field
|
||||
name="use_total_margin"
|
||||
invisible="compute_price != 'formula' or base != 'pricelist'"
|
||||
/>
|
||||
<field
|
||||
name="margin_type"
|
||||
invisible="not use_total_margin"
|
||||
/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue