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.quant

Compute Method: _compute_sn_duplicated

View 17.0 View 19.0
Inputs Method Outputs
  • lot_id
  • lot_id.ids
self.sn_duplicated = False
- domain = [('tracking', '=', 'serial'), ('lot_id', 'in', self.lot_id.ids), ('location_id.usage', 'in', ['internal', 'transit'])]
+ domain = [('tracking', '=', 'serial'), ('lot_id', 'in', self.lot_id.ids), ('quantity', '>', 0), ('location_id.usage', 'in', ['internal', 'transit'])]
results = self._read_group(domain, ['lot_id'], having=[('__count', '>', 1)])
duplicated_sn_ids = [lot.id for [lot] in results]
quants_with_duplicated_sn = self.env['stock.quant'].search([('lot_id', 'in', duplicated_sn_ids)])
quants_with_duplicated_sn.sn_duplicated = True
  • sn_duplicated

Back to entity