Skip to content

[18.0][IMP] product_secondary_unit: Add "secondary_priority" dependency type - #2398

Open
carlosdauden wants to merge 3 commits into
OCA:18.0from
Tecnativa:18.0-FIX-product_secondary_unit_add_secondary_priority
Open

carlosdauden wants to merge 3 commits into
OCA:18.0from
Tecnativa:18.0-FIX-product_secondary_unit_add_secondary_priority

Conversation

@carlosdauden

Copy link
Copy Markdown
Contributor

"dependent" always keeps both quantities in sync via the factor - wrong
when the secondary unit is a count that must survive exactly (e.g.
pieces of a product sold by weight). "independent" avoids that, but
also drops the useful estimate of the primary quantity from the count
at creation time, since neither direction computes at all.

Add "secondary_priority": the primary quantity is still estimated from
the secondary one (like "dependent"), but the secondary one is never
itself recomputed back from the primary (like "independent") - the
secondary unit always has priority once it's been set.

@Tecnativa

ping @sergio-teruel @carlos-lopez-tecnativa @CarlosRoca13

"dependent" always keeps both quantities in sync via the factor - wrong
when the secondary unit is a count that must survive exactly (e.g.
pieces of a product sold by weight). "independent" avoids that, but
also drops the useful estimate of the primary quantity from the count
at creation time, since neither direction computes at all.

Add "secondary_priority": the primary quantity is still estimated from
the secondary one (like "dependent"), but the secondary one is never
itself recomputed back from the primary (like "independent") - the
secondary unit always has priority once it's been set.
This one-line guard existed in the 15.0 and 17.0 versions of this
module but was lost during the 18.0 migration (confirmed via git
archaeology against the sibling version projects - present 15.0,
absent 16.0, present 17.0, absent 18.0).

qty_field (e.g. product_uom_qty) and secondary_uom_qty are mutually
dependent computed fields with readonly=False. Without this call,
after _compute_secondary_uom_qty runs (triggered because qty_field
changed), qty_field itself gets marked "to compute" again since it
depends on secondary_uom_qty - a later recompute could then silently
overwrite an explicitly-written qty_field value with one re-derived
from secondary_uom_qty * factor, which can differ due to rounding.

No dependency_type="dependent" secondary units are active in
peixospalamos production today (migrated to "secondary_priority" this
session), so this closes a latent gap rather than an active one, but
it's a correct restoration for this shared module regardless.
… detail

Rewrote readme/DESCRIPTION.md and readme/USAGE.md with a concrete
example for each dependency_type (dependent/independent/secondary_priority)
and the real use cases covered, including this session's own
secondary_priority addition and the restored remove_to_compute() guard.

README.rst/index.html regenerated from the fragments via pre-commit.
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @sergio-teruel,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza pedrobaeza added this to the 18.0 milestone Sep 14, 2026
carlosdauden added a commit to Tecnativa/stock-logistics-warehouse that referenced this pull request Sep 15, 2026
Pin product_secondary_unit to OCA/product-attribute#2398
so Runboat and CI can test the "secondary_priority" dependency_type this
module needs before that PR merges. Remove once it does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants