Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion addons/pos_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ def _compute_qty_invoiced(self):
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.

return self.product_id.uom_id

def read_converted(self):
field_names = self._get_sale_order_fields()
results = []
for sale_line in self:
if sale_line.product_type or (sale_line.is_downpayment and sale_line.price_unit != 0):
product_uom = sale_line.product_id.uom_id
product_uom = sale_line.get_product_uom()
sale_line_uom = sale_line.product_uom
item = sale_line.read(field_names, load=False)[0]
if sale_line.product_id.tracking != 'none':
Expand Down