diff --git a/addons/stock/data/stock_data.xml b/addons/stock/data/stock_data.xml
index e9bc83c9794..23eff682ad6 100644
--- a/addons/stock/data/stock_data.xml
+++ b/addons/stock/data/stock_data.xml
@@ -31,13 +31,6 @@
1
-
- Scrapped
-
- True
- inventory
-
-
Procurements
@@ -167,5 +160,8 @@
+
+
+
diff --git a/addons/stock/models/res_company.py b/addons/stock/models/res_company.py
index 37ba46bb10a..7955023918b 100644
--- a/addons/stock/models/res_company.py
+++ b/addons/stock/models/res_company.py
@@ -67,6 +67,17 @@ class Company(models.Model):
'value': 'stock.location,%d' % production_location.id,
})
+ def _create_scrap_location(self):
+ for company in self:
+ parent_location = self.env.ref('stock.stock_location_locations_virtual', raise_if_not_found=False)
+ scrap_location = self.env['stock.location'].create({
+ 'name': '%s: Scrap' % company.name,
+ 'usage': 'inventory',
+ 'location_id': parent_location.id,
+ 'company_id': company.id,
+ 'scrap_location': True,
+ })
+
@api.model
def create_missing_warehouse(self):
""" This hook is used to add a warehouse on existing companies
@@ -101,6 +112,14 @@ class Company(models.Model):
for company in company_without_property:
company._create_production_location()
+ @api.model
+ def create_missing_scrap_location(self):
+ company_ids = self.env['res.company'].search([])
+ companies_having_scrap_loc = self.env['stock.location'].search([('scrap_location', '=', True)]).mapped('company_id')
+ company_without_property = company_ids - companies_having_scrap_loc
+ for company in company_without_property:
+ company._create_scrap_location()
+
@api.model
def create(self, vals):
company = super(Company, self).create(vals)
@@ -108,5 +127,6 @@ class Company(models.Model):
company.create_transit_location()
company.sudo()._create_inventory_loss_location()
company.sudo()._create_production_location()
+ company.sudo()._create_scrap_location()
self.env['stock.warehouse'].sudo().create({'name': company.name, 'code': company.name[:5], 'company_id': company.id, 'partner_id': company.partner_id.id})
return company