-
-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check orderpoints also for non relocated moves Fix quantity to replenish in case of partial source relocation
- Loading branch information
Showing
8 changed files
with
143 additions
and
43 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
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,11 +1,12 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# Copyright 2023 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "stock_location_orderpoint_source_relocate", | ||
"author": "MT Software, Odoo Community Association (OCA)", | ||
"author": "MT Software, BCIM, Odoo Community Association (OCA)", | ||
"summary": "Run an auto location orderpoint replenishment " | ||
"also after a move gets relocated by Stock Move Source Relocate", | ||
"after the move relocation done by Stock Move Source Relocate", | ||
"version": "14.0.1.0.2", | ||
"development_status": "Alpha", | ||
"data": [], | ||
|
@@ -14,6 +15,6 @@ | |
"stock_move_source_relocate", | ||
], | ||
"license": "AGPL-3", | ||
"maintainers": ["mt-software-de"], | ||
"maintainers": ["mt-software-de", "jbaudoux"], | ||
"website": "https://github.com/OCA/stock-logistics-warehouse", | ||
} |
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 +1,2 @@ | ||
from . import stock_location_orderpoint | ||
from . import stock_move |
43 changes: 43 additions & 0 deletions
43
stock_location_orderpoint_source_relocate/models/stock_location_orderpoint.py
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,43 @@ | ||
# Copyright 2023 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import api, models | ||
from odoo.tools import float_round | ||
|
||
|
||
class StockLocationOrderpoint(models.Model): | ||
_inherit = "stock.location.orderpoint" | ||
|
||
@api.model | ||
def _compute_quantities_dict(self, locations, products): | ||
qties = super()._compute_quantities_dict(locations, products) | ||
# With the source relocation, we could have stock on the location that | ||
# is reserved by moves with a source location on the parent location. | ||
# Those moves are not considered by the standard virtual available | ||
# stock. | ||
Move = self.env["stock.move"].with_context(active_test=False) | ||
for location, location_dict in qties.items(): | ||
products = products.with_context(location=location.id) | ||
_, _, domain_move_out_loc = products._get_domain_locations() | ||
domain_move_out_loc_todo = [ | ||
( | ||
"state", | ||
"in", | ||
("waiting", "confirmed", "assigned", "partially_available"), | ||
) | ||
] + domain_move_out_loc | ||
for product, qty in location_dict.items(): | ||
moves = Move.search( | ||
domain_move_out_loc_todo + [("product_id", "=", product.id)], | ||
order="id", | ||
) | ||
rounding = product.uom_id.rounding | ||
unreserved_availability = float_round( | ||
qty["outgoing_qty"] - sum(m.reserved_availability for m in moves), | ||
precision_rounding=rounding, | ||
) | ||
qty["virtual_available"] = float_round( | ||
qty["free_qty"] + qty["incoming_qty"] - unreserved_availability, | ||
precision_rounding=rounding, | ||
) | ||
|
||
return qties |
20 changes: 8 additions & 12 deletions
20
stock_location_orderpoint_source_relocate/models/stock_move.py
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,22 +1,18 @@ | ||
# Copyright 2023 Michael Tietz (MT Software) <[email protected]> | ||
# Copyright 2023 Jacques-Etienne Baudoux (BCIM) <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class StockMove(models.Model): | ||
_inherit = "stock.move" | ||
|
||
def _action_assign(self, *args, **kwargs): | ||
def _action_assign(self): | ||
self = self.with_context(skip_auto_replenishment=True) | ||
res = super()._action_assign(*args, **kwargs) | ||
self = self.with_context(skip_auto_replenishment=False) | ||
return res | ||
super()._action_assign() | ||
|
||
def _apply_source_relocate_rule(self, *args, **kwargs): | ||
relocated = super()._apply_source_relocate_rule(*args, **kwargs) | ||
if not relocated: | ||
return relocated | ||
relocated.with_context( | ||
skip_auto_replenishment=False | ||
)._prepare_auto_replenishment_for_waiting_moves() | ||
return relocated | ||
def _apply_source_relocate(self): | ||
res = super()._apply_source_relocate() | ||
res = res.with_context(skip_auto_replenishment=False) | ||
res._prepare_auto_replenishment_for_waiting_moves() | ||
return res |
1 change: 1 addition & 0 deletions
1
stock_location_orderpoint_source_relocate/readme/CONTRIBUTORS.rst
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 +1,2 @@ | ||
* Michael Tietz (MT Software) <[email protected]> | ||
* Jacques-Etienne Baudoux (BCIM) <[email protected]> |
2 changes: 1 addition & 1 deletion
2
stock_location_orderpoint_source_relocate/readme/DESCRIPTION.rst
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 +1 @@ | ||
Run an auto location orderpoint replenishment also after a move gets relocated by Stock Move Source Relocate | ||
Run the auto location orderpoint replenishment after the potiential move relocation by Stock Move Source Relocate |
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