diff --git a/addons/stock/models/res_company.py b/addons/stock/models/res_company.py index 5308392de51..a310991cc17 100644 --- a/addons/stock/models/res_company.py +++ b/addons/stock/models/res_company.py @@ -12,7 +12,6 @@ class Company(models.Model): 'stock.location', 'Internal Transit Location', on_delete="restrict", help="Technical field used for resupply routes between warehouses that belong to this company") - @api.one def create_transit_location(self): '''Create a transit location with company_id being the given company_id. This is needed in case of resuply routes between warehouses belonging to the same company, because @@ -20,13 +19,14 @@ class Company(models.Model): ''' # TDE FIXME: called in data - should be done in init ?? parent_location = self.env.ref('stock.stock_location_locations', raise_if_not_found=False) - location = self.env['stock.location'].create({ - 'name': _('%s: Transit Location') % self.name, - 'usage': 'transit', - 'location_id': parent_location and parent_location.id or False, - }) - location.sudo().write({'company_id': self.id}) - self.write({'internal_transit_location_id': location.id}) + for company in self: + location = self.env['stock.location'].create({ + 'name': _('%s: Transit Location') % company.name, + 'usage': 'transit', + 'location_id': parent_location and parent_location.id or False, + }) + location.sudo().write({'company_id': company.id}) + company.write({'internal_transit_location_id': location.id}) @api.model def create(self, vals):