mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[9.0][IMP] stock_inventory_exclude_sublocaton: track visibility and only editable in draft state
This commit is contained in:
@@ -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'
|
||||
],
|
||||
|
||||
@@ -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,)
|
||||
|
||||
BIN
stock_inventory_exclude_sublocation/static/description/icon.png
Normal file
BIN
stock_inventory_exclude_sublocation/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user