Skip to content

[IMP] purchase_order_weight_volume: resolve total UoM via standard helper - #3175

Open
Camille0907 wants to merge 3 commits into
OCA:19.0from
camptocamp:19.0-imp-purchase_order_weight_volume
Open

Camille0907 wants to merge 3 commits into
OCA:19.0from
camptocamp:19.0-imp-purchase_order_weight_volume

Conversation

@Camille0907

Copy link
Copy Markdown
Contributor

total_weight_uom_id / total_volume_uom_id were read directly as a raw uom.uom id from the ir.config_parameter keys product_default_weight_uom_id / product_default_volume_uom_id. These parameters are only meaningful when the module product_logistics_uom (not in dependencies of the current module) is installed. If it is not installed, or was installed and later removed, the parameters can be missing, stale, or point to an orphaned/incompatible UoM. Since uom.uom._compute_quantity() does not validate that a conversion happens between compatible units, this could silently produce incorrect totals (e.g. a weight expressed in kg on the lines summed and displayed as if it were in ml on the total).

The line weight/volume UoM already resolves through product.template._get_weight_uom_id_from_ir_config_parameter() / _get_volume_uom_id_from_ir_config_parameter(), the standard Odoo helper that reads the same parameters through product_logistics_uom's override when installed, and safely falls back to kg/m3 otherwise. Use the same helper for the PO total, so lines and total are always expressed in compatible UoMs.

This changes almost nothing in practice: if product_logistics_uom is installed and correctly configured, the helper returns the exact same UoM the raw parameter already pointed to. Whether the total is displayed at all is untouched: it can still be disabled entirely through the existing display_order_weight_in_po / display_order_volume_in_po company settings, as before.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @ilyasProgrammer,
some modules you are maintaining are being modified, check this out!

@OCA-git-bot OCA-git-bot added series:19.0 mod:purchase_order_weight_volume Module purchase_order_weight_volume labels Sep 10, 2026
@HviorForgeFlow

Copy link
Copy Markdown
Member

Fix pre-commit

@HviorForgeFlow HviorForgeFlow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Attend comment #3175 (comment)

CI is broken

…helper

`total_weight_uom_id` / `total_volume_uom_id` were read directly as a raw `uom.uom` id from the `ir.config_parameter` keys `product_default_weight_uom_id` / `product_default_volume_uom_id`.
These parameters are only meaningful when the module `product_logistics_uom` (not in dependencies of the current module) is installed.
If it is not installed, or was installed and later removed, the parameters can be missing, stale, or point to an orphaned/incompatible UoM. Since `uom.uom._compute_quantity()` does not validate that a conversion happens between compatible units, this could silently produce incorrect totals (e.g. a weight expressed in kg on the lines summed and displayed as if it were in ml on the total).

The line weight/volume UoM already resolves through `product.template._get_weight_uom_id_from_ir_config_parameter()` / `_get_volume_uom_id_from_ir_config_parameter()`, the standard Odoo helper that reads the same parameters through `product_logistics_uom`'s override when installed, and safely falls back to kg/m3 otherwise. Use the same helper for the PO total, so lines and total are always expressed in compatible UoMs.

This changes almost nothing in practice: if `product_logistics_uom` is installed and correctly configured, the helper returns the exact same UoM the raw parameter already pointed to. Whether the total is displayed at all is untouched: it can still be disabled entirely through the existing `display_order_weight_in_po` / `display_order_volume_in_po` company settings, as before.
@vvrossem
vvrossem force-pushed the 19.0-imp-purchase_order_weight_volume branch from cebd436 to dd23f9f Compare September 25, 2026 09:14
…PO form

The total volume label and value were hidden based on the weight settings
(`total_weight_uom_id` / `display_order_weight_in_po`) instead of the volume
ones, so the volume total could be hidden while enabled, or shown while
disabled. Regression from the 19.0 migration (OCA#2901, cb2edf8): when
converting `attrs` to `invisible`, the volume rows got the weight condition.

Hide each total based on its own `display_order_*_in_po` setting only: the
total UoMs are now always set by the standard helper, so the
`total_*_uom_id == False` condition is no longer needed.
@vvrossem
vvrossem force-pushed the 19.0-imp-purchase_order_weight_volume branch from 8b41ffb to 8722b5d Compare September 25, 2026 10:16
…ay settings

`display_order_weight_in_po` / `display_order_volume_in_po` copied the company
settings through a compute depending on `company_id` only: a PO value already
read in the current transaction was not invalidated when the company setting
changed, and kept returning the old value.

Declare them as related fields: the dependencies on the company settings come
for free, and the compute that only copied the values goes away.
@vvrossem
vvrossem force-pushed the 19.0-imp-purchase_order_weight_volume branch from 8722b5d to aeea72d Compare September 25, 2026 10:20
@vvrossem

Copy link
Copy Markdown
Contributor

Two related fixes added in the same module:

  • Fix total volume visibility in PO form: the total volume label and value were hidden based on the weight settings instead of the volume ones. Regression from the 19.0 migration ([19.0][MIG] purchase_order_weight_volume: Migration to 19.0 #2901), when converting attrs to invisible.
  • Use related fields for PO display settings: display_order_weight_in_po / display_order_volume_in_po copied the company settings through a compute depending on company_id only, so a PO value already read in the current transaction kept its old value when the company setting changed. They are now related to the company fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:purchase_order_weight_volume Module purchase_order_weight_volume series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants