Skip to content

Commit ea7318e

Browse files
Merge pull request #303 from akretion/16.0-mig-purchase_specific_location-mo
[IMP] make orderpoint destination location compatible with stock.rule
2 parents ea710b8 + 9ca15c1 commit ea7318e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from . import stock_orderpoint
22
from . import stock_rule
33
from . import purchase_order
4+
from . import procurement_group
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
2+
3+
from odoo import api, models
4+
5+
6+
class ProcurementGroup(models.Model):
7+
_inherit = "procurement.group"
8+
9+
@api.model
10+
def run(self, procurements, raise_user_error=True):
11+
new_procurements = []
12+
for procurement in procurements:
13+
orderpoint = procurement.values.get("orderpoint_id")
14+
if (
15+
self.env.context.get("from_orderpoint")
16+
and orderpoint.location_destination_id
17+
and orderpoint.location_id == procurement.location_id
18+
):
19+
new_procurements.append(
20+
procurement._replace(location_id=orderpoint.location_destination_id)
21+
)
22+
else:
23+
new_procurements.append(procurement)
24+
return super().run(new_procurements, raise_user_error=raise_user_error)

0 commit comments

Comments
 (0)