Skip to content

[IMP] pos_sale: read_converted now uses method to get lines UoM#638

Open
JVegaB wants to merge 1 commit intoVauxoo:18.0from
vauxoo-dev:18.0-JVegaB-94093
Open

[IMP] pos_sale: read_converted now uses method to get lines UoM#638
JVegaB wants to merge 1 commit intoVauxoo:18.0from
vauxoo-dev:18.0-JVegaB-94093

Conversation

@JVegaB
Copy link

@JVegaB JVegaB commented Nov 6, 2025

  • Addded method get_product_uom to the sale.order.line model.
  • Method read_converted now uses get_product_uom.

Description of the issue/feature this PR addresses:

The current method read_converted does not offers a way to change the UoM to use in a sale.order.line.

Current behavior before PR:

We are unable to change the UoM to use in a sale.order.line within the method read_converted.

Desired behavior after PR is merged:

We are able to change the UoM to use in a sale.order.line within the method read_converted.


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@hugho-ad
Copy link
Collaborator

hugho-ad commented Nov 7, 2025

@JVegaB

mejora el commit, creo que para que lo mezclen, deberiamos abogar de que el metodo debe ser inheritance friendly
o algo asi

- Addded method `get_product_uom` to the `sale.order.line` model.
- Method `read_converted` now uses `get_product_uom`.

This improves the quality of the method `read_converted`, being able
to specify a UoM instead of always depending of same product field.
@JVegaB JVegaB force-pushed the 18.0-JVegaB-94093 branch from 924188d to 5818ae1 Compare November 7, 2025 14:24
def _get_sale_order_fields(self):
return ["product_id", "display_name", "price_unit", "product_uom_qty", "tax_id", "qty_delivered", "qty_invoiced", "discount", "qty_to_invoice", "price_total", "is_downpayment"]

def get_product_uom(self):

Choose a reason for hiding this comment

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

  • Make it private
  • Maybe a more specific name to avoid colliding with other modules, something like _get_product_uom_pos

If this patch is not accepted, you could implement a workaround in Ventacero like:

def read_converted(self):
    products_with_conversion = self.product_id.filtered("uom_conversion_id")
    original_uoms = products_with_conversion.read(["uom_id"])
    for product in products_with_conversion:
        product._cache["uom_id"] = product.uom_conversion_id.id
    res = super().read_converted()
    for product, uom in zip(products_with_conversion, original_uoms):
        product._cache["uom_id"] = uom["uom_id"][0]
    return res

That way, this patch wouldn't be required.

Copy link
Author

Choose a reason for hiding this comment

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

1.- It cannot be private, it belongs to sale.order.line, and called in sale.order (Also I will kept the name as it is).
2.- So should I close this PR or not?

Choose a reason for hiding this comment

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

  1. Yes it can, private methods can't be used from RPC but they can be used from other models.
  2. Create the PR to Odoo with the suggested method name and use the suggested workaround in Ventacero. If the PR is accepted, we can remove the workaround.

The suggested method name is not a nitpick but to increase chances for it being accepted. If we use a bare-name method, I think it most likely will be rejected.

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.

3 participants