[18.0][IMP] product_secondary_unit: Add "secondary_priority" dependency type - #2398
Open
carlosdauden wants to merge 3 commits into
Open
carlosdauden wants to merge 3 commits into
carlosdauden wants to merge 3 commits into
Conversation
"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.
Contributor
|
Hi @sergio-teruel, |
sergio-teruel
approved these changes
Sep 11, 2026
carlos-lopez-tecnativa
approved these changes
Sep 14, 2026
Contributor
|
This PR has the |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
"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