[FIX] stock, mrp: _get_similar_move_lines

try to make it work actually.
This commit is contained in:
Simon Lejeune
2017-09-26 16:12:16 +02:00
parent 0f24652b29
commit 096a39b3e9
2 changed files with 10 additions and 6 deletions
+7 -4
View File
@@ -20,11 +20,14 @@ class StockMoveLine(models.Model):
def _get_similar_move_lines(self):
lines = super(StockMoveLine, self)._get_similar_move_lines()
if self.move_id.production_id:
lines |= self.move_id.production_id.move_finished_ids.mapped('move_line_ids').filtered(lambda l: l.lot_id)
finished_moves = self.move_id.production_id.move_finished_ids
finished_move_lines = finished_moves.mapped('move_line_ids')
lines |= finished_move_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name))
if self.move_id.raw_material_production_id:
lines |= self.move_id.raw_material_production_id.move_raw_ids.mapped('move_line_ids').filtered(lambda l: l.lot_id)
if self.workorder_id:
lines |= self.workorder_id.active_move_line_ids
raw_moves = self.move_id.raw_material_production_id.move_raw_ids
raw_moves_lines = raw_moves.mapped('move_line_ids')
raw_moves_lines |= self.move_id.active_move_line_ids
lines |= raw_moves_lines.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name))
return lines
@api.multi
+3 -2
View File
@@ -128,8 +128,9 @@ class StockMoveLine(models.Model):
def _get_similar_move_lines(self):
self.ensure_one()
lines = self.env['stock.move.line']
if self.move_id.picking_id:
lines |= self.move_id.picking_id.move_line_ids.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name))
picking_id = self.move_id.picking_id if self.move_id else self.picking_id
if picking_id:
lines |= picking_id.move_line_ids.filtered(lambda ml: ml.product_id == self.product_id and (ml.lot_id or ml.lot_name))
return lines
def _check_for_duplicated_serial_numbers(self):