Commit 7f18843
committed
[FIX] stock_currency_valuation: fix revaluation in secondary currency
Three defects on the revaluation of a product whose category has a secondary
valuation currency.
1. The cost in currency was never written. The 18.0 migration rewrote
action_validate_revaluation() as a copy of the new native method and dropped
the line that updated standard_price_in_currency, so the valuation layer and
the journal entry were right but the product form kept the old value. The
other path that writes that field,
stock.valuation.layer._update_currency_standard_price(), only runs for layers
with a landed cost and the revaluation layer has none. The added value in
currency is divided by product_id.quantity_svl, the same divisor the native
code uses on the line above for standard_price, so both costs stay on the
same basis when the revaluation targets specific layers.
2. The wizard preview added a unit cost to a total value:
standard_price_in_currency + added_value_in_currency. The native code adds
current_value_svl (a total) to added_value, so the figures shown on screen did
not match the cost that ended up on the product. With 10 units at 10 and an
added value of 50 it showed 60 (6 by unit) instead of 150 (15 by unit).
3. new_value_in_currency_by_qty declared _compute_new_value as its compute
method, which never assigns it. It only resolved because reading
new_value_in_currency first filled the cache.
Also add standard_price_in_currency to the depends of the product.template
compute. It only tracked the variant standard_price, so a change that moved only
the cost in currency left the template showing a stale value. The existing
standard_price dependency is kept: the field is not stored and that dependency
drives the onchange in the product form.
Add a test covering the four cases.
closes #993
Signed-off-by: Filoquin adhoc <maq@adhoc.com.ar>1 parent 3da22a2 commit 7f18843
4 files changed
Lines changed: 72 additions & 4 deletions
File tree
- stock_currency_valuation
- models
- tests
- wizard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 54 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
111 | 120 | | |
112 | 121 | | |
113 | 122 | | |
| |||
0 commit comments