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: product.product
Compute Method: _compute_nbr_moves
| Inputs | Method | Outputs |
|---|---|---|
|
incoming_moves = self.env['stock.move.line']._read_group([
('product_id', 'in', self.ids),
('state', '=', 'done'),
- ('picking_code', '=', 'incoming'),
+ ('location_id.warehouse_id', '=', False),
+ ('location_dest_id.warehouse_id', '!=', False),
('date', '>=', fields.Datetime.now() - relativedelta(years=1))
], ['product_id'], ['__count'])
outgoing_moves = self.env['stock.move.line']._read_group([
('product_id', 'in', self.ids),
('state', '=', 'done'),
- ('picking_code', '=', 'outgoing'),
+ ('location_id.warehouse_id', '!=', False),
+ ('location_dest_id.warehouse_id', '=', False),
('date', '>=', fields.Datetime.now() - relativedelta(years=1))
], ['product_id'], ['__count'])
res_incoming = {product.id: count for product, count in incoming_moves}
res_outgoing = {product.id: count for product, count in outgoing_moves}
for product in self:
product.nbr_moves_in = res_incoming.get(product.id, 0)
product.nbr_moves_out = res_outgoing.get(product.id, 0)
|
|
