odoo/tutorials#1270
Created by Aditi Pawar (adpaw)
Blocked
- Merge method
- Review
-
CI
- ci/style: (runtime 5s)
- ci/tutorial: (runtime 133s)
- label
- odoo-dev:19.0-second-uom-adpaw
- head
- cc13eb605838334de80c63878809a0c5156b2057
| odoo/tutorials | |
|---|---|
| 19.0 | #1270 missing r+ |
| master |
19.0 second uom adpaw
Introduce a new feature in the Point of Sale that allows cashiers to input quantities using a secondary Unit of Measure (UoM). This is specifically designed for products sold in larger units (e.g., Dozens) where the cashier needs a quick shortcut to enter sub-units (e.g., individual Units) without manually calculating decimals.
Currently, if a product is configured in a large UoM like "Dozens or kgs" a cashier wanting to sell 6 individual pieces or half kg etc, must manually calculate and type "0.5". This is prone to human error and slows down the checkout process. This module introduces a dedicated conversion shortcut to automate that calculation while maintaining the primary UoM on the order line.
Technical Decisions:
1. Schema: Added pos_second_uom_id and a computed pos_uom_reference_id to product.template to anchor units to their Category Roots.
2. Loader Integration: Appended the new field to _load_pos_data_fields to push metadata to the POS Reactive Store.
3. Data Integrity: Used an @api.onchange guard with relative_uom_id to auto-clear fields if the UoM Categories no longer match.
4. OWL: Patched ControlButtons.prototype with a Reactive Getter to show the button only when a secondary UoM exists.
5. Inherited from NumberPopup to create SecondUomPopup, preserving native keypad logic.
6. Conversion Logic: Applied the formula (enteredQty * secondUom.factor) / mainUom.factor within the JS action to sync the orderline.