[IMP] stock: Rewrite 'create_transit_location' in api.multi
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user