summaryrefslogtreecommitdiff
path: root/addons/purchase_stock/tests
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-02-27 08:06:12 +0000
committerNicolas Martinelli <nim@odoo.com>2020-03-09 08:33:58 +0000
commit121c73246dfe455cfd0a86af7515d28bc0a79661 (patch)
treebe6a363e310e6850bee4965e78af45097582fa6f /addons/purchase_stock/tests
parent74847914977210b1d5a80c1d586eb1316324d9d7 (diff)
[FIX] stock: change of scheduled date
- Install Inventory, Purchase - General Settings/tick Multi-step routes - In Warehouses/YourCompany Incoming Shipments: Receive goods in input, then quality and then stock (3 steps) - Create a PO and add the same products on 2 lines. One has a scheduled date in the future - Go to transfers, where "Picking List" or "Procurement Group" correspond to your PO => the 3 scheduled_date correspond to Datetime.now() - Validate the first picking (WH/IN) The scheduled_date (resp date_expected) in the remaining pickings WH/INT (resp. stock moves) are changed to the past. This is due to the fact that both moves are merged in subsequent pickings. The cleanest solution would be to avoid the merge in case the expected dates are different. Although this makes sense, that also implies a change of behavior. Therefore, we avoid such situation by preventing the propagation of an expected date in the past, which does not make much sense when propagating. opw-2171509 closes odoo/odoo#47155 X-original-commit: c7b2341b35aabe394a34e14c48a913a8595737fc Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Co-authored-by: Arnold Moyaux <arm@odoo.com>
Diffstat (limited to 'addons/purchase_stock/tests')
-rw-r--r--addons/purchase_stock/tests/test_create_picking.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/addons/purchase_stock/tests/test_create_picking.py b/addons/purchase_stock/tests/test_create_picking.py
index 271f25686e7..cd6f472c818 100644
--- a/addons/purchase_stock/tests/test_create_picking.py
+++ b/addons/purchase_stock/tests/test_create_picking.py
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
-from datetime import datetime, timedelta
-from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
+from datetime import date, datetime, timedelta
+
from odoo.addons.product.tests import common
from odoo.tests import Form
+from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
class TestCreatePicking(common.TestProductCommon):
@@ -470,6 +471,46 @@ class TestCreatePicking(common.TestProductCommon):
self.assertNotEqual(purchase_order_line.date_planned, delivery_order.scheduled_date,
'Delivery order schedule date should not changed.')
+ def test_07_differed_schedule_date(self):
+ warehouse = self.env['stock.warehouse'].search([], limit=1)
+
+ # mark all rules as propagate_date so that push rules will use it
+ self.env['stock.rule'].search([]).write({
+ 'propagate_date': True,
+ 'propagate_date_minimum_delta': 5,
+ })
+
+ with Form(warehouse) as w:
+ w.reception_steps = 'three_steps'
+ po_form = Form(self.env['purchase.order'])
+ po_form.partner_id = self.partner_id
+ with po_form.order_line.new() as line:
+ line.product_id = self.product_id_1
+ line.date_planned = datetime.today()
+ line.product_qty = 1.0
+ with po_form.order_line.new() as line:
+ line.product_id = self.product_id_1
+ line.date_planned = datetime.today() + timedelta(days=7)
+ line.product_qty = 1.0
+ po = po_form.save()
+
+ # mark the po line as propagate_date so that the created moves will use it
+ po.order_line.write({
+ 'propagate_date': True,
+ 'propagate_date_minimum_delta': 5,
+ })
+
+ po.button_approve()
+
+ po.picking_ids.move_line_ids.write({
+ 'qty_done': 1.0
+ })
+ po.picking_ids.button_validate()
+
+ pickings = self.env['stock.picking'].search([('group_id', '=', po.group_id.id)])
+ for picking in pickings:
+ self.assertEqual(picking.scheduled_date.date(), date.today())
+
def test_update_quantity_and_return(self):
po = self.env['purchase.order'].create(self.po_vals)