mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
in stock move instead of checks in quants. This will allow for a more robust lockdown, and still make it possible to perform inventory adjustments in the locked location. Also resolves an outstanding issue related to the previous design not allowing inventory adjustments where negative quants existed.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
# © 2013-2016 Numérigraphe SARL
|
|
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
|
# (http://www.eficent.com)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from openerp import models, api
|
|
|
|
|
|
class StockInventory(models.Model):
|
|
_inherit = 'stock.inventory'
|
|
|
|
@api.model
|
|
def _get_locations_open_inventories(self, locations_ids=None):
|
|
"""IDs of locations in open exhaustive inventories, with children"""
|
|
inventory_domain = [('state', '=', 'confirm')]
|
|
if locations_ids:
|
|
inventory_domain.append(('location_id', 'child_of', locations_ids))
|
|
inventories = self.search(inventory_domain)
|
|
if not inventories:
|
|
# Early exit if no match found
|
|
return []
|
|
location_ids = inventories.mapped('location_id')
|
|
|
|
# Extend to the children Locations
|
|
location_domain = [
|
|
('location_id', 'child_of', location_ids.ids),
|
|
('usage', 'in', ['internal', 'transit'])]
|
|
if locations_ids:
|
|
location_domain.append(('location_id', 'child_of', locations_ids))
|
|
return self.env['stock.location'].search(location_domain)
|