diff options
| author | William Henrotin <whe@odoo.com> | 2020-02-04 11:08:24 +0000 |
|---|---|---|
| committer | William Henrotin <whe@odoo.com> | 2020-02-04 15:07:12 +0000 |
| commit | 26be4a7bde1aab8733da232c9863e5b8f8e37a66 (patch) | |
| tree | d00f7fc3176d8571a90623710bf8cc2c3cd8fd56 /addons/purchase_stock/tests | |
| parent | 6ff84799373056059ce5db6601ca98e30cd507a0 (diff) | |
[FIX] purchase_stock: confuse return move and move dest
Increasing the quantity on a purchase order line will create a stock
move with the delta quantity. In case the purchase order has a return
among its picking_ids, the delta will be wrong.
This is due to the fact a return move is considered like a move_dest
of the original incoming move. The delta quantity will be computed
from the return move which doens't make sense.
This commit excludes outgoing moves from move_dest to avoid taking
return move into account.
closes odoo/odoo#44551
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Diffstat (limited to 'addons/purchase_stock/tests')
| -rw-r--r-- | addons/purchase_stock/tests/test_create_picking.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/addons/purchase_stock/tests/test_create_picking.py b/addons/purchase_stock/tests/test_create_picking.py index 8a001a41cbb..271f25686e7 100644 --- a/addons/purchase_stock/tests/test_create_picking.py +++ b/addons/purchase_stock/tests/test_create_picking.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT from odoo.addons.product.tests import common +from odoo.tests import Form class TestCreatePicking(common.TestProductCommon): @@ -468,3 +469,40 @@ class TestCreatePicking(common.TestProductCommon): # Now check scheduled date of delivery order is changed or not. self.assertNotEqual(purchase_order_line.date_planned, delivery_order.scheduled_date, 'Delivery order schedule date should not changed.') + + def test_update_quantity_and_return(self): + po = self.env['purchase.order'].create(self.po_vals) + + po.order_line.product_qty = 10 + po.button_confirm() + + first_picking = po.picking_ids + first_picking.move_lines.quantity_done = 5 + # create the backorder + backorder_wizard_dict = first_picking.button_validate() + backorder_wizard = Form(self.env[backorder_wizard_dict['res_model']].with_context(backorder_wizard_dict['context'])).save() + backorder_wizard.process() + + self.assertEqual(len(po.picking_ids), 2) + + # Create a partial return + stock_return_picking_form = Form( + self.env['stock.return.picking'].with_context( + active_ids=first_picking.ids, + active_id=first_picking.ids[0], + active_model='stock.picking' + ) + ) + stock_return_picking = stock_return_picking_form.save() + stock_return_picking.product_return_moves.quantity = 2.0 + stock_return_picking_action = stock_return_picking.create_returns() + return_pick = self.env['stock.picking'].browse(stock_return_picking_action['res_id']) + return_pick.action_assign() + return_pick.move_lines.quantity_done = 2 + return_pick._action_done() + + self.assertEqual(po.order_line.qty_received, 3) + + po.order_line.product_qty += 2 + backorder = po.picking_ids.filtered(lambda picking: picking.state == 'assigned') + self.assertEqual(backorder.move_lines.product_uom_qty, 7) |
