[FIX] stock: correctly trigger loc warehouse compute

Commit [1] made it so the computed stock_location.warehouse_id field is
stored. Unfortunately it did not correctly add the additional depends
value of `location_id` so when this value is changed after the record
has been initially created+saved without a location_id, the warehouse
will never be correctly computed.

[1] https://github.com/odoo/odoo/commit/9978bcb366d0ea48ed25a7891e0c7653a2f96bfb

Followup to task: 2882539

closes odoo/odoo#100219

Related: odoo/upgrade#3901
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
This commit is contained in:
Tiffany Chang (tic)
2022-09-16 14:25:35 +02:00
parent 6d28c9c2e5
commit 02ad90ee75
+1 -1
View File
@@ -146,7 +146,7 @@ class Location(models.Model):
else:
location.next_inventory_date = False
@api.depends('warehouse_view_ids')
@api.depends('warehouse_view_ids', 'location_id')
def _compute_warehouse_id(self):
warehouses = self.env['stock.warehouse'].search([('view_location_id', 'parent_of', self.ids)])
view_by_wh = OrderedDict((wh.view_location_id.id, wh.id) for wh in warehouses)