diff --git a/mrp_production_putaway_strategy/README.rst b/mrp_production_putaway_strategy/README.rst index 392ce3655..e20ecc5d5 100644 --- a/mrp_production_putaway_strategy/README.rst +++ b/mrp_production_putaway_strategy/README.rst @@ -38,7 +38,7 @@ To use this module proceed as follows: .. 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 + :target: https://runbot.odoo-community.org/runbot/129/10.0 Bug Tracker diff --git a/mrp_production_putaway_strategy/__init__.py b/mrp_production_putaway_strategy/__init__.py index 1ef17e386..149f4e4fd 100644 --- a/mrp_production_putaway_strategy/__init__.py +++ b/mrp_production_putaway_strategy/__init__.py @@ -1,5 +1,4 @@ # -*- 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 diff --git a/mrp_production_putaway_strategy/__openerp__.py b/mrp_production_putaway_strategy/__manifest__.py similarity index 94% rename from mrp_production_putaway_strategy/__openerp__.py rename to mrp_production_putaway_strategy/__manifest__.py index 2c79827b2..828f7175f 100644 --- a/mrp_production_putaway_strategy/__openerp__.py +++ b/mrp_production_putaway_strategy/__manifest__.py @@ -6,7 +6,7 @@ "name": "MRP Production Putaway Strategy", "summary": "Applies putaway strategies to manufacturing orders for " "finished products.", - "version": "9.0.1.0.0", + "version": "10.0.1.0.0", "author": "Eficent, " "Odoo Community Association (OCA)", "website": "http://www.eficent.com", diff --git a/mrp_production_putaway_strategy/models/__init__.py b/mrp_production_putaway_strategy/models/__init__.py index e62eb8998..628baff40 100644 --- a/mrp_production_putaway_strategy/models/__init__.py +++ b/mrp_production_putaway_strategy/models/__init__.py @@ -1,5 +1,4 @@ # -*- 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 diff --git a/mrp_production_putaway_strategy/models/mrp_production.py b/mrp_production_putaway_strategy/models/mrp_production.py index 55ea6ecf9..42d2a52a1 100644 --- a/mrp_production_putaway_strategy/models/mrp_production.py +++ b/mrp_production_putaway_strategy/models/mrp_production.py @@ -1,23 +1,26 @@ # -*- coding: utf-8 -*- -# © 2017 Eficent Business and IT Consulting Services S.L. +# © 2017-18 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, _ +from odoo 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() + @api.model + def create(self, vals): + location_dest = self.env['stock.location'].browse(vals.get( + 'location_dest_id')) + product = self.env['product.product'].browse(vals.get('product_id')) + location_id = location_dest.get_putaway_strategy(product) + if location_id: + vals['location_dest_id'] = location_id + mo = super(MrpProduction, self).create(vals) + if location_id: + message = _( + "Applied Putaway strategy to finished products.\n" + "Finished Products Location: %s." % + mo.location_dest_id.complete_name) + mo.message_post(message, message_type='comment') + return mo diff --git a/mrp_production_putaway_strategy/tests/test_mrp_production.py b/mrp_production_putaway_strategy/tests/test_mrp_production.py index 6cb82d865..adf8b0b2c 100644 --- a/mrp_production_putaway_strategy/tests/test_mrp_production.py +++ b/mrp_production_putaway_strategy/tests/test_mrp_production.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -# © 2017 Eficent Business and IT Consulting Services S.L. +# © 2017-18 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 +from odoo.tests.common import TransactionCase class MrpProductionCase(TransactionCase): @@ -39,15 +39,15 @@ class MrpProductionCase(TransactionCase): self.loc_production = self.env.ref( "stock.location_production") - self.product1 = self.env.ref("product.product_product_18") + self.product1 = self.env.ref("mrp.product_product_19") 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): + dest_loc=False, qty=10.0, uom=False): if not product: product = self.product1 - uom = product.uom_id + uom = product.uom_id or uom if not bom: bom = self.bom1 if not src_loc: @@ -60,40 +60,15 @@ class MrpProductionCase(TransactionCase): "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, + "product_uom_id": uom.id, } 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.""" + """Tests if the putaway strategy applies to a Manufacturing Order.""" # Create MO mo = self._create_mo() - # Click confirm button - mo.signal_workflow("button_confirm") - for finished in mo.move_created_ids: + for finished in mo.move_finished_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.")