Skip to content

Fork Sync Branch 18.0 - #65

Merged
btl-bot merged 2 commits into
BTLzdravtech:18.0from
ingadhoc:18.0
Aug 20, 2026
Merged

Fork Sync Branch 18.0#65
btl-bot merged 2 commits into
BTLzdravtech:18.0from
ingadhoc:18.0

Conversation

@btl-bot

@btl-bot btl-bot commented Aug 20, 2026

Copy link
Copy Markdown

No description provided.

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>
…urrency

Standalone module, so it can be installed on an affected database, run once per
product and uninstalled afterwards. It adds no behaviour to the base module while
installed, and #993 remains the permanent fix.

Port of #736 (16.0, never merged).

Fixing the revaluation wizard is not enough for a database that already ran
revaluations while the cost in currency was not being written. Every later layer
was valued from that stale cost: outs take standard_price_in_currency * quantity,
and inbound moves re-averaged on top of it. So the product form, the layers and
the journal entries are all off, and setting the cost on the product does not
repair the history.

stock.valuation.layer.recompute replays the valuation history of a product in
chronological order, computing what each layer should have been (purchase,
purchase refund, landed cost, inventory, out, return and manual adjustment are
handled separately), shows the old and new values side by side, and only on
confirmation writes the corrected values back to the layers, their journal entries
and the product cost.

Manual adjustments are respected: only the layers created after the last manual
valuation are adjusted, and that adjustment and everything before it are left as
they are. The layers before the cut still take part in the replay, but with their
recorded values rather than the recomputed ones, since they are not going to be
written and the average has to advance with what will actually remain in the
database. In 16.0 the running average always used the recomputed values, which was
consistent there because the normal flow deleted the adjustments first and then
wrote every layer; keeping the adjustments makes that assumption wrong.

The 16.0 tool detected those adjustments with create_uid = 1, which only matched
the ones it had created itself; on a database where the operators enter them,
nothing matched and the cut was lost. The domain now looks for layers with no
stock move, no invoice line and no landed cost, whoever created them. Excluding
the invoice line matters: a purchase price difference has no stock move either,
and taking it as the adjustment moves the cut past the real one.

The companion delete_adjust_compute_lines, which erased those adjustments with
their journal entries before recomputing, is not ported: it was circumstantial to
16.0, where the adjustments to remove were the tool's own.

Port notes for 18.0:

- attrs is gone: the view uses direct invisible/readonly attributes.
- tree became list in the valuation views.
- the header was outside form in the original arch, which no longer validates.
- the ACL is restricted to stock.group_stock_manager instead of base.group_user
  since the tool rewrites posted entries.
- 18.0 added lot level valuation. The recompute works at product level, so
  _check_supported_product raises on products with lot_valuated rather than
  silently producing wrong costs.
- computing with no layers for the chosen company now raises instead of reporting
  "Not changes Required", which reads as "the product is fine" when the company
  was simply wrong.
- dropped the dead patch_check_reconciliation helper and the commented out branch
  for layers older than #675.

Add a test covering the case that motivated it: an out valued with the stale cost
in currency is flagged, the manual adjustment is detected and left untouched, only
layers after it are marked, and the ones that are not written keep their recorded
value in the replay.

closes #995

Signed-off-by: Filoquin adhoc <maq@adhoc.com.ar>

@sireko sireko left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved

@btl-bot
btl-bot merged commit 5d07135 into BTLzdravtech:18.0 Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants