From 58173526c09c01e232e55bc7402013b9f156a27e Mon Sep 17 00:00:00 2001 From: Lois Rilo Date: Thu, 27 Feb 2020 13:14:33 +0530 Subject: [PATCH] [IMP] mrp_production_putaway_strategy: black, isort, prettier --- .../__manifest__.py | 5 +- .../models/mrp_production.py | 17 +++--- .../tests/test_mrp_production.py | 58 +++++++++++-------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/mrp_production_putaway_strategy/__manifest__.py b/mrp_production_putaway_strategy/__manifest__.py index 27dd5fb27..ca8055628 100644 --- a/mrp_production_putaway_strategy/__manifest__.py +++ b/mrp_production_putaway_strategy/__manifest__.py @@ -4,10 +4,9 @@ { "name": "MRP Production Putaway Strategy", "summary": "Applies putaway strategies to manufacturing orders for " - "finished products.", + "finished products.", "version": "13.0.1.0.0", - "author": "Eficent, " - "Odoo Community Association (OCA)", + "author": "Eficent, " "Odoo Community Association (OCA)", "website": "https://github.com/OCA/manufacture", "category": "Manufacture", "depends": ["mrp"], diff --git a/mrp_production_putaway_strategy/models/mrp_production.py b/mrp_production_putaway_strategy/models/mrp_production.py index a27efb3d0..9ac47f417 100644 --- a/mrp_production_putaway_strategy/models/mrp_production.py +++ b/mrp_production_putaway_strategy/models/mrp_production.py @@ -1,25 +1,24 @@ # Copyright 2017-18 Eficent Business and IT Consulting Services S.L. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, models, _ +from odoo import _, api, models class MrpProduction(models.Model): - _inherit = 'mrp.production' + _inherit = "mrp.production" @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_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.id + vals["location_dest_id"] = location_id.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(body=message, message_type='comment') + "Finished Products Location: %s." % mo.location_dest_id.complete_name + ) + mo.message_post(body=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 267328227..4dcb9f1ff 100644 --- a/mrp_production_putaway_strategy/tests/test_mrp_production.py +++ b/mrp_production_putaway_strategy/tests/test_mrp_production.py @@ -5,41 +5,47 @@ from odoo.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.warehouse = self.env["stock.warehouse"].create( + { + "name": "X Warehouse", + "code": "X WH", + "reception_steps": "one_step", + "delivery_steps": "ship_only", + } + ) - self.category = self.env['product.category'].create({'name': 'Test'}) + 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.bin_loc_stock = self.env["stock.location"].create( + {"name": "Bin 1", "location_id": self.loc_stock.id, "usage": "internal"} + ) self.product1 = self.env.ref("mrp.product_product_computer_desk") self.product1.categ_id = self.category self.bom1 = self.env.ref("mrp.mrp_bom_desk") - self.putaway_strategy = self.env['stock.putaway.rule'].create({ - 'product_id': self.product1.id, - 'location_in_id': self.loc_stock.id, - 'location_out_id': self.bin_loc_stock.id, - }) + self.putaway_strategy = self.env["stock.putaway.rule"].create( + { + "product_id": self.product1.id, + "location_in_id": self.loc_stock.id, + "location_out_id": self.bin_loc_stock.id, + } + ) self.loc_stock.putaway_strategy_id = self.putaway_strategy - def _create_mo(self, product=False, bom=False, src_loc=False, - dest_loc=False, qty=10.0, uom=False): + def _create_mo( + self, + product=False, + bom=False, + src_loc=False, + dest_loc=False, + qty=10.0, + uom=False, + ): if not product: product = self.product1 uom = product.uom_id or uom @@ -57,7 +63,7 @@ class MrpProductionCase(TransactionCase): "product_qty": qty, "product_uom_id": uom.id, } - return self.env['mrp.production'].create(res) + return self.env["mrp.production"].create(res) def test_putaway_strategy_01(self): """Tests if the putaway strategy applies to a Manufacturing Order.""" @@ -65,5 +71,7 @@ class MrpProductionCase(TransactionCase): mo = self._create_mo() for finished in mo.move_finished_ids: self.assertEqual( - finished.location_dest_id, self.bin_loc_stock, - "Putaway strategy hasn't been applied.") + finished.location_dest_id, + self.bin_loc_stock, + "Putaway strategy hasn't been applied.", + )