mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[9.0][ADD] mrp_production_putaway_strategy (#215)
* [9.0][ADD] mrp_production_putaway_strategy * small fix * fixes * [FIX] travis and readme. * [FIX] adapt tests to new logic
This commit is contained in:
committed by
Lois Rilo
parent
624d50d34f
commit
cb1b82e6f7
80
mrp_production_putaway_strategy/README.rst
Normal file
80
mrp_production_putaway_strategy/README.rst
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
|
:alt: License: AGPL-3
|
||||||
|
|
||||||
|
===============================
|
||||||
|
MRP Production Putaway Strategy
|
||||||
|
===============================
|
||||||
|
|
||||||
|
This module allows to apply putaway strategies to the products resulting from
|
||||||
|
the manufacturing orders.
|
||||||
|
|
||||||
|
The finished products will be placed in the location designated by the putaway
|
||||||
|
strategy (if they do not have another destination move), based on the
|
||||||
|
finished products location that was defined in the manufacturing order.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
To configure a putaway strategy follow the next steps:
|
||||||
|
|
||||||
|
#. Go to 'Inventory / Settings' and activate the option 'Advanced routing of
|
||||||
|
products using rules'.
|
||||||
|
#. Define a putaway strategy in the location zone where the finished products
|
||||||
|
are supposed to be placed, and indicate the specific sub-location/bin
|
||||||
|
where the products should be placed.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
To use this module proceed as follows:
|
||||||
|
|
||||||
|
#. Create a manufacturing order and indicate the product and the finished
|
||||||
|
products location zone.
|
||||||
|
#. Confirm the manufacturing order.
|
||||||
|
#. You will notice that the finished products location has changed to the
|
||||||
|
putaway location, and the chatter shows a message indicating that the
|
||||||
|
putaway strategy was applied.
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
|
:alt: Try me on Runbot
|
||||||
|
:target: https://runbot.odoo-community.org/runbot/129/9.0
|
||||||
|
|
||||||
|
|
||||||
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bugs are tracked on `GitHub Issues
|
||||||
|
<https://github.com/OCA/manufacture/issues>`_. In case of trouble, please
|
||||||
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
|
help us smashing it by providing a detailed and welcomed feedback.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
Images
|
||||||
|
------
|
||||||
|
|
||||||
|
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Jordi Ballester <jordi.ballester@eficent.com>
|
||||||
|
* Lois Rilo <lois.rilo@eficent.com>
|
||||||
|
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/logo.png
|
||||||
|
:alt: Odoo Community Association
|
||||||
|
:target: https://odoo-community.org
|
||||||
|
|
||||||
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
mission is to support the collaborative development of Odoo features and
|
||||||
|
promote its widespread use.
|
||||||
|
|
||||||
|
To contribute to this module, please visit https://odoo-community.org.
|
||||||
5
mrp_production_putaway_strategy/__init__.py
Normal file
5
mrp_production_putaway_strategy/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from . import models
|
||||||
17
mrp_production_putaway_strategy/__openerp__.py
Normal file
17
mrp_production_putaway_strategy/__openerp__.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "MRP Production Putaway Strategy",
|
||||||
|
"summary": "Applies putaway strategies to manufacturing orders for "
|
||||||
|
"finished products.",
|
||||||
|
"version": "9.0.1.0.0",
|
||||||
|
"author": "Eficent, "
|
||||||
|
"Odoo Community Association (OCA)",
|
||||||
|
"website": "http://www.eficent.com",
|
||||||
|
"category": "Manufacture",
|
||||||
|
"depends": ["mrp"],
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"installable": True,
|
||||||
|
}
|
||||||
5
mrp_production_putaway_strategy/models/__init__.py
Normal file
5
mrp_production_putaway_strategy/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from . import mrp_production
|
||||||
23
mrp_production_putaway_strategy/models/mrp_production.py
Normal file
23
mrp_production_putaway_strategy/models/mrp_production.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from openerp import api, models, _
|
||||||
|
|
||||||
|
|
||||||
|
class MrpProduction(models.Model):
|
||||||
|
_inherit = 'mrp.production'
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def action_confirm(self):
|
||||||
|
for mo in self:
|
||||||
|
if not mo.move_prod_id:
|
||||||
|
location = self.env['stock.location'].get_putaway_strategy(
|
||||||
|
mo.location_dest_id, mo.product_id)
|
||||||
|
if location:
|
||||||
|
message = _(
|
||||||
|
'Applied Putaway strategy to finished products '
|
||||||
|
'location %s.' % mo.location_dest_id.complete_name)
|
||||||
|
mo.message_post(message, message_type='comment')
|
||||||
|
mo.location_dest_id = location
|
||||||
|
return super(MrpProduction, self).action_confirm()
|
||||||
BIN
mrp_production_putaway_strategy/static/description/icon.png
Normal file
BIN
mrp_production_putaway_strategy/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
5
mrp_production_putaway_strategy/tests/__init__.py
Normal file
5
mrp_production_putaway_strategy/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from . import test_mrp_production
|
||||||
99
mrp_production_putaway_strategy/tests/test_mrp_production.py
Normal file
99
mrp_production_putaway_strategy/tests/test_mrp_production.py
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2017 Eficent Business and IT Consulting Services S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from openerp.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
|
class MrpProductionCase(TransactionCase):
|
||||||
|
|
||||||
|
def setUp(self, *args, **kwargs):
|
||||||
|
super(MrpProductionCase, self).setUp(*args, **kwargs)
|
||||||
|
|
||||||
|
self.warehouse = self.env["stock.warehouse"].create({
|
||||||
|
"name": "X Warehouse",
|
||||||
|
"code": "X WH",
|
||||||
|
"reception_steps": "one_step",
|
||||||
|
"delivery_steps": "ship_only",
|
||||||
|
"resupply_from_wh": False,
|
||||||
|
"default_resupply_wh_id": False,
|
||||||
|
})
|
||||||
|
|
||||||
|
self.category = self.env['product.category'].create({'name': 'Test'})
|
||||||
|
|
||||||
|
self.loc_stock = self.warehouse.lot_stock_id
|
||||||
|
self.bin_loc_stock = self.env['stock.location'].create({
|
||||||
|
'name': 'Bin 1',
|
||||||
|
'location_id': self.loc_stock.id,
|
||||||
|
'usage': 'internal'
|
||||||
|
})
|
||||||
|
|
||||||
|
self.putaway_strategy = self.env['product.putaway'].create({
|
||||||
|
'name': 'Fixed Loc',
|
||||||
|
'method': 'fixed',
|
||||||
|
'fixed_location_ids': [(
|
||||||
|
0, 0, {'fixed_location_id': self.bin_loc_stock.id,
|
||||||
|
'category_id': self.category.id})]
|
||||||
|
})
|
||||||
|
self.loc_stock.putaway_strategy_id = self.putaway_strategy
|
||||||
|
|
||||||
|
self.loc_production = self.env.ref(
|
||||||
|
"stock.location_production")
|
||||||
|
self.product1 = self.env.ref("product.product_product_18")
|
||||||
|
self.product1.categ_id = self.category
|
||||||
|
self.bom1 = self.env.ref("mrp.mrp_bom_3")
|
||||||
|
|
||||||
|
def _create_mo(self, product=False, bom=False, src_loc=False,
|
||||||
|
dest_loc=False, qty=10.0, uom=False, move_prod_id=False):
|
||||||
|
if not product:
|
||||||
|
product = self.product1
|
||||||
|
uom = product.uom_id
|
||||||
|
if not bom:
|
||||||
|
bom = self.bom1
|
||||||
|
if not src_loc:
|
||||||
|
src_loc = self.loc_stock
|
||||||
|
if not dest_loc:
|
||||||
|
dest_loc = self.loc_stock
|
||||||
|
res = {
|
||||||
|
"product_id": product.id,
|
||||||
|
"bom_id": bom.id,
|
||||||
|
"location_src_id": src_loc.id,
|
||||||
|
"location_dest_id": dest_loc.id,
|
||||||
|
"product_qty": qty,
|
||||||
|
"product_uom": uom.id,
|
||||||
|
"move_prod_id": move_prod_id.id if move_prod_id else False,
|
||||||
|
}
|
||||||
|
return self.env['mrp.production'].create(res)
|
||||||
|
|
||||||
|
def test_putaway_strategy_01(self):
|
||||||
|
"""Tests if the putaway strategy applies to a Manufacturing Order
|
||||||
|
without destination move."""
|
||||||
|
# Create MO
|
||||||
|
mo = self._create_mo()
|
||||||
|
# Click confirm button
|
||||||
|
mo.signal_workflow("button_confirm")
|
||||||
|
for finished in mo.move_created_ids:
|
||||||
|
self.assertEqual(
|
||||||
|
finished.location_dest_id, self.bin_loc_stock,
|
||||||
|
"Putaway strategy hasn't been applied.")
|
||||||
|
|
||||||
|
def test_putaway_strategy_02(self):
|
||||||
|
"""Tests if the destination location is respected whenever a
|
||||||
|
destination move is set for the Manufactuing Order."""
|
||||||
|
# Create a destination transfer.
|
||||||
|
move = self.env['stock.move'].create({
|
||||||
|
"name": "Destination move for the test MO",
|
||||||
|
"product_id": self.product1.id,
|
||||||
|
"product_uom_qty": 10.0,
|
||||||
|
"product_uom": self.product1.uom_id.id,
|
||||||
|
"location_id": self.loc_stock.id,
|
||||||
|
"location_dest_id": self.bin_loc_stock.id,
|
||||||
|
})
|
||||||
|
# Create MO
|
||||||
|
mo = self._create_mo(move_prod_id=move)
|
||||||
|
# Click confirm button
|
||||||
|
mo.signal_workflow("button_confirm")
|
||||||
|
for finished in mo.move_created_ids:
|
||||||
|
self.assertEqual(
|
||||||
|
finished.location_dest_id, self.loc_stock,
|
||||||
|
"Destination move has not been respected.")
|
||||||
Reference in New Issue
Block a user