[IMP] stock: Rewrite 'create_transit_location' in api.multi

This commit is contained in:
Yannick Tivisse
2017-11-16 14:49:05 +01:00
parent 16a2f91832
commit f7dcabf9f0
+8 -8
View File
@@ -12,7 +12,6 @@ class Company(models.Model):
'stock.location', 'Internal Transit Location', on_delete="restrict", 'stock.location', 'Internal Transit Location', on_delete="restrict",
help="Technical field used for resupply routes between warehouses that belong to this company") help="Technical field used for resupply routes between warehouses that belong to this company")
@api.one
def create_transit_location(self): def create_transit_location(self):
'''Create a transit location with company_id being the given company_id. This is needed '''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 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 ?? # TDE FIXME: called in data - should be done in init ??
parent_location = self.env.ref('stock.stock_location_locations', raise_if_not_found=False) parent_location = self.env.ref('stock.stock_location_locations', raise_if_not_found=False)
location = self.env['stock.location'].create({ for company in self:
'name': _('%s: Transit Location') % self.name, location = self.env['stock.location'].create({
'usage': 'transit', 'name': _('%s: Transit Location') % company.name,
'location_id': parent_location and parent_location.id or False, '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}) location.sudo().write({'company_id': company.id})
company.write({'internal_transit_location_id': location.id})
@api.model @api.model
def create(self, vals): def create(self, vals):