[FIX] stock, mrp: handle multi method
Commit 84ae731d5d used 'self.code' in a method
called by a multi one. As 'self.code' expect a singleton, the transaction
raise an error in case of multiple records into the recordset
This commit calls the method into a loop on 'self and change its signature
to pass 'code' and be sure its a non multi one
This commit is contained in:
@@ -14,5 +14,4 @@ def _create_warehouse_data(cr, registry):
|
||||
"""
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
warehouse_ids = env['stock.warehouse'].search([('manufacture_pull_id', '=', False)])
|
||||
for warehouse_id in warehouse_ids:
|
||||
warehouse_id.write({'manufacture_to_resupply': True})
|
||||
warehouse_ids.write({'manufacture_to_resupply': True})
|
||||
|
||||
@@ -164,11 +164,11 @@ class StockWarehouse(models.Model):
|
||||
})
|
||||
return rules
|
||||
|
||||
def _get_locations_values(self, vals):
|
||||
values = super(StockWarehouse, self)._get_locations_values(vals)
|
||||
def _get_locations_values(self, vals, code=False):
|
||||
values = super(StockWarehouse, self)._get_locations_values(vals, code=code)
|
||||
def_values = self.default_get(['manufacture_steps'])
|
||||
manufacture_steps = vals.get('manufacture_steps', def_values['manufacture_steps'])
|
||||
code = vals.get('code') or self.code
|
||||
code = vals.get('code') or code
|
||||
code = code.replace(' ', '').upper()
|
||||
values.update({
|
||||
'pbm_loc_id': {
|
||||
|
||||
@@ -492,12 +492,12 @@ class Warehouse(models.Model):
|
||||
else:
|
||||
existing_rule.write({'active': True})
|
||||
|
||||
def _get_locations_values(self, vals):
|
||||
def _get_locations_values(self, vals, code=False):
|
||||
""" Update the warehouse locations. """
|
||||
def_values = self.default_get(['reception_steps', 'delivery_steps'])
|
||||
reception_steps = vals.get('reception_steps', def_values['reception_steps'])
|
||||
delivery_steps = vals.get('delivery_steps', def_values['delivery_steps'])
|
||||
code = vals.get('code') or self.code
|
||||
code = vals.get('code') or code
|
||||
code = code.replace(' ', '').upper()
|
||||
sub_locations = {
|
||||
'lot_stock_id': {
|
||||
@@ -539,8 +539,8 @@ class Warehouse(models.Model):
|
||||
In this case, this function will create missing locations in order to
|
||||
avoid mistakes during picking types and rules creation.
|
||||
"""
|
||||
sub_locations = self._get_locations_values(vals)
|
||||
for warehouse in self:
|
||||
sub_locations = self._get_locations_values(vals, warehouse.code)
|
||||
missing_location = {}
|
||||
for location, location_values in sub_locations.items():
|
||||
if not warehouse[location] and location not in vals:
|
||||
|
||||
Reference in New Issue
Block a user