Skip to content

Conversation

@lef-adhoc
Copy link
Contributor

This PR fixes a bug where the product_uom_qty on a sale order line would reset to 0 when adding a product that uses a secondary unit of measure.

The logic that prevented this in previous versions was altered during the migration to v17 (#3385)

@lef-adhoc
Copy link
Contributor Author

Hi @pedrobaeza, can you check this PR?

@pedrobaeza pedrobaeza added this to the 18.0 milestone Aug 26, 2025
@pedrobaeza pedrobaeza changed the title [FIX] sale_order_secondary_unit: quantity resets to 0 with secondary UoM [18.0][FIX] sale_order_secondary_unit: quantity resets to 0 with secondary UoM Aug 26, 2025
@pedrobaeza
Copy link
Member

@sergio-teruel is more suitable than me for checking this.

@lef-adhoc
Copy link
Contributor Author

Hi @sergio-teruel could you check this?

Copy link

@nicolascol nicolascol left a comment

Choose a reason for hiding this comment

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

Funcitonal LGTM

Copy link

@lav-adhoc lav-adhoc left a comment

Choose a reason for hiding this comment

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

LGTM

if self.secondary_uom_id:
if line_uom_qty == 1.0:
self.secondary_uom_qty = 1.0
self._onchange_helper_product_uom_for_secondary()

Choose a reason for hiding this comment

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

instead of _onchange_helper_product_uom_for_secondary(), you should call the _compute_helper_target_field_qty() method, otherwise when the product qty is 1 and makes the comparison (in the if) to insert 1 unit in the secondary unit, after introducing 1 unit in the secondary qty, it introduces again 1 unit in the product original qty and makes the convertion.

This PR fixes a bug where the product_uom_qty on a sale order line would reset to 0 when adding a product that uses a secondary unit of measure.

The @onchange logic that prevented this in previous versions was altered during the migration to v17 (OCA#3385),
@rousseldenis
Copy link
Contributor

@sergio-teruel

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants