forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpurchase_order.py
44 lines (39 loc) · 1.43 KB
/
purchase_order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright 2015 AvanzOsc (http://www.avanzosc.es)
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2015-2021 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import models
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
def _find_candidate(
self,
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
):
"""If not grouping by line, we should make an exception when you update an
existing sales order line, so we filter a bit more by procurement group.
NOTE: This makes that if you manually assign the same procurement group to
several different sales orders, the grouping will be done no matter the grouping
criteria, but this is the only way to do it without having to put a lot of glue
modules, and on standard operation mode, procurement groups are not reused
between sales orders.
"""
obj = self
if values.get("grouping") == "line":
obj = self.filtered(lambda x: x.order_id.group_id == values.get("group_id"))
return super(PurchaseOrderLine, obj)._find_candidate(
product_id,
product_qty,
product_uom,
location_id,
name,
origin,
company_id,
values,
)