Skip to content

Commit

Permalink
[IMP] make orderpoint destination location compatible with stock.rule
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-dacosta committed Jun 18, 2024
1 parent ea710b8 commit 9ca15c1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions purchase_specific_location/models/__init__.py
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
24 changes: 24 additions & 0 deletions purchase_specific_location/models/procurement_group.py
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)

0 comments on commit 9ca15c1

Please sign in to comment.