6
6
7
7
from odoo .tests .common import TransactionCase , tagged
8
8
9
+ from odoo .addons .base .tests .common import DISABLED_MAIL_CONTEXT
10
+
9
11
_logger = logging .getLogger (__name__ )
10
12
11
13
@@ -14,15 +16,6 @@ class TestProductCostPriceAvcoSync(TransactionCase):
14
16
@classmethod
15
17
def setUpClass (cls ):
16
18
super (TestProductCostPriceAvcoSync , cls ).setUpClass ()
17
- # Remove this variable in v16 and put instead:
18
- # from odoo.addons.base.tests.common import DISABLED_MAIL_CONTEXT
19
- DISABLED_MAIL_CONTEXT = {
20
- "tracking_disable" : True ,
21
- "mail_create_nolog" : True ,
22
- "mail_create_nosubscribe" : True ,
23
- "mail_notrack" : True ,
24
- "no_reset_password" : True ,
25
- }
26
19
cls .env = cls .env (context = dict (cls .env .context , ** DISABLED_MAIL_CONTEXT ))
27
20
cls .StockPicking = cls .env ["stock.picking" ]
28
21
cls .supplier_location = cls .env .ref ("stock.stock_location_suppliers" )
@@ -48,7 +41,7 @@ def setUpClass(cls):
48
41
"picking_type_id" : cls .picking_type_in .id ,
49
42
"location_id" : cls .supplier_location .id ,
50
43
"location_dest_id" : cls .stock_location .id ,
51
- "move_lines " : [
44
+ "move_ids " : [
52
45
(
53
46
0 ,
54
47
0 ,
@@ -70,7 +63,7 @@ def setUpClass(cls):
70
63
"picking_type_id" : cls .picking_type_out .id ,
71
64
"location_id" : cls .stock_location .id ,
72
65
"location_dest_id" : cls .customer_location .id ,
73
- "move_lines " : [
66
+ "move_ids " : [
74
67
(
75
68
0 ,
76
69
0 ,
@@ -88,7 +81,7 @@ def setUpClass(cls):
88
81
)
89
82
90
83
def _test_sync_cost_price (self ):
91
- move_in = self .picking_in .move_lines [:1 ]
84
+ move_in = self .picking_in .move_ids [:1 ]
92
85
move_in .product_uom_qty = 100
93
86
move_in .price_unit = 5.0
94
87
move_in .quantity_done = move_in .product_uom_qty
@@ -104,20 +97,20 @@ def _test_sync_cost_price(self):
104
97
sleep (1 )
105
98
106
99
picking_in_2 = self .picking_in .copy ()
107
- move_in_2 = picking_in_2 .move_lines [:1 ]
100
+ move_in_2 = picking_in_2 .move_ids [:1 ]
108
101
move_in_2 .product_uom_qty = 10.0
109
102
move_in_2 .quantity_done = move_in_2 .product_uom_qty
110
103
picking_in_2 ._action_done ()
111
104
move_in_2 .date = "2019-10-02 00:00:00"
112
105
sleep (1 )
113
106
114
- move_out = self .picking_out .move_lines [:1 ]
107
+ move_out = self .picking_out .move_ids [:1 ]
115
108
move_out .quantity_done = move_out .product_uom_qty
116
109
self .picking_out ._action_done ()
117
110
move_out .date = "2019-10-03 00:00:00"
118
111
119
112
picking_out_2 = self .picking_out .copy ()
120
- move_out_2 = picking_out_2 .move_lines [:1 ]
113
+ move_out_2 = picking_out_2 .move_ids [:1 ]
121
114
move_out_2 .quantity_done = move_out_2 .product_uom_qty
122
115
picking_out_2 ._action_done ()
123
116
move_out_2 .date = "2019-10-04 00:00:00"
@@ -154,31 +147,31 @@ def _test_sync_cost_price(self):
154
147
155
148
def _test_sync_cost_price_and_history (self ):
156
149
company_id = self .picking_in .company_id .id
157
- move_in = self .picking_in .move_lines [:1 ]
150
+ move_in = self .picking_in .move_ids [:1 ]
158
151
move_in .quantity_done = move_in .product_uom_qty
159
152
self .picking_in ._action_done ()
160
153
move_in .date = "2019-10-01 00:00:00"
161
154
162
- move_out = self .picking_out .move_lines [:1 ]
155
+ move_out = self .picking_out .move_ids [:1 ]
163
156
move_out .quantity_done = move_out .product_uom_qty
164
157
self .picking_out ._action_done ()
165
158
move_out .date = "2019-10-01 01:00:00"
166
159
167
160
picking_in_2 = self .picking_in .copy ()
168
- move_in_2 = picking_in_2 .move_lines [:1 ]
161
+ move_in_2 = picking_in_2 .move_ids [:1 ]
169
162
move_in_2 .quantity_done = move_in_2 .product_uom_qty
170
163
picking_in_2 ._action_done ()
171
164
move_in_2 .date = "2019-10-01 02:00:00"
172
165
173
166
picking_out_2 = self .picking_out .copy ()
174
- move_out_2 = picking_out_2 .move_lines [:1 ]
167
+ move_out_2 = picking_out_2 .move_ids [:1 ]
175
168
move_out_2 .product_uom_qty = 15
176
169
move_out_2 .quantity_done = move_out_2 .product_uom_qty
177
170
picking_out_2 ._action_done ()
178
171
move_out_2 .date = "2019-10-01 03:00:00"
179
172
180
173
picking_in_3 = self .picking_in .copy ()
181
- move_in_3 = picking_in_3 .move_lines [:1 ]
174
+ move_in_3 = picking_in_3 .move_ids [:1 ]
182
175
move_in_3 .quantity_done = move_in_3 .product_uom_qty
183
176
move_in_3 .price_unit = 2.0
184
177
picking_in_3 ._action_done ()
@@ -215,13 +208,13 @@ def _test_sync_cost_price_and_history(self):
215
208
self .assertEqual (svl_count , 4 ) # TODO: Miralo que no se si es así
216
209
217
210
def _test_sync_cost_price_multi_moves_done_at_same_time (self ):
218
- move_in = self .picking_in .move_lines [:1 ]
211
+ move_in = self .picking_in .move_ids [:1 ]
219
212
move_in .product_uom_qty = 10
220
213
move_in .price_unit = 10.0
221
214
move_in .quantity_done = move_in .product_uom_qty
222
215
223
216
picking_in_2 = self .picking_in .copy ()
224
- move_in_2 = picking_in_2 .move_lines [:1 ]
217
+ move_in_2 = picking_in_2 .move_ids [:1 ]
225
218
move_in_2 .product_uom_qty = 10.0
226
219
move_in_2 .price_unit = 5.0
227
220
move_in_2 .quantity_done = move_in_2 .product_uom_qty
@@ -245,13 +238,13 @@ def _test_sync_cost_price_multi_moves_done_at_same_time(self):
245
238
def _test_change_quantiy_price (self ):
246
239
"""Write quantity and price to zero in a stock valuation layer"""
247
240
self .picking_in .action_assign ()
248
- move_in = self .picking_in .move_lines [:1 ]
241
+ move_in = self .picking_in .move_ids [:1 ]
249
242
self .picking_in .move_line_ids .qty_done = move_in .product_uom_qty
250
243
self .picking_in ._action_done ()
251
244
252
245
picking_in_2 = self .picking_in .copy ()
253
246
picking_in_2 .action_assign ()
254
- move_in_2 = picking_in_2 .move_lines [:1 ]
247
+ move_in_2 = picking_in_2 .move_ids [:1 ]
255
248
move_in_2 .product_uom_qty = 10.0
256
249
move_in_2 .quantity_done = move_in_2 .product_uom_qty
257
250
picking_in_2 ._action_done ()
@@ -300,7 +293,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
300
293
"picking_type_id" : picking_type .id ,
301
294
"location_id" : location_id .id ,
302
295
"location_dest_id" : location_dest_id .id ,
303
- "move_lines " : [
296
+ "move_ids " : [
304
297
(
305
298
0 ,
306
299
0 ,
@@ -319,7 +312,7 @@ def create_picking(self, p_type="IN", qty=1.0, confirmed=True):
319
312
)
320
313
if confirmed :
321
314
picking .action_assign ()
322
- move = picking .move_lines [:1 ]
315
+ move = picking .move_ids [:1 ]
323
316
picking .move_line_ids .qty_done = move .product_uom_qty
324
317
picking ._action_done ()
325
318
return picking , move
@@ -455,52 +448,21 @@ def test_change_quantiy_price_xx(self):
455
448
quant .quantity , quant .product_id .standard_price
456
449
)
457
450
)
458
- # Change qty before cost
459
- move_in_01 .with_context (keep_avco_inventory = True ).quantity_done = 0.0
460
- self .print_svl (
461
- "After force quantity to 0 in first IN move Quant:{} Cost:{}" .format (
462
- quant .quantity , quant .product_id .standard_price
463
- )
464
- )
465
- move_in_01 .stock_valuation_layer_ids .unit_cost = 0.0
466
- self .print_svl (
467
- "After force unit cost to 0 in first IN move Quant:{}" .format (
468
- quant .quantity
469
- )
470
- )
471
-
472
- # Restore to initial values
473
- move_in_01 .with_context (keep_avco_inventory = True ).quantity_done = 10.0
474
- move_in_01 .stock_valuation_layer_ids .unit_cost = 2.0
475
- self .print_svl (
476
- "After restore initial values Quant:{} Standard Price:{}" .format (
477
- quant .quantity , quant .product_id .standard_price
478
- )
479
- )
480
-
481
451
# Change cost before quantity
482
452
move_in_01 .stock_valuation_layer_ids .unit_cost = 0.0
483
453
self .print_svl (
484
454
"After force unit cost to 0 in first IN move Quant:{}" .format (
485
455
quant .quantity
486
456
)
487
457
)
488
- move_in_01 .quantity_done = 0.0
458
+ # Change qty after cost
459
+ move_in_01 .with_context (keep_avco_inventory = True ).quantity_done = 0.0
489
460
self .print_svl (
490
461
"After force quantity to 0 in first IN move Quant:{} Cost:{}" .format (
491
462
quant .quantity , quant .product_id .standard_price
492
463
)
493
464
)
494
465
495
- # Restore to initial values
496
- move_in_01 .stock_valuation_layer_ids .unit_cost = 2.0
497
- move_in_01 .quantity_done = 10.0
498
- self .print_svl (
499
- "After restore initial values Quant:{} Standard Price:{}" .format (
500
- quant .quantity , quant .product_id .standard_price
501
- )
502
- )
503
-
504
466
def print_svl (self , char_info = "" ):
505
467
msg_list = ["{}" .format (char_info )]
506
468
total_qty = total_value = 0.0
0 commit comments