mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_production_putaway_strategy: black, isort, prettier
This commit is contained in:
committed by
Joan Mateu Jordi
parent
a087b9e4ad
commit
58173526c0
@@ -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"],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user