-
-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0][REF]stock_auto_move: fix action_assign() (#373)
* The `_apply` method should not be overridden. In case of three step operation with the last step set to auto move. The override of the `_apply` method was causing the second move to be automatic as well. **Use case**: doing a reception operation in two steps where the moves on the second step are set to be automatic (using the push rule in this case), and the reception is done partially. **Expected Result**: When doing a first reception step partially a back order is created, and we expect the second step to have a back order for the remaining qty as well. **Current behavior**: The correct move is processed automatically but no backorder is created. The reason for that behavior is we processing the move directly (i.e calling `action_done` of the `stock.move`) without going through the normal process (i.e processing the second step picking). **The solution to the problem**: The processing the of the automatic stock move should follow the same behavior as done from the user interface. I've added a new function in `stock.picking` model called `_transfer_pickings_with_auto_move` to simulate the same behavior this function is called inside the `action_assign` of the stock move instead of calling the `action_done` of the move.
- Loading branch information
1 parent
cf0b656
commit a851aad
Showing
4 changed files
with
261 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
# -*- coding: utf-8 -*- | ||
from . import stock_move | ||
from . import procurement_rule | ||
from . import procurement_order | ||
from . import stock_location_path | ||
from . import stock_picking |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2017 ACSONE SA/NV | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import api, models | ||
|
||
|
||
class StockPicking(models.Model): | ||
|
||
_inherit = 'stock.picking' | ||
|
||
@api.model | ||
def _transfer_pickings_with_auto_move(self, auto_moves_by_pickings): | ||
"""This function is meant to simulate what a user would normally | ||
transfer a picking from the user interface either partial processing | ||
or full processing. | ||
@params auto_moves_by_pickings: dict of moves grouped by pickings | ||
{stock.picking(id): stock.move(id1, id2, id3 ...), ...} | ||
""" | ||
for picking in auto_moves_by_pickings: | ||
if len(picking.move_lines) != len(auto_moves_by_pickings[picking]): | ||
# Create a back order for remaning moves | ||
backorder_moves = \ | ||
picking.move_lines - auto_moves_by_pickings[picking] | ||
self._create_backorder( | ||
picking=picking, backorder_moves=backorder_moves) | ||
|
||
# Create immediate transfer wizard so it will fill the qty_done | ||
# on the auto move linked operation | ||
picking.do_prepare_partial() | ||
wizard = self.env['stock.immediate.transfer'].create( | ||
{'pick_id': picking.id}) | ||
wizard.process() | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters