[FIX] purchase_stock: mock datetime to avoid midnight

The test test_update_date_planned issued starting just before midnight.
a purchase was created at 23:59:59 then the variable `today` was
assigned to 00:00:01. When comparing the activity generated by the test,
taking 23:59:59.today() and 00:00:01.today() gave two different values.

This commit force the test time to 09:00:00.

Task : 2325270

closes odoo/odoo#56681

X-original-commit: 70c223eebe7edfa26564598c898cb9a8541e349b
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
William Henrotin
2020-08-27 15:25:48 +00:00
parent 9dd65cce3f
commit f6df07020b
@@ -27,7 +27,7 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
'product_qty': 5.0,
'product_uom': cls.product_id_1.uom_po_id.id,
'price_unit': 500.0,
'date_planned': datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'date_planned': datetime.today().replace(hour=9).strftime(DEFAULT_SERVER_DATETIME_FORMAT),
}),
(0, 0, {
'name': cls.product_id_2.name,
@@ -35,7 +35,7 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
'product_qty': 5.0,
'product_uom': cls.product_id_2.uom_po_id.id,
'price_unit': 250.0,
'date_planned': datetime.today().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
'date_planned': datetime.today().replace(hour=9).strftime(DEFAULT_SERVER_DATETIME_FORMAT),
})],
}
@@ -213,11 +213,11 @@ class TestPurchaseOrder(ValuationReconciliationTestCommon):
self.assertEqual(po1.picking_ids[-1].move_lines.product_qty, 10)
def test_update_date_planned(self):
today = datetime.today().replace(hour=9, microsecond=0)
tomorrow = datetime.today().replace(hour=9, microsecond=0) + timedelta(days=1)
po = self.env['purchase.order'].create(self.po_vals)
po.button_confirm()
today = datetime.today().replace(microsecond=0)
tomorrow = datetime.today().replace(microsecond=0) + timedelta(days=1)
# update first line
po._update_date_planned_for_lines([(po.order_line[0], tomorrow)])
self.assertEqual(po.order_line[0].date_planned, tomorrow)