-
-
Notifications
You must be signed in to change notification settings - Fork 733
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support split of moves for sourcing from different zones
When a move has several move lines because it is sourced from different locations, and these locations come from different zones, or from a zone and another location which is not a zone, we have to split the move in as many moves as we have zones, and chain them properly. This is needed because otherwise, the move for, for instance taking goods from a shelf would have to wait on the move taking from the Higbay which has been added in front of it. We expect that we can already process the Shelf one. The algorithm is to find all the zones of a move, split the move if any. But to do so, we have to unreserve the move first. As we want to keep the same quantities from the same locations (eg. 6 from the highbay bin 1), when we reserve again the quants, we have to force the reservation system to take the goods from the same location than we had originally (otherwise, the quantities that we used to split the move may change and we are back to the beginning).
- Loading branch information
Showing
4 changed files
with
261 additions
and
24 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,2 +1,3 @@ | ||
from . import stock_move | ||
from . import stock_picking_type | ||
from . import stock_quant |
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,59 @@ | ||
# Copyright 2019 Camptocamp (https://www.camptocamp.com) | ||
|
||
"""Allow forcing reservations of quants in a location (or children) | ||
When the context key "gather_in_location_id" is passed, it will look | ||
in this location or its children. | ||
Example:: | ||
moves.with_context( | ||
gather_in_location_id=location.id, | ||
)._action_assign() | ||
""" | ||
|
||
from odoo import models | ||
|
||
|
||
class StockQuant(models.Model): | ||
_inherit = 'stock.quant' | ||
|
||
def _update_reserved_quantity(self, product_id, location_id, quantity, | ||
lot_id=None, package_id=None, owner_id=None, | ||
strict=False): | ||
gather_in_location_id = self.env.context.get('gather_in_location_id') | ||
if gather_in_location_id: | ||
location_model = self.env['stock.location'] | ||
location_id = location_model.browse(gather_in_location_id) | ||
result = super()._update_reserved_quantity( | ||
product_id, location_id, quantity, lot_id=lot_id, | ||
package_id=package_id, owner_id=owner_id, strict=strict, | ||
) | ||
return result | ||
|
||
def _update_available_quantity(self, product_id, location_id, quantity, | ||
lot_id=None, package_id=None, owner_id=None, | ||
in_date=None): | ||
gather_in_location_id = self.env.context.get('gather_in_location_id') | ||
if gather_in_location_id: | ||
location_model = self.env['stock.location'] | ||
location_id = location_model.browse(gather_in_location_id) | ||
result = super()._update_available_quantity( | ||
product_id, location_id, quantity, lot_id=lot_id, | ||
package_id=package_id, owner_id=owner_id, in_date=in_date, | ||
) | ||
return result | ||
|
||
def _get_available_quantity(self, product_id, location_id, lot_id=None, | ||
package_id=None, owner_id=None, strict=False, | ||
allow_negative=False): | ||
gather_in_location_id = self.env.context.get('gather_in_location_id') | ||
if gather_in_location_id: | ||
location_model = self.env['stock.location'] | ||
location_id = location_model.browse(gather_in_location_id) | ||
result = super()._get_available_quantity( | ||
product_id, location_id, lot_id=lot_id, | ||
package_id=package_id, owner_id=owner_id, strict=strict, | ||
) | ||
return result |
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