Files
manufacture/mrp_sale_info/tests/test_mrp_sale_info.py
2021-04-22 16:48:31 +02:00

53 lines
1.8 KiB
Python

# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tests import common
class TestMrpSaleInfo(common.SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
route_manufacture_1 = cls.env.ref("mrp.route_warehouse0_manufacture")
route_manufacture_2 = cls.env.ref("stock.route_warehouse0_mto")
route_manufacture_2.active = True
cls.product = cls.env["product.product"].create(
{
"name": "Test mrp_sale_info product",
"type": "product",
"route_ids": [
(4, route_manufacture_1.id),
(4, route_manufacture_2.id),
],
}
)
cls.bom = cls.env["mrp.bom"].create(
{
"product_tmpl_id": cls.product.product_tmpl_id.id,
}
)
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
cls.sale_order = cls.env["sale.order"].create(
{
"partner_id": cls.partner.id,
"order_line": [
(
0,
0,
{
"product_id": cls.product.id,
"product_uom_qty": 1,
"price_unit": 1,
},
),
],
}
)
def test_mrp_sale_info(self):
prev_productions = self.env["mrp.production"].search([])
self.sale_order.action_confirm()
production = self.env["mrp.production"].search([]) - prev_productions
self.assertEqual(production.sale_id, self.sale_order)
self.assertEqual(production.partner_id, self.partner)