Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Inventory

Entity: stock.package

Compute Method: _compute_content_description

View 20.0
Inputs Method Outputs
  • contained_quant_ids
+ def format_content(qty, uom_name, product_name, display_uom):
+             quantity = str(int(qty) if qty == int(qty) else qty)
+             return " ".join([quantity, uom_name, product_name] if display_uom else [quantity, product_name])
+ display_uom = self.env.user.has_group('uom.group_uom')
+ for package in self:
+             package_content = package.contained_quant_ids.grouped(lambda q: (q.uom_id, q.product_id))
+             package_content = [(uom.name, product.display_name, sum(quants.mapped('quantity'))) for ((uom, product), quants) in package_content.items()]
+             package.content_description = format_list(self.env, [format_content(qty, uom_name, product_name, display_uom) for (uom_name, product_name, qty) in package_content])
  • content_description

Back to entity