OdooWiki OCA HUB

Product packaging calculator

product_packaging_calculator folder_open OCA/product-attribute open_in_new
Product License: LGPL-3

Basic module providing an helper method to calculate the quantity of product by packaging.

auto_awesome What this module does

AI-generated from the code · Odoo 18.0

This module adds a helper that converts a total product quantity into a readable breakdown by packaging (pallets, boxes, units). It is a technical building block used by other modules to show or compute quantities by packaging.

This module does not add menus or screens by itself. It provides calculation logic on product.product and a reusable mixin product.qty_by_packaging.mixin that other modules can inherit to display a "Qty by packaging" text field.

What it does: - For a given total quantity of a product, it calculates how many of each packaging are needed, starting from the largest packaging down to the smallest, and finally the product's unit of measure. - It can also show what each packaging contains (for example, 1 pallet contains 4 big boxes and 6 little boxes) when the "with contained" option is used. - It can return the result as a text string such as "2 Pallets, 3 Boxes, 5 Units", optionally including the total in units.

Business rules shown in the code: - Packagings with zero quantity are ignored. - Fractional quantities are lost; the smallest quantity is always expressed in the product's unit of measure. - The calculation can be filtered or customized through context values, but no user interface is provided here.

The module also includes an installation hook to move existing data from the older stock_packaging_calculator module if it was installed.

Depends on

product
Models and fields (2)
  • product.product · extends an existing model
  • product.qty_by_packaging.mixin · new modelproduct_qty_by_packaging_display (Qty by packaging)

Text generated by AI (DeepSeek) from reading the Odoo 18.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub

Availability by version

Reviewed: 2026-11-03
Confirmed (verified in repository and branch) Estimated (unverified) No information

Confirmation status: 1 confirmed, 8 with no information of 9 versions.

Sources · Odoo 18.0

Confirmed on 2026-11-03 in branch 18.0 of OCA/product-attribute.

terminal Installation and usage

OCA documentation · Odoo 18.0

Imagine you have the following packagings:

  • Pallet: 1000 Units
  • Big box: 500 Units
  • Box: 50 Units

and you have to pick from your warehouse 2860 Units.

Then you can do:

> ``> >>> product.product_qty_by_packaging(2860) > > [ > {"id": 1, "qty": 2, "name": "Pallet"}, > {"id": 2, "qty": 1, "name": "Big box"}, > {"id": 3, "qty": 7, "name": "Box"}, > {"id": 100, "qty": 10, "name": "Units"}, > ] >``

With this you can show a proper message to warehouse operators to quickly pick the quantity they need.

Optionally you can get contained packaging by passing with_contained flag:

> ``> >>> product.product_qty_by_packaging(2860, with_contained=True) > > [ > {"id": 1, "qty": 2, "name": "Pallet", "contained": [{"id": 2, "qty": 2, "name": "Big box"}]}, > {"id": 2, "qty": 1, "name": "Big box", "contained": [{"id": 3, "qty": 10, "name": "Box"}]}, > {"id": 3, "qty": 7, "name": "Box", "contained": [{"id": 100, "qty": 50, "name": "Units"}]}, > {"id": 100, "qty": 10, "name": "Units", "contained": []},}, > ] >``

No verified information in OCA: Installation, Configuration.

info

Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.