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
@@ -6,8 +6,7 @@
|
|||||||
"summary": "Applies putaway strategies to manufacturing orders for "
|
"summary": "Applies putaway strategies to manufacturing orders for "
|
||||||
"finished products.",
|
"finished products.",
|
||||||
"version": "13.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"author": "Eficent, "
|
"author": "Eficent, " "Odoo Community Association (OCA)",
|
||||||
"Odoo Community Association (OCA)",
|
|
||||||
"website": "https://github.com/OCA/manufacture",
|
"website": "https://github.com/OCA/manufacture",
|
||||||
"category": "Manufacture",
|
"category": "Manufacture",
|
||||||
"depends": ["mrp"],
|
"depends": ["mrp"],
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
# Copyright 2017-18 Eficent Business and IT Consulting Services S.L.
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# 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):
|
class MrpProduction(models.Model):
|
||||||
_inherit = 'mrp.production'
|
_inherit = "mrp.production"
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
location_dest = self.env['stock.location'].browse(vals.get(
|
location_dest = self.env["stock.location"].browse(vals.get("location_dest_id"))
|
||||||
'location_dest_id'))
|
product = self.env["product.product"].browse(vals.get("product_id"))
|
||||||
product = self.env['product.product'].browse(vals.get('product_id'))
|
|
||||||
location_id = location_dest._get_putaway_strategy(product)
|
location_id = location_dest._get_putaway_strategy(product)
|
||||||
if location_id:
|
if location_id:
|
||||||
vals['location_dest_id'] = location_id.id
|
vals["location_dest_id"] = location_id.id
|
||||||
mo = super(MrpProduction, self).create(vals)
|
mo = super(MrpProduction, self).create(vals)
|
||||||
if location_id:
|
if location_id:
|
||||||
message = _(
|
message = _(
|
||||||
"Applied Putaway strategy to finished products.\n"
|
"Applied Putaway strategy to finished products.\n"
|
||||||
"Finished Products Location: %s." %
|
"Finished Products Location: %s." % mo.location_dest_id.complete_name
|
||||||
mo.location_dest_id.complete_name)
|
)
|
||||||
mo.message_post(body=message, message_type='comment')
|
mo.message_post(body=message, message_type="comment")
|
||||||
return mo
|
return mo
|
||||||
|
|||||||
@@ -5,41 +5,47 @@ from odoo.tests.common import TransactionCase
|
|||||||
|
|
||||||
|
|
||||||
class MrpProductionCase(TransactionCase):
|
class MrpProductionCase(TransactionCase):
|
||||||
|
|
||||||
def setUp(self, *args, **kwargs):
|
def setUp(self, *args, **kwargs):
|
||||||
super(MrpProductionCase, self).setUp(*args, **kwargs)
|
super(MrpProductionCase, self).setUp(*args, **kwargs)
|
||||||
|
|
||||||
self.warehouse = self.env["stock.warehouse"].create({
|
self.warehouse = self.env["stock.warehouse"].create(
|
||||||
|
{
|
||||||
"name": "X Warehouse",
|
"name": "X Warehouse",
|
||||||
"code": "X WH",
|
"code": "X WH",
|
||||||
"reception_steps": "one_step",
|
"reception_steps": "one_step",
|
||||||
"delivery_steps": "ship_only",
|
"delivery_steps": "ship_only",
|
||||||
"resupply_from_wh": False,
|
}
|
||||||
"default_resupply_wh_id": False,
|
)
|
||||||
})
|
|
||||||
|
|
||||||
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.loc_stock = self.warehouse.lot_stock_id
|
||||||
self.bin_loc_stock = self.env['stock.location'].create({
|
self.bin_loc_stock = self.env["stock.location"].create(
|
||||||
'name': 'Bin 1',
|
{"name": "Bin 1", "location_id": self.loc_stock.id, "usage": "internal"}
|
||||||
'location_id': self.loc_stock.id,
|
)
|
||||||
'usage': 'internal'
|
|
||||||
})
|
|
||||||
|
|
||||||
self.product1 = self.env.ref("mrp.product_product_computer_desk")
|
self.product1 = self.env.ref("mrp.product_product_computer_desk")
|
||||||
self.product1.categ_id = self.category
|
self.product1.categ_id = self.category
|
||||||
self.bom1 = self.env.ref("mrp.mrp_bom_desk")
|
self.bom1 = self.env.ref("mrp.mrp_bom_desk")
|
||||||
|
|
||||||
self.putaway_strategy = self.env['stock.putaway.rule'].create({
|
self.putaway_strategy = self.env["stock.putaway.rule"].create(
|
||||||
'product_id': self.product1.id,
|
{
|
||||||
'location_in_id': self.loc_stock.id,
|
"product_id": self.product1.id,
|
||||||
'location_out_id': self.bin_loc_stock.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
|
self.loc_stock.putaway_strategy_id = self.putaway_strategy
|
||||||
|
|
||||||
def _create_mo(self, product=False, bom=False, src_loc=False,
|
def _create_mo(
|
||||||
dest_loc=False, qty=10.0, uom=False):
|
self,
|
||||||
|
product=False,
|
||||||
|
bom=False,
|
||||||
|
src_loc=False,
|
||||||
|
dest_loc=False,
|
||||||
|
qty=10.0,
|
||||||
|
uom=False,
|
||||||
|
):
|
||||||
if not product:
|
if not product:
|
||||||
product = self.product1
|
product = self.product1
|
||||||
uom = product.uom_id or uom
|
uom = product.uom_id or uom
|
||||||
@@ -57,7 +63,7 @@ class MrpProductionCase(TransactionCase):
|
|||||||
"product_qty": qty,
|
"product_qty": qty,
|
||||||
"product_uom_id": uom.id,
|
"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):
|
def test_putaway_strategy_01(self):
|
||||||
"""Tests if the putaway strategy applies to a Manufacturing Order."""
|
"""Tests if the putaway strategy applies to a Manufacturing Order."""
|
||||||
@@ -65,5 +71,7 @@ class MrpProductionCase(TransactionCase):
|
|||||||
mo = self._create_mo()
|
mo = self._create_mo()
|
||||||
for finished in mo.move_finished_ids:
|
for finished in mo.move_finished_ids:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
finished.location_dest_id, self.bin_loc_stock,
|
finished.location_dest_id,
|
||||||
"Putaway strategy hasn't been applied.")
|
self.bin_loc_stock,
|
||||||
|
"Putaway strategy hasn't been applied.",
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user