diff --git a/stock_inventory_exclude_sublocation/__openerp__.py b/stock_inventory_exclude_sublocation/__openerp__.py index a6ba8022d..3774ab76d 100644 --- a/stock_inventory_exclude_sublocation/__openerp__.py +++ b/stock_inventory_exclude_sublocation/__openerp__.py @@ -6,12 +6,12 @@ "name": "Stock Inventory Exclude Sublocation", "summary": "Allow to perform inventories of a location without including " "its child locations.", - "version": "9.0.1.0.0", + "version": "9.0.1.0.1", "author": "Eficent," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/stock-logistics-warehouse", "category": "Warehouse Management", - "depends": ["stock"], + "depends": ["stock", "stock_inventory_chatter"], "data": [ 'views/stock_inventory_view.xml' ], diff --git a/stock_inventory_exclude_sublocation/models/stock_inventory.py b/stock_inventory_exclude_sublocation/models/stock_inventory.py index 8421ce802..99e15b2e4 100644 --- a/stock_inventory_exclude_sublocation/models/stock_inventory.py +++ b/stock_inventory_exclude_sublocation/models/stock_inventory.py @@ -3,21 +3,26 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from openerp import fields, models, api +from openerp import api, fields, models class StockInventory(models.Model): _inherit = 'stock.inventory' - exclude_sublocation = fields.Boolean(string='Exclude Sublocations', - default=False) + exclude_sublocation = fields.Boolean( + string='Exclude Sublocations', default=False, + track_visibility='onchange', readonly=True, + states={'draft': [('readonly', False)]}) @api.model def _get_inventory_lines(self, inventory): if inventory.exclude_sublocation: product_obj = self.env['product.product'] domain = ' location_id = %s' - args = (tuple(inventory.location_id.ids)) + args = (tuple(inventory.location_id.ids),) + if inventory.company_id.id: + domain += ' and company_id = %s' + args += (inventory.company_id.id,) if inventory.partner_id: domain += ' and owner_id = %s' args += (inventory.partner_id.id,) diff --git a/stock_inventory_exclude_sublocation/static/description/icon.png b/stock_inventory_exclude_sublocation/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/stock_inventory_exclude_sublocation/static/description/icon.png differ diff --git a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py index 8913dba79..bc9bbfc60 100644 --- a/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py +++ b/stock_inventory_exclude_sublocation/tests/test_exclude_sublocation.py @@ -3,10 +3,10 @@ # (http://www.eficent.com) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -import openerp.tests.common as common +from openerp.tests.common import TransactionCase -class TestStockInventoryExcludeSublocation(common.TransactionCase): +class TestStockInventoryExcludeSublocation(TransactionCase): def setUp(self): super(TestStockInventoryExcludeSublocation, self).setUp() @@ -100,8 +100,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): return inventory def test_not_excluding_sublocations(self): - '''Check if products in sublocations are included into the inventory - if the excluding sublocations option is disabled.''' + """Check if products in sublocations are included into the inventory + if the excluding sublocations option is disabled.""" inventory_location = self._create_inventory_all_products( 'location inventory', self.location, False) inventory_location.prepare_inventory() @@ -111,8 +111,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'included') def test_excluding_sublocations(self): - '''Check if products in sublocations are not included if the exclude - sublocations is enabled.''' + """Check if products in sublocations are not included if the exclude + sublocations is enabled.""" inventory_location = self._create_inventory_all_products( 'location inventory', self.location, True) inventory_sublocation = self._create_inventory_all_products( @@ -129,7 +129,7 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'The products in the sublocations are not excluded') def test_lot_excluding_sublocation(self): - '''Check if the sublocations are excluded when using lots.''' + """Check if the sublocations are excluded when using lots.""" inventory = self.inventory_model.sudo(self.user.id).create({ 'name': 'Inventory lot', 'filter': 'lot', @@ -144,8 +144,8 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'not excluded with lots.') def test_product_and_owner_excluding_sublocation(self): - '''Check if sublocations are excluded when filtering by owner and - product.''' + """Check if sublocations are excluded when filtering by owner and + product.""" self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id, @@ -167,7 +167,7 @@ class TestStockInventoryExcludeSublocation(common.TransactionCase): 'not excluded with product and owner filter.') def test_pack_excluding_sublocation(self): - '''Check if sublocations are excluded when filtering by package.''' + """Check if sublocations are excluded when filtering by package.""" self.quant_model.create({ 'product_id': self.product1.id, 'location_id': self.location.id,