@@ -29,7 +29,6 @@ def setUpClass(cls):
29
29
)
30
30
cls .supplier_location = cls .env .ref ("stock.stock_location_suppliers" )
31
31
cls .stock_location = cls .env .ref ("stock.stock_location_stock" )
32
- cls .env .user .tz = "Asia/Tokyo"
33
32
34
33
def create_picking (self , actual_date = False ):
35
34
receipt = self .env ["stock.picking" ].create (
@@ -87,28 +86,26 @@ def test_stock_move_actual_date(self):
87
86
self .assertEqual (
88
87
move .stock_valuation_layer_ids .account_move_id .date , date (2024 , 9 , 1 )
89
88
)
90
- # Update actual_date after done
91
89
receipt .actual_date = date (2024 , 8 , 1 )
92
90
self .assertEqual (move .actual_date , date (2024 , 8 , 1 ))
93
91
self .assertEqual (
94
92
move .stock_valuation_layer_ids .account_move_id .date , date (2024 , 8 , 1 )
95
93
)
96
- # Create scrap
97
94
scrap = self .create_scrap (receipt , date (2024 , 9 , 10 ))
98
95
self .assertEqual (scrap .move_id .actual_date , date (2024 , 9 , 10 ))
99
96
self .assertEqual (
100
97
scrap .move_id .stock_valuation_layer_ids .account_move_id .date ,
101
98
date (2024 , 9 , 10 ),
102
99
)
103
- # Update actual_date after done
104
100
scrap .actual_date = date (2024 , 8 , 11 )
105
101
self .assertEqual (scrap .move_id .actual_date , date (2024 , 8 , 11 ))
106
102
self .assertEqual (
107
103
scrap .move_id .stock_valuation_layer_ids .account_move_id .date ,
108
104
date (2024 , 8 , 11 ),
109
105
)
110
106
111
- # Test inventory adjustment with actual date
107
+ def test_inventory_adjustment_actual_date (self ):
108
+ _ , _ = self .create_picking ()
112
109
inventory_quant = self .env ["stock.quant" ].search (
113
110
[
114
111
("location_id" , "=" , self .stock_location .id ),
@@ -117,7 +114,11 @@ def test_stock_move_actual_date(self):
117
114
)
118
115
inventory_quant .inventory_quantity = 20.0
119
116
inventory_quant .accounting_date = date (2024 , 7 , 1 )
120
- inventory_quant .action_apply_inventory ()
117
+ move = self .env ["stock.move" ].search (
118
+ [("product_id" , "=" , self .product_1 .id ), ("is_inventory" , "=" , True )],
119
+ limit = 1 ,
120
+ )
121
+ inventory_quant ._apply_inventory ()
121
122
move = self .env ["stock.move" ].search (
122
123
[("product_id" , "=" , self .product_1 .id ), ("is_inventory" , "=" , True )],
123
124
limit = 1 ,
@@ -129,6 +130,7 @@ def test_stock_move_actual_date(self):
129
130
130
131
@freeze_time ("2024-09-20 23:00:00" )
131
132
def test_stock_move_without_actual_date_from_picking_or_scrap (self ):
133
+ self .env .user .tz = "Asia/Tokyo"
132
134
receipt , move = self .create_picking ()
133
135
self .assertEqual (move .actual_date , date (2024 , 9 , 21 ))
134
136
self .assertEqual (
0 commit comments