Skip to content
Snippets Groups Projects
Commit c6651428 authored by paso-odoo's avatar paso-odoo
Browse files

[FIX] mrp: create production location when type is not production

If the user change a location type of the 'Production' from inventory locations
and installs the 'MRP' module, the traceback will appear.

Steps to produce:
- Install Stock module.
- Inventory > Configuration > Settings > enable the Storage Locations.
- Inventory > Configuration > Locations > Remove the filter 'Internal'.
- Open the 'Production' location and change the Location Type to 'View'.
- Now install the 'Manufacturing' module.
Error: A traceback appears: 'ParseError: while parsing
/home/odoo/src/odoo/saas-16.2/addons/mrp/data/mrp_data.xml:17, somewhere inside'

At the time of installing the MRP module, it will search for the production
location using the location type as the production here - https://github.com/odoo/odoo/blob/f65a9bffe2cbc03b2efc969dc205c9ba01ee9ab5/addons/mrp/models/stock_warehouse.py#L65


If the production location is not found it will raise an userError. In this
commit, the production location is created based on the company if not found. It
will lead to the above traceback.

sentry-4215564628

closes odoo/odoo#125885

X-original-commit: e8ce51dd
Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
Signed-off-by: default avatarParth Solanki (paso) <paso@odoo.com>
parent cbe2a78a
No related branches found
No related tags found
No related merge requests found
......@@ -274,6 +274,13 @@ class StockWarehouse(models.Model):
})
return data
def _create_missing_locations(self, vals):
super()._create_missing_locations(vals)
for company_id in self.company_id:
location = self.env['stock.location'].search([('usage', '=', 'production'), ('company_id', '=', company_id.id)], limit=1)
if not location:
company_id._create_production_location()
def write(self, vals):
if any(field in vals for field in ('manufacture_steps', 'manufacture_to_resupply')):
for warehouse in self:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment