[11.0][MIG] stock_inventory_lockdown

This commit is contained in:
Lois Rilo
2018-09-12 16:52:42 +02:00
committed by Ben Stannard
parent 1479334b6b
commit 89e3ad6791
12 changed files with 88 additions and 61 deletions

View File

@@ -1,40 +1,65 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg ===================
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html Inventory Lock Down
:alt: License: AGPL-3 ===================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
:target: https://odoo-community.org/page/development-status
:alt: Mature
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github
:target: https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_inventory_lockdown
:alt: OCA/stock-logistics-warehouse
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/153/11.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4|
======================================
Lock down locations during inventories
======================================
This module lets you lock down the locations during an inventory. This module lets you lock down the locations during an inventory.
**Table of contents**
.. contents::
:local:
Usage Usage
===== =====
.. image:: stock_inventory_lockdown/static/images/move_error.png
:alt: Error message
While an inventory is in the state "In progress", no stock moves While an inventory is in the state "In progress", no stock moves
can be recorded in/out of the inventory's location: users will get an error can be recorded in/out of the inventory's location: users will get an error
message. message.
Creating or modifying locations is also forbidden. Creating or modifying locations is also forbidden.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: stock_inventory_lockdown/static/images/move_error.png
:alt: Try me on Runbot :alt: Error message
:target: https://runbot.odoo-community.org/runbot/153/10.0
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/issues>`_.
<https://github.com/OCA/stock-logistics-warehouse/issues>`_. In case of trouble, please In case of trouble, please check there if your issue has already been reported.
check there if your issue has already been reported. If you spotted it first, If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
help us smashing it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits Credits
======= =======
Authors
~~~~~~~
* Numérigraphe
* Eficent
Contributors Contributors
------------ ~~~~~~~~~~~~
* Loïc Bellier (Numérigraphe) <lb@numerigraphe.com> * Loïc Bellier (Numérigraphe) <lb@numerigraphe.com>
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com> * Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
@@ -43,18 +68,19 @@ Contributors
* Lois Rilo (Eficent) <lois.rilo@eficent.com> * Lois Rilo (Eficent) <lois.rilo@eficent.com>
* Jordi Ballester (Eficent) <jordi.ballester@eficent.com> * Jordi Ballester (Eficent) <jordi.ballester@eficent.com>
Maintainers
~~~~~~~~~~~
Maintainer This module is maintained by the OCA.
----------
.. image:: https://odoo-community.org/logo.png .. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association :alt: Odoo Community Association
:target: https://odoo-community.org :target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
To contribute to this module, please visit https://odoo-community.org. This module is part of the `OCA/stock-logistics-warehouse <https://github.com/OCA/stock-logistics-warehouse/tree/11.0/stock_inventory_lockdown>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models from . import models

View File

@@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Numérigraphe SARL # © 2013-2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
"name": "Inventory Lock Down", "name": "Inventory Lock Down",
"summary": "Lock down stock locations during inventories.", "summary": "Lock down stock locations during inventories.",
"version": "10.0.1.0.1", "version": "11.0.1.0.0",
"development_status": "Mature",
"depends": ["stock"], "depends": ["stock"],
"author": "Numérigraphe, Eficent, Odoo Community Association (OCA)", "author": "Numérigraphe, Eficent, Odoo Community Association (OCA)",
"category": "Warehouse Management", "category": "Warehouse Management",
"images": [ "images": [
"images/move_error.png", "images/move_error.png",
"images/location_locked.png"], "images/location_locked.png",
],
"license": "AGPL-3", "license": "AGPL-3",
"installable": True, "installable": True,
} }

View File

@@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import stock_move from . import stock_move
from . import stock_inventory from . import stock_inventory
from . import stock_location from . import stock_location

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Numérigraphe SARL # © 2013-2016 Numérigraphe SARL
# Copyright 2017 Eficent Business and IT Consulting Services S.L. # Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 Numérigraphe SARL # © 2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2016 Numérigraphe SARL # © 2016 Numérigraphe SARL
# Copyright 2017 Eficent Business and IT Consulting Services S.L. # Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)
@@ -14,14 +13,12 @@ class StockMove(models.Model):
@api.multi @api.multi
def _get_reserved_locations(self): def _get_reserved_locations(self):
self.ensure_one() self.ensure_one()
return self.reserved_quant_ids.mapped('location_id') + \ return self.move_line_ids.mapped('location_id')
self.split_from.reserved_quant_ids.mapped('location_id')
@api.multi @api.multi
def _get_dest_locations(self): def _get_dest_locations(self):
self.ensure_one() self.ensure_one()
return self.linked_move_operation_ids.mapped( return self.move_line_ids.mapped('location_dest_id')
'operation_id.location_dest_id')
@api.constrains('location_dest_id', 'location_id', 'state') @api.constrains('location_dest_id', 'location_id', 'state')
def _check_locked_location(self): def _check_locked_location(self):

View File

@@ -0,0 +1,6 @@
* Loïc Bellier (Numérigraphe) <lb@numerigraphe.com>
* Lionel Sausin (Numérigraphe) <ls@numerigraphe.com>
* Laetitia Gangloff (Acsone) <laetitia.gangloff@acsone.eu>
* Laurent Mignon (Acsone) <laurent.mignon@acsone.eu>
* Lois Rilo (Eficent) <lois.rilo@eficent.com>
* Jordi Ballester (Eficent) <jordi.ballester@eficent.com>

View File

@@ -0,0 +1 @@
This module lets you lock down the locations during an inventory.

View File

@@ -0,0 +1,7 @@
While an inventory is in the state "In progress", no stock moves
can be recorded in/out of the inventory's location: users will get an error
message.
Creating or modifying locations is also forbidden.
.. image:: stock_inventory_lockdown/static/images/move_error.png
:alt: Error message

View File

@@ -1,5 +1 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import test_stock_inventory_lockdown from . import test_stock_inventory_lockdown

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# © 2014 Acsone SA/NV (http://www.acsone.eu) # © 2014 Acsone SA/NV (http://www.acsone.eu)
# © 2016 Numérigraphe SARL # © 2016 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
@@ -26,17 +25,17 @@ class StockInventoryLocationTest(TestStockCommon):
self.env['stock.quant'].create( self.env['stock.quant'].create(
{'location_id': self.new_location.id, {'location_id': self.new_location.id,
'product_id': self.productA.id, 'product_id': self.productA.id,
'qty': 10.0}) 'quantity': 10.0})
self.env['stock.quant'].create( self.env['stock.quant'].create(
{'location_id': self.new_parent_location.id, {'location_id': self.new_parent_location.id,
'product_id': self.productB.id, 'product_id': self.productB.id,
'qty': 5.0}) 'quantity': 5.0})
# Prepare an inventory # Prepare an inventory
self.inventory = self.env['stock.inventory'].create( self.inventory = self.env['stock.inventory'].create(
{'name': 'Lock down location', {'name': 'Lock down location',
'filter': 'none', 'filter': 'none',
'location_id': self.new_location.id}) 'location_id': self.new_location.id})
self.inventory.prepare_inventory() self.inventory.action_start()
self.assertTrue(self.inventory.line_ids, 'The inventory is empty.') self.assertTrue(self.inventory.line_ids, 'The inventory is empty.')
def create_stock_move(self, product, origin_id=False, dest_id=False): def create_stock_move(self, product, origin_id=False, dest_id=False):
@@ -79,7 +78,7 @@ class StockInventoryLocationTest(TestStockCommon):
{'name': 'Lock down location', {'name': 'Lock down location',
'filter': 'partial', 'filter': 'partial',
'location_id': self.new_sublocation.id}) 'location_id': self.new_sublocation.id})
inventory_subloc.prepare_inventory() inventory_subloc.action_start()
line = self.env['stock.inventory.line'].create( line = self.env['stock.inventory.line'].create(
{'product_id': self.productA.id, {'product_id': self.productA.id,
'product_qty': 22.0, 'product_qty': 22.0,
@@ -95,16 +94,18 @@ class StockInventoryLocationTest(TestStockCommon):
location.""" location."""
move1 = self.create_stock_move( move1 = self.create_stock_move(
self.productA, origin_id=self.inventory.location_id.id) self.productA, origin_id=self.inventory.location_id.id)
move1.action_confirm() move1._action_confirm()
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
move1.action_assign() move1._action_assign()
move1.action_done() move1.move_line_ids[0].qty_done = 10.0
move1._action_done()
move2 = self.create_stock_move( move2 = self.create_stock_move(
self.productA, dest_id=self.inventory.location_id.id) self.productA, dest_id=self.inventory.location_id.id)
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
move2.action_confirm() move2._action_confirm()
move2.action_assign() move2._action_assign()
move2.action_done() move2.move_line_ids[0].qty_done = 10.0
move2._action_done()
def test_move_reserved_quants(self): def test_move_reserved_quants(self):
"""Shipping stock should be allowed or not depending on reserved """Shipping stock should be allowed or not depending on reserved
@@ -114,14 +115,16 @@ class StockInventoryLocationTest(TestStockCommon):
inventoried.""" inventoried."""
move1 = self.create_stock_move( move1 = self.create_stock_move(
self.productB, self.new_parent_location.id) self.productB, self.new_parent_location.id)
move1.action_confirm() move1._action_confirm()
move1.action_assign() move1._action_assign()
move1.action_done() move1.move_line_ids[0].qty_done = 10.0
move1._action_done()
self.assertEqual( self.assertEqual(
move1.state, 'done', 'Move has not been completed') move1.state, 'done', 'Move has not been completed')
move2 = self.create_stock_move( move2 = self.create_stock_move(
self.productA, self.new_parent_location.id) self.productA, self.new_parent_location.id)
move2.action_confirm() move2._action_confirm()
with self.assertRaises(ValidationError): with self.assertRaises(ValidationError):
move2.action_assign() move2._action_assign()
move2.action_done() move2.move_line_ids[0].qty_done = 10.0
move2._action_done()