mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_location_lockdown from v9 to v10
Improve README
This commit is contained in:
committed by
Florian da Costa
parent
3117a08439
commit
f1ae654e42
@@ -4,18 +4,14 @@
|
||||
|
||||
{
|
||||
"name": "Stock Location Lockdown",
|
||||
"summary": "Prevent to add stock in flag locations",
|
||||
"summary": "Prevent to add stock on flagged locations",
|
||||
"author": "Akretion, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
"category": "Warehouse",
|
||||
"version": "9.0.1.0.0",
|
||||
"version": "10.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"application": False,
|
||||
"installable": True,
|
||||
"depends": [
|
||||
"stock",
|
||||
],
|
||||
"data": [
|
||||
"views/stock_location.xml",
|
||||
]
|
||||
"depends": ["stock"],
|
||||
"data": ["views/stock_location.xml"],
|
||||
}
|
||||
@@ -2,12 +2,13 @@
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import fields, models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
|
||||
block_stock_entrance = fields.Boolean(
|
||||
help="if this box is checked, put stock in this location won't be "
|
||||
"allowed. Usually used for virtual location, which has children")
|
||||
help="if this box is checked, putting stock on this location won't be "
|
||||
"allowed. Usually used for a virtual location that has "
|
||||
"childrens.")
|
||||
|
||||
@@ -2,18 +2,25 @@
|
||||
# Copyright 2018 Akretion
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import api, models, _
|
||||
from openerp.exceptions import UserError
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class StockQuant(models.Model):
|
||||
_inherit = 'stock.quant'
|
||||
|
||||
@api.model
|
||||
def _check_location(self, location):
|
||||
res = super(StockQuant, self)._check_location(location)
|
||||
if location.block_stock_entrance:
|
||||
raise UserError(
|
||||
_('The location %s is not configured to receive stock.')
|
||||
% (location.name))
|
||||
return res
|
||||
def quants_move(
|
||||
self, quants, move, location_to, location_from=False, lot_id=False,
|
||||
owner_id=False, src_package_id=False, dest_package_id=False,
|
||||
entire_pack=False):
|
||||
if (
|
||||
location_to.usage == 'internal' and
|
||||
location_to.block_stock_entrance):
|
||||
raise UserError(_(
|
||||
"The location '%s' is not configured to receive stock.")
|
||||
% location_to.display_name)
|
||||
return super(StockQuant, self).quants_move(
|
||||
quants, move, location_to, location_from=location_from,
|
||||
lot_id=lot_id, owner_id=owner_id, src_package_id=src_package_id,
|
||||
dest_package_id=dest_package_id, entire_pack=entire_pack)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
The aims of this module is to mark locations where no product should transit.
|
||||
Indeed, in complex warehouse environment, we may have a complicated tree of locations with a lot of virtual ones, used to create the hierarchy of the locations.
|
||||
We might want to avoid to put stock in these locations since they are not physical locations, they just represent a zone of the warehouse.
|
||||
For these location, the usage should be internal as it belongs to a warehouse, so the usage 'view' can't be used for these purpose.
|
||||
The aim of this module is to mark internal locations where no product should transit.
|
||||
Indeed, in complex warehouse setups, we may have a complicated tree of internal locations with parent locations only used to create the hierarchy of the internal locations.
|
||||
We may want to avoid to put stock on these parent internal locations since they are not physical locations, they just represent a zone of the warehouse.
|
||||
Theses locations must have *Location Type* set to *Internal Location* because they belong to a warehouse (they can't be configured with *Location Type* set to *View*, cf `Odoo bug #26679 <https://github.com/odoo/odoo/issues/26679>`_). With this module, you will be able to enable a new option *Block stock entrance* for these locations.
|
||||
|
||||
@@ -1 +1 @@
|
||||
* Once the module is installed, goes to any location for which you want to prevent stock entrance and check the box "Block Stock Entrance". Then, you won't be allow to add stock in these locations.
|
||||
* Once the module is installed, select any internal location for which you want to prevent stock entrance and check the box *Block Stock Entrance*. Then, you won't be allow to add stock on these locations.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
|
||||
# Copyright 2018 Akretion France
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp.exceptions import UserError
|
||||
from openerp.tests.common import TransactionCase
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestStockLocationLockdown(TransactionCase):
|
||||
@@ -13,7 +13,7 @@ class TestStockLocationLockdown(TransactionCase):
|
||||
self.main_stock_location = self.env.ref('stock.stock_location_stock')
|
||||
self.main_stock_location.block_stock_entrance = True
|
||||
self.supplier_location = self.env.ref('stock.stock_location_suppliers')
|
||||
self.product = self.env.ref('product.product_product_35')
|
||||
self.product = self.env.ref('product.product_product_27')
|
||||
|
||||
def test_transfer_stock_in_locked_location(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user