Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] mrp_production_machine_location: Machine location in consume an…
…d produce products.
- Loading branch information
1 parent
c1fcd66
commit 747f7b4
Showing
9 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MRP Production machine location | ||
=============================== | ||
If the work order is to produce, and this work order has a work center that has | ||
a machine defined, and this machine has definied a location: | ||
|
||
* The origin location of the products to consume in the work order, will be | ||
the location of the machine. | ||
|
||
* The destination location of the product to be produced, will be the location | ||
of the machine. | ||
|
||
|
||
Configuration | ||
============= | ||
|
||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Ana Juaristi <ajuaristo@gmail.com> | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2016 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2016 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
{ | ||
"name": "MRP Production Machine Location", | ||
"version": "8.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "AvanzOSC", | ||
"website": "http://www.avanzosc.es", | ||
'contributors': [ | ||
"Ana Juaristi <anajuaristi@avanzosc.es>", | ||
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>", | ||
], | ||
"category": "Manufacturing", | ||
"depends": ['mrp_machine_relation' | ||
], | ||
"data": [], | ||
"installable": True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_production_machine_location | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-11-08 15:16+0000\n" | ||
"PO-Revision-Date: 2016-11-08 15:16+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mrp_production_machine_location | ||
#: model:ir.model,name:mrp_production_machine_location.model_mrp_production | ||
msgid "Manufacturing Order" | ||
msgstr "Orden de fabricación" | ||
|
||
#. module: mrp_production_machine_location | ||
#: model:ir.model,name:mrp_production_machine_location.model_stock_move | ||
msgid "Stock Move" | ||
msgstr "Movimiento de stock" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2016 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import mrp_production | ||
from . import stock_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2016 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from openerp import models, api | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = 'mrp.production' | ||
|
||
@api.multi | ||
def action_confirm(self): | ||
result = super(MrpProduction, self).action_confirm() | ||
for prod in self: | ||
moves = prod.move_lines.filtered( | ||
lambda r: r.work_order.do_production and | ||
r.work_order.workcenter_id.machine.location) | ||
for move in moves: | ||
location = move.work_order.workcenter_id.machine.location | ||
move.location_id = location | ||
workcenter_lines = prod.workcenter_lines.filtered( | ||
lambda r: r.do_production) | ||
workcenter_line = max( | ||
workcenter_lines, key=lambda x: x.sequence) | ||
location = workcenter_line.workcenter_id.machine.location | ||
if location: | ||
prod.move_created_ids.write({'location_dest_id': location.id}) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2016 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from openerp import models, api | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = 'stock.move' | ||
|
||
@api.multi | ||
def action_confirm(self): | ||
moves = self.filtered(lambda r: r.raw_material_production_id and | ||
r.work_order.do_production and | ||
r.work_order.workcenter_id.machine.location) | ||
for move in moves: | ||
location = move.work_order.workcenter_id.machine.location | ||
if move.location_id.id != location.id: | ||
move.location_id = location.id | ||
return super(StockMove, self).action_confirm() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from . import test_mrp_production_machine_location |
34 changes: 34 additions & 0 deletions
34
mrp_production_machine_location/tests/test_mrp_production_machine_location.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
import openerp.tests.common as common | ||
|
||
|
||
class TestMrpProductionMachineLocation(common.TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestMrpProductionMachineLocation, self).setUp() | ||
self.machine = self.env.ref('machine_manager.machinery_1') | ||
self.machine.location = self.ref('stock.location_refrigerator_small') | ||
self.workcenter = self.env.ref('mrp.mrp_workcenter_0') | ||
self.workcenter.machine = self.machine.id | ||
self.production = self.env.ref( | ||
'mrp_operations_extension.mrp_production_opeext') | ||
|
||
def test_mrp_production_machine_location(self): | ||
self.assertEqual(self.production.state, 'draft') | ||
self.production.signal_workflow('button_confirm') | ||
stock_moves = self.production.mapped('move_lines').filtered( | ||
lambda l: l.work_order.workcenter_id == self.workcenter) | ||
for stock_move in stock_moves: | ||
self.assertEqual( | ||
stock_move.location_id, self.machine.location, | ||
'products to consume without machine location') | ||
stock_moves.write( | ||
{'location_id': | ||
self.ref('stock.stock_location_locations_virtual')}) | ||
stock_moves.action_confirm() | ||
for stock_move in stock_moves: | ||
self.assertEqual( | ||
stock_move.location_id, self.machine.location, | ||
'products to consume without machine location') |