diff --git a/stock_inventory/__manifest__.py b/stock_inventory/__manifest__.py index 1a6c25678e70..2196e5426380 100644 --- a/stock_inventory/__manifest__.py +++ b/stock_inventory/__manifest__.py @@ -1,6 +1,6 @@ { "name": "Stock Inventory Adjustment", - "version": "16.0.2.3.0", + "version": "17.0.1.0.0", "license": "LGPL-3", "maintainer": ["DavidJForgeFlow"], "development_status": "Beta", diff --git a/stock_inventory/models/stock_inventory.py b/stock_inventory/models/stock_inventory.py index 72f8e449699b..113f8c9de8cc 100644 --- a/stock_inventory/models/stock_inventory.py +++ b/stock_inventory/models/stock_inventory.py @@ -2,10 +2,6 @@ from odoo.exceptions import UserError, ValidationError from odoo.osv import expression -READONLY_STATES = { - "draft": [("readonly", False)], -} - class InventoryAdjustmentsGroup(models.Model): _name = "stock.inventory" @@ -20,20 +16,17 @@ class InventoryAdjustmentsGroup(models.Model): default="Inventory", string="Inventory Reference", readonly=True, - states=READONLY_STATES, ) date = fields.Datetime( default=lambda self: fields.Datetime.now(), readonly=True, - states=READONLY_STATES, ) company_id = fields.Many2one( comodel_name="res.company", readonly=True, index=True, - states={"draft": [("readonly", False)]}, default=lambda self: self.env.company, required=True, ) @@ -54,7 +47,6 @@ class InventoryAdjustmentsGroup(models.Model): "Owner", help="This is the owner of the inventory adjustment", readonly=True, - states=READONLY_STATES, ) location_ids = fields.Many2many( @@ -63,7 +55,6 @@ class InventoryAdjustmentsGroup(models.Model): domain="[('usage', '=', 'internal'), " "'|', ('company_id', '=', company_id), ('company_id', '=', False)]", readonly=True, - states=READONLY_STATES, ) product_selection = fields.Selection( @@ -77,7 +68,6 @@ class InventoryAdjustmentsGroup(models.Model): default="all", required=True, readonly=True, - states=READONLY_STATES, ) product_ids = fields.Many2many( @@ -85,7 +75,6 @@ class InventoryAdjustmentsGroup(models.Model): string="Products", domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]", readonly=True, - states=READONLY_STATES, ) stock_quant_ids = fields.Many2many( @@ -93,14 +82,12 @@ class InventoryAdjustmentsGroup(models.Model): string="Inventory Adjustment", domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]", readonly=True, - states=READONLY_STATES, ) category_id = fields.Many2one( "product.category", string="Product Category", readonly=True, - states=READONLY_STATES, ) lot_ids = fields.Many2many( @@ -108,7 +95,6 @@ class InventoryAdjustmentsGroup(models.Model): string="Lot/Serial Numbers", domain="['|', ('company_id', '=', company_id), ('company_id', '=', False)]", readonly=True, - states=READONLY_STATES, ) stock_move_ids = fields.One2many( @@ -116,7 +102,6 @@ class InventoryAdjustmentsGroup(models.Model): "inventory_adjustment_id", string="Inventory Adjustments Done", readonly=True, - states=READONLY_STATES, ) count_stock_quants = fields.Integer( @@ -276,7 +261,8 @@ def action_state_to_in_progress(self): else: error_field = "location_id" error_message = _( - "There's already an Adjustment in Process using one requested Location: %s" + "There's already an Adjustment in Process using one " + "requested Location: %s" ) quants = self.env["stock.quant"].search(search_filter) @@ -407,8 +393,9 @@ def _check_inventory_in_progress_not_override(self): ): raise ValidationError( _( - "Cannot have more than one in-progress inventory adjustment " - "affecting the same location or product at the same time." + "Cannot have more than one in-progress inventory " + "adjustment affecting the same location or product " + "at the same time." ) ) diff --git a/stock_inventory/models/stock_quant.py b/stock_inventory/models/stock_quant.py index d9d46a67dcd6..ba8b4afe4044 100644 --- a/stock_inventory/models/stock_quant.py +++ b/stock_inventory/models/stock_quant.py @@ -15,7 +15,7 @@ def _apply_inventory(self): self.env["stock.inventory"] .search([("state", "=", "in_progress")]) .filtered( - lambda x: rec.location_id in x.location_ids + lambda x, rec=rec: rec.location_id in x.location_ids or ( rec.location_id in x.location_ids.child_internal_location_ids and not x.exclude_sublocation @@ -32,7 +32,7 @@ def _apply_inventory(self): ], order="create_date asc", ).filtered( - lambda x: not x.company_id.id + lambda x, rec=rec: not x.company_id.id or not rec.company_id.id or rec.company_id.id == x.company_id.id ) diff --git a/stock_inventory/tests/test_stock_inventory.py b/stock_inventory/tests/test_stock_inventory.py index 2288aa50da66..a662b3fb6998 100644 --- a/stock_inventory/tests/test_stock_inventory.py +++ b/stock_inventory/tests/test_stock_inventory.py @@ -7,7 +7,7 @@ class TestStockInventory(TransactionCase): def setUp(self): - super(TestStockInventory, self).setUp() + super().setUp() self.env.company.stock_inventory_auto_complete = False self.quant_model = self.env["stock.quant"] self.move_model = self.env["stock.move.line"] @@ -142,7 +142,7 @@ def test_01_all_locations(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 3) self.assertEqual(inventory1.count_stock_quants_string, "2 / 3") - self.assertEqual(inventory1.stock_move_ids.qty_done, 8) + self.assertEqual(inventory1.stock_move_ids.quantity, 8) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_1.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location1.id) @@ -176,7 +176,7 @@ def test_02_manual_selection(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 2) self.assertEqual(inventory1.count_stock_quants_string, "1 / 2") - self.assertEqual(inventory1.stock_move_ids.qty_done, 26) + self.assertEqual(inventory1.stock_move_ids.quantity, 26) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id) @@ -226,7 +226,7 @@ def test_03_one_selection(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 2) self.assertEqual(inventory1.count_stock_quants_string, "1 / 2") - self.assertEqual(inventory1.stock_move_ids.qty_done, 26) + self.assertEqual(inventory1.stock_move_ids.quantity, 26) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id) @@ -276,7 +276,7 @@ def test_04_lot_selection(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 1) self.assertEqual(inventory1.count_stock_quants_string, "0 / 1") - self.assertEqual(inventory1.stock_move_ids.qty_done, 26) + self.assertEqual(inventory1.stock_move_ids.quantity, 26) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id) @@ -310,7 +310,7 @@ def test_05_category_selection(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 1) self.assertEqual(inventory1.count_stock_quants_string, "0 / 1") - self.assertEqual(inventory1.stock_move_ids.qty_done, 26) + self.assertEqual(inventory1.stock_move_ids.quantity, 26) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product2.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id) inventory1.action_state_to_done() @@ -354,7 +354,7 @@ def test_06_exclude_sub_locations(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 1) self.assertEqual(inventory1.count_stock_quants_string, "0 / 1") - self.assertEqual(inventory1.stock_move_ids.qty_done, 8) + self.assertEqual(inventory1.stock_move_ids.quantity, 8) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_1.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location1.id) @@ -399,7 +399,7 @@ def test_07_stock_inventory_auto_complete(self): self.assertEqual(inventory1.count_stock_moves, 1) self.assertEqual(inventory1.count_stock_quants, 2) self.assertEqual(inventory1.count_stock_quants_string, "1 / 2") - self.assertEqual(inventory1.stock_move_ids.qty_done, 26) + self.assertEqual(inventory1.stock_move_ids.quantity, 26) self.assertEqual(inventory1.stock_move_ids.product_id.id, self.product.id) self.assertEqual(inventory1.stock_move_ids.lot_id.id, self.lot_3.id) self.assertEqual(inventory1.stock_move_ids.location_id.id, self.location3.id) diff --git a/stock_inventory/views/res_config_settings_view.xml b/stock_inventory/views/res_config_settings_view.xml index 3ff8ec98778c..38ca715ee135 100644 --- a/stock_inventory/views/res_config_settings_view.xml +++ b/stock_inventory/views/res_config_settings_view.xml @@ -7,7 +7,7 @@ res.config.settings - +

Stock Inventory

diff --git a/stock_inventory/views/stock_inventory.xml b/stock_inventory/views/stock_inventory.xml index a4394b587530..759870233148 100644 --- a/stock_inventory/views/stock_inventory.xml +++ b/stock_inventory/views/stock_inventory.xml @@ -11,27 +11,27 @@ type="object" name="action_state_to_in_progress" class="oe_highlight" - attrs="{'invisible':[('state', 'in', ['in_progress', 'done'])]}" + invisible="state in ('in_progress', 'done')" string="Begin Adjustments" />