-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] make orderpoint destination location compatible with stock.rule
- Loading branch information
1 parent
ea710b8
commit 9ca15c1
Showing
2 changed files
with
25 additions
and
0 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,3 +1,4 @@ | ||
from . import stock_orderpoint | ||
from . import stock_rule | ||
from . import purchase_order | ||
from . import procurement_group |
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,24 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class ProcurementGroup(models.Model): | ||
_inherit = "procurement.group" | ||
|
||
@api.model | ||
def run(self, procurements, raise_user_error=True): | ||
new_procurements = [] | ||
for procurement in procurements: | ||
orderpoint = procurement.values.get("orderpoint_id") | ||
if ( | ||
self.env.context.get("from_orderpoint") | ||
and orderpoint.location_destination_id | ||
and orderpoint.location_id == procurement.location_id | ||
): | ||
new_procurements.append( | ||
procurement._replace(location_id=orderpoint.location_destination_id) | ||
) | ||
else: | ||
new_procurements.append(procurement) | ||
return super().run(new_procurements, raise_user_error=raise_user_error) |