[FIX] mrp: A traceback was raised when creating a warehouse

When creating a warehouse, a traceback was raised if the xml_id: mrp.route_warehouse0_manufacture
was not found.

opw:1852761
This commit is contained in:
Goffin Simon
2018-05-29 14:14:24 +02:00
parent b5ea61bf72
commit f349d2f3ab
+5 -5
View File
@@ -29,12 +29,12 @@ class StockWarehouse(models.Model):
return result
def _get_manufacture_route_id(self):
manufacture_route_id = self.env.ref('mrp.route_warehouse0_manufacture').id
if not manufacture_route_id:
manufacture_route_id = self.env['stock.location.route'].search([('name', 'like', _('Manufacture'))], limit=1).id
if not manufacture_route_id:
manufacture_route = self.env.ref('mrp.route_warehouse0_manufacture', raise_if_not_found=False)
if not manufacture_route:
manufacture_route = self.env['stock.location.route'].search([('name', 'like', _('Manufacture'))], limit=1)
if not manufacture_route:
raise exceptions.UserError(_('Can\'t find any generic Manufacture route.'))
return manufacture_route_id
return manufacture_route.id
def _get_manufacture_pull_rules_values(self, route_values):
if not self.manu_type_id: