diff --git a/addons/mrp/wizard/mrp_product_produce.py b/addons/mrp/wizard/mrp_product_produce.py index 6c15772fdab..617e5f012f9 100644 --- a/addons/mrp/wizard/mrp_product_produce.py +++ b/addons/mrp/wizard/mrp_product_produce.py @@ -193,9 +193,8 @@ class MrpProductProduceLine(models.TransientModel): def _check_for_duplicated_serial_numbers(self): if self.mapped('lot_id'): - lot_names = [ml.lot_id.name for ml in self] - recorded_serials_counter = Counter(lot_names) - for lot_id, occurrences in recorded_serials_counter.items(): + lots_map = [(ml.product_id.id, ml.lot_id.name) for ml in self] + recorded_serials_counter = Counter(lots_map) + for (product_id, lot_id), occurrences in recorded_serials_counter.items(): if occurrences > 1 and lot_id is not False: - return _( - 'You cannot consume the same serial number twice. Please correct the serial numbers encoded.') + return _('You cannot consume the same serial number twice. Please correct the serial numbers encoded.') diff --git a/addons/stock/models/stock_move_line.py b/addons/stock/models/stock_move_line.py index 75a4d960d01..ab164d8a656 100644 --- a/addons/stock/models/stock_move_line.py +++ b/addons/stock/models/stock_move_line.py @@ -140,16 +140,17 @@ class StockMoveLine(models.Model): :return: an error message directed to the user if needed else False """ if self.mapped('lot_id'): - lot_names = [ml.lot_id.name for ml in self] - recorded_serials_counter = Counter(lot_names) - for lot_id, occurrences in recorded_serials_counter.items(): + lots_map = [(ml.product_id.id, ml.lot_id.name) for ml in self] + recorded_serials_counter = Counter(lots_map) + for (product_id, lot_id), occurrences in recorded_serials_counter.items(): if occurrences > 1 and lot_id is not False: - return _('You cannot consume the same serial number twice. Please correct the serial numbers encoded.') + return _('You cannot use the same serial number twice. Please correct the serial numbers encoded.') elif self.mapped('lot_name'): - recorded_serials_counter = Counter(self.mapped('lot_name')) - for lot_id, occurrences in recorded_serials_counter.items(): + lots_map = [(ml.product_id.id, ml.lot_name) for ml in self] + recorded_serials_counter = Counter(lots_map) + for (product_id, lot_id), occurrences in recorded_serials_counter.items(): if occurrences > 1 and lot_id is not False: - return _('You cannot consume the same serial number twice. Please correct the serial numbers encoded.') + return _('You cannot use the same serial number twice. Please correct the serial numbers encoded.') return False @api.model