Skip to content

Conversation

@pilarvargas-tecnativa
Copy link
Contributor

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

Code review OK

Comment on lines +52 to +84
@api.onchange("secondary_uom_id", "secondary_uom_qty")
def _onchange_secondary_uom(self):
if not self.secondary_uom_id:
return
factor = self.secondary_uom_id.factor * self.product_id.uom_id.factor
qty = float_round(
self.secondary_uom_qty * factor,
precision_rounding=self.product_id.uom_id.rounding,
)
if (
float_compare(
self.units_included,
qty,
precision_rounding=self.product_id.uom_id.rounding,
)
!= 0
):
self.units_included = qty

@api.onchange("units_included")
def _onchange_units_included_purchase_order_secondary_unit(self):
if not self.secondary_uom_id:
return
factor = self.secondary_uom_id.factor * self.product_id.uom_id.factor
qty = float_round(
self.units_included / (factor or 1.0),
precision_rounding=self.secondary_uom_id.uom_id.rounding,
)
if (
float_compare(
self.secondary_uom_qty,
qty,
precision_rounding=self.secondary_uom_id.uom_id.rounding,
)
!= 0
):
self.secondary_uom_qty = qty
Copy link
Contributor

Choose a reason for hiding this comment

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

The same comment from this other PR can be applied here: OCA/sale-workflow#4010 (comment)

@pilarvargas-tecnativa pilarvargas-tecnativa force-pushed the 18.0-mig-purchase_order_product_recommendation_secondary_unit branch from 962e4ab to f0bf45e Compare November 14, 2025 07:45
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.

6 participants