1
1
# Copyright 2021-2021 Camptocamp SA
2
2
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3
3
4
+ from odoo_test_helper import FakeModelLoader
4
5
5
6
from .common import StockPickingDeliveryLinkCommonCase
6
7
@@ -27,6 +28,17 @@ def setUpClass(cls):
27
28
}
28
29
)
29
30
31
+ cls .loader = FakeModelLoader (cls .env , cls .__module__ )
32
+ cls .loader .backup_registry ()
33
+ from .models .delivery_carrier import DeliveryCarrier
34
+
35
+ cls .loader .update_registry ((DeliveryCarrier ,))
36
+
37
+ @classmethod
38
+ def tearDownClass (cls ):
39
+ cls .loader .restore_registry ()
40
+ super ().tearDownClass ()
41
+
30
42
def test_ship_data_from_pick (self ):
31
43
move1 = self ._create_move (
32
44
self .product ,
@@ -138,8 +150,60 @@ def test_put_in_pack_from_pick_with_wizard(self):
138
150
# check the action is a dict
139
151
self .assertIsInstance (pip_action , dict )
140
152
pip_action_model = pip_action ["res_model" ]
153
+ pip_action_context = pip_action ["context" ]
154
+ # We make sure the correct action was returned
155
+ self .assertEqual (pip_action_model , "choose.delivery.package" )
156
+ self .assertEqual ("none" , pip_action_context .get ("current_package_carrier_type" ))
157
+
158
+ def test_put_in_pack_from_pick_with_wizard_carrier (self ):
159
+ """
160
+ Normally the "choose package type" wizard is triggered only if a carrier is
161
+ set on the picking (usually on ship picking). This module permits to force
162
+ the wizard if there is no carrier set but if there is a shipping carrier and
163
+ set_delivery_package_type_on_put_in_pack set on the package type.
164
+
165
+ Try with forcing from pick picking type => wizard ok
166
+ """
167
+ self .test_carrier .delivery_type = "test"
168
+ self .wh .delivery_steps = "pick_ship"
169
+ self .env ["stock.quant" ]._update_available_quantity (
170
+ self .product , self .shelf1_loc , 20.0
171
+ )
172
+ ship_move = self .env ["stock.move" ].create (
173
+ {
174
+ "name" : "The ship move" ,
175
+ "product_id" : self .product .id ,
176
+ "product_uom_qty" : 5.0 ,
177
+ "product_uom" : self .product .uom_id .id ,
178
+ "location_id" : self .shelf2_loc .id ,
179
+ "location_dest_id" : self .customer_location .id ,
180
+ "warehouse_id" : self .wh .id ,
181
+ "picking_type_id" : self .wh .out_type_id .id ,
182
+ "procure_method" : "make_to_order" ,
183
+ "state" : "draft" ,
184
+ }
185
+ )
186
+ ship_move ._assign_picking ()
187
+ ship_move ._action_confirm ()
188
+ pick_move = ship_move .move_orig_ids [0 ]
189
+ pick_picking = pick_move .picking_id
190
+ ship_picking = ship_move .picking_id
191
+ # set a carrier on shipment picking
192
+ ship_picking .carrier_id = self .test_carrier
193
+ # force wizard on pick operation picking_type_id
194
+ pick_picking .picking_type_id .set_delivery_package_type_on_put_in_pack = True
195
+ pick_picking .action_assign ()
196
+ pick_picking .move_line_ids .filtered (
197
+ lambda ml : ml .product_id == self .product
198
+ ).qty_done = 5.0
199
+ pip_action = pick_picking .action_put_in_pack ()
200
+ # check the action is a dict
201
+ self .assertIsInstance (pip_action , dict )
202
+ pip_action_model = pip_action ["res_model" ]
203
+ pip_action_context = pip_action ["context" ]
141
204
# We make sure the correct action was returned
142
205
self .assertEqual (pip_action_model , "choose.delivery.package" )
206
+ self .assertEqual ("test" , pip_action_context .get ("current_package_carrier_type" ))
143
207
144
208
def test_put_in_pack_from_pick_without_wizard (self ):
145
209
"""
0 commit comments