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.move
Compute Method: _compute_quantity
| Inputs | Method | Outputs |
|---|---|---|
|
""" This field represents the sum of the move lines `quantity`. It allows the user to know
if there is still work to do.
We take care of rounding this value at the general decimal precision and not the rounding
of the move's UOM to make sure this value is really close to the real sum, because this
field will be used in `_action_done` in order to know if the move will need a backorder or
an extra move.
"""
if not any(self._ids):
# onchange
for move in self:
move.quantity = move._quantity_sml()
else:
# compute
move_lines_ids = set()
for move in self:
move_lines_ids |= set(move.move_line_ids.ids)
data = self.env['stock.move.line']._read_group(
[('id', 'in', list(move_lines_ids))],
- ['move_id', 'product_uom_id'], ['quantity:sum']
+ ['move_id', 'uom_id'], ['quantity:sum']
)
sum_qty = defaultdict(float)
- for move, product_uom, qty_sum in data:
- uom = move.product_uom
- sum_qty[move.id] += product_uom._compute_quantity(qty_sum, uom, round=False)
+ for move, uom_id, qty_sum in data:
+ uom = move.uom_id
+ sum_qty[move.id] += uom_id._compute_quantity(qty_sum, uom, round=False)
for move in self:
move.quantity = sum_qty[move.id]
|
|
