Skip to content

Commit adc1c9e

Browse files
[UPD] tests
1 parent b457c89 commit adc1c9e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

stock_move_actual_date/tests/test_stock_move_actual_date.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ def setUpClass(cls):
2929
)
3030
cls.supplier_location = cls.env.ref("stock.stock_location_suppliers")
3131
cls.stock_location = cls.env.ref("stock.stock_location_stock")
32-
cls.env.user.tz = "Asia/Tokyo"
3332

3433
def create_picking(self, actual_date=False):
3534
receipt = self.env["stock.picking"].create(
@@ -87,28 +86,26 @@ def test_stock_move_actual_date(self):
8786
self.assertEqual(
8887
move.stock_valuation_layer_ids.account_move_id.date, date(2024, 9, 1)
8988
)
90-
# Update actual_date after done
9189
receipt.actual_date = date(2024, 8, 1)
9290
self.assertEqual(move.actual_date, date(2024, 8, 1))
9391
self.assertEqual(
9492
move.stock_valuation_layer_ids.account_move_id.date, date(2024, 8, 1)
9593
)
96-
# Create scrap
9794
scrap = self.create_scrap(receipt, date(2024, 9, 10))
9895
self.assertEqual(scrap.move_id.actual_date, date(2024, 9, 10))
9996
self.assertEqual(
10097
scrap.move_id.stock_valuation_layer_ids.account_move_id.date,
10198
date(2024, 9, 10),
10299
)
103-
# Update actual_date after done
104100
scrap.actual_date = date(2024, 8, 11)
105101
self.assertEqual(scrap.move_id.actual_date, date(2024, 8, 11))
106102
self.assertEqual(
107103
scrap.move_id.stock_valuation_layer_ids.account_move_id.date,
108104
date(2024, 8, 11),
109105
)
110106

111-
# Test inventory adjustment with actual date
107+
def test_inventory_adjustment_actual_date(self):
108+
_, _ = self.create_picking()
112109
inventory_quant = self.env["stock.quant"].search(
113110
[
114111
("location_id", "=", self.stock_location.id),
@@ -117,7 +114,11 @@ def test_stock_move_actual_date(self):
117114
)
118115
inventory_quant.inventory_quantity = 20.0
119116
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()
121122
move = self.env["stock.move"].search(
122123
[("product_id", "=", self.product_1.id), ("is_inventory", "=", True)],
123124
limit=1,
@@ -129,6 +130,7 @@ def test_stock_move_actual_date(self):
129130

130131
@freeze_time("2024-09-20 23:00:00")
131132
def test_stock_move_without_actual_date_from_picking_or_scrap(self):
133+
self.env.user.tz = "Asia/Tokyo"
132134
receipt, move = self.create_picking()
133135
self.assertEqual(move.actual_date, date(2024, 9, 21))
134136
self.assertEqual(

0 commit comments

Comments
 (0)