diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 281e90047ee..9a6c17c136e 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1134,7 +1134,8 @@ class MrpProduction(models.Model): self.ensure_one() self.lot_producing_id = self.env['stock.production.lot'].create({ 'product_id': self.product_id.id, - 'company_id': self.company_id.id + 'company_id': self.company_id.id, + 'name': self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) or self.env['ir.sequence'].next_by_code('stock.lot.serial'), }) if self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids: self.move_finished_ids.filtered(lambda m: m.product_id == self.product_id).move_line_ids.lot_id = self.lot_producing_id @@ -1747,7 +1748,7 @@ class MrpProduction(models.Model): message += "\n".join(component.name for component in multiple_lot_components) if message: raise UserError(message) - next_serial = self.env['stock.production.lot'].get_next_serial(self.company_id, self.product_id) + next_serial = self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) action = self.env["ir.actions.actions"]._for_xml_id("mrp.act_assign_serial_numbers_production") action['context'] = { 'default_production_id': self.id, diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index 7741fe7e8e9..1bb5fe23c1c 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -649,7 +649,7 @@ class StockMove(models.Model): view = self.env.ref('stock.view_stock_move_nosuggest_operations') if self.product_id.tracking == "serial" and self.state == "assigned": - self.next_serial = self.env['stock.production.lot'].get_next_serial(self.company_id, self.product_id) + self.next_serial = self.env['stock.production.lot']._get_next_serial(self.company_id, self.product_id) return { 'name': _('Detailed Operations'), diff --git a/addons/stock/models/stock_production_lot.py b/addons/stock/models/stock_production_lot.py index 7e5e748b76d..f6364de6592 100644 --- a/addons/stock/models/stock_production_lot.py +++ b/addons/stock/models/stock_production_lot.py @@ -61,7 +61,7 @@ class ProductionLot(models.Model): return lot_names @api.model - def get_next_serial(self, company, product): + def _get_next_serial(self, company, product): """Return the next serial number to be attributed to the product.""" if product.tracking == "serial": last_serial = self.env['stock.production.lot'].search(