@@ -66,18 +66,13 @@ def setUpClass(cls):
66
66
"company_id" : cls .user_company .id ,
67
67
}
68
68
)
69
+ cls .location = cls .env .ref ("stock.stock_location_stock" )
69
70
70
71
def qty_on_hand (self , product , quantity , lot ):
71
72
"""Update Product quantity."""
72
- res = product .action_update_quantity_on_hand ()
73
- stock_quant_form = Form (
74
- self .env ["stock.quant" ].with_context (** res ["context" ]),
75
- view = "stock.view_stock_quant_tree_inventory_editable" ,
73
+ self .env ["stock.quant" ]._update_available_quantity (
74
+ product , self .location , lot_id = lot , quantity = quantity
76
75
)
77
- stock_quant_form .inventory_quantity = quantity
78
- stock_quant_form .lot_id = lot
79
- quant = stock_quant_form .save ()
80
- quant .action_apply_inventory ()
81
76
82
77
def test_00_sale_stock_invoice_product_lot (self ):
83
78
# update quantities with their related lots
@@ -89,9 +84,7 @@ def test_00_sale_stock_invoice_product_lot(self):
89
84
picking = self .sale .picking_ids [:1 ]
90
85
picking .action_confirm ()
91
86
picking .action_assign ()
92
- for sml in picking .move_ids .mapped ("move_line_ids" ):
93
- sml .qty_done = sml .reserved_qty
94
- picking ._action_done ()
87
+ picking .button_validate ()
95
88
# create invoice
96
89
invoice = self .sale ._create_invoices ()
97
90
self .assertEqual (len (invoice .invoice_line_ids ), 2 )
@@ -115,7 +108,8 @@ def test_01_sale_stock_delivery_partial_invoice_product_lot(self):
115
108
picking .action_confirm ()
116
109
picking .action_assign ()
117
110
# deliver partially only one lot
118
- picking .move_ids [0 ].move_line_ids [0 ].write ({"qty_done" : 2.0 })
111
+ picking .move_ids [0 ].move_line_ids [0 ].write ({"quantity" : 2.0 })
112
+ picking .move_ids [0 ].move_line_ids [1 ].write ({"quantity" : 0.0 })
119
113
backorder_wizard_dict = picking .button_validate ()
120
114
backorder_wiz = Form (
121
115
self .env [backorder_wizard_dict ["res_model" ]].with_context (
@@ -145,8 +139,8 @@ def test_02_sale_stock_delivery_partial_invoice_product_lot(self):
145
139
picking .action_confirm ()
146
140
picking .action_assign ()
147
141
# deliver partially both lots
148
- picking .move_ids [0 ].move_line_ids [0 ].write ({"qty_done " : 1.0 })
149
- picking .move_ids [0 ].move_line_ids [1 ].write ({"qty_done " : 1.0 })
142
+ picking .move_ids [0 ].move_line_ids [0 ].write ({"quantity " : 1.0 })
143
+ picking .move_ids [0 ].move_line_ids [1 ].write ({"quantity " : 1.0 })
150
144
backorder_wizard_dict = picking .button_validate ()
151
145
backorder_wiz = Form (
152
146
self .env [backorder_wizard_dict ["res_model" ]].with_context (
0 commit comments