[IMP] pos_sale: read_converted now uses method to get lines UoM#638
Open
JVegaB wants to merge 1 commit intoVauxoo:18.0from
Open
[IMP] pos_sale: read_converted now uses method to get lines UoM#638JVegaB wants to merge 1 commit intoVauxoo:18.0from
JVegaB wants to merge 1 commit intoVauxoo:18.0from
Conversation
Collaborator
|
mejora el commit, creo que para que lo mezclen, deberiamos abogar de que el metodo debe ser inheritance friendly |
- 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.
924188d to
5818ae1
Compare
luisg123v
reviewed
Nov 11, 2025
| 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): |
There was a problem hiding this comment.
- 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.
Author
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
- Yes it can, private methods can't be used from RPC but they can be used from other models.
- 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.
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.
get_product_uomto thesale.order.linemodel.read_convertednow usesget_product_uom.Description of the issue/feature this PR addresses:
The current method
read_converteddoes not offers a way to change the UoM to use in asale.order.line.Current behavior before PR:
We are unable to change the UoM to use in a
sale.order.linewithin the methodread_converted.Desired behavior after PR is merged:
We are able to change the UoM to use in a
sale.order.linewithin the methodread_converted.I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr