11# © 2015 Agile Business Group
22# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3-
3+ from odoo . fields import Command
44from odoo .tests import TransactionCase
55
66
@@ -18,17 +18,62 @@ def setUpClass(cls):
1818
1919 """
2020 super ().setUpClass ()
21- cls .prd_cable = cls .env .ref ("stock.product_cable_management_box" )
22- cls .prd_cable .tracking = "lot"
23- cls .product_46 = cls .env .ref ("product.product_product_13" )
24- cls .product_12 = cls .env .ref ("product.product_product_12" )
21+ cls .partner = cls .env ["res.partner" ].create (
22+ {
23+ "name" : "Partner Test" ,
24+ }
25+ )
26+ cls .prd_cable = cls .env ["product.product" ].create (
27+ {
28+ "name" : "Cable Test" ,
29+ "tracking" : "lot" ,
30+ "is_storable" : True ,
31+ }
32+ )
33+ cls .product_46 = cls .env ["product.product" ].create (
34+ {
35+ "name" : "Product 46" ,
36+ "is_storable" : True ,
37+ }
38+ )
39+ cls .product_12 = cls .env ["product.product" ].create (
40+ {
41+ "name" : "Product 12" ,
42+ "is_storable" : True ,
43+ }
44+ )
2545 cls .supplier_location = cls .env .ref ("stock.stock_location_suppliers" )
2646 cls .customer_location = cls .env .ref ("stock.stock_location_customers" )
2747 cls .stock_location = cls .env .ref ("stock.stock_location_stock" )
2848 cls .product_model = cls .env ["product.product" ]
2949 cls .lot_model = cls .env ["stock.lot" ]
30- cls .lot_cable = cls .env .ref ("sale_order_lot_selection.lot_cable_demo" )
31- cls .sale = cls .env .ref ("sale_order_lot_selection.sale_order_demo" )
50+ cls .lot_cable = cls .env ["stock.lot" ].create (
51+ {
52+ "name" : "cable test lot" ,
53+ "product_id" : cls .prd_cable .id ,
54+ }
55+ )
56+ cls .sale = cls .env ["sale.order" ].create (
57+ {
58+ "partner_id" : cls .partner .id ,
59+ "order_line" : [
60+ Command .create (
61+ {
62+ "product_id" : cls .prd_cable .id ,
63+ "product_uom_qty" : 1.0 ,
64+ "lot_id" : cls .lot_cable .id ,
65+ }
66+ ),
67+ Command .create (
68+ {
69+ "product_id" : cls .prd_cable .id ,
70+ "product_uom_qty" : 1.0 ,
71+ "lot_id" : cls .lot_cable .id ,
72+ }
73+ ),
74+ ],
75+ }
76+ )
3277
3378 def _retrieve_stock_quantity (self , product , lot , location ):
3479 return product .with_context (lot_id = lot .id , location = location .id ).qty_available
0 commit comments