forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.py
44 lines (40 loc) · 1.3 KB
/
product.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 2017 Today Mourad EL HADJ MIMOUNE @ Akretion
# Copyright 2020 Tecnativa - Manuel Calero
# Copyright 2020 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class ProductProduct(models.Model):
_inherit = "product.product"
@api.model
def _search(
self,
args,
offset=0,
limit=None,
order=None,
count=False,
access_rights_uid=None,
):
if self.env.context.get("use_only_supplied_product"):
restrict_supplier_id = self.env.context.get("restrict_supplier_id")
seller = (
self.env["res.partner"]
.browse(restrict_supplier_id)
.commercial_partner_id
)
supplierinfos = self.env["product.supplierinfo"].search(
[("partner_id", "=", seller.id)]
)
args += [
"|",
("product_tmpl_id", "in", supplierinfos.product_tmpl_id.ids),
("id", "in", supplierinfos.product_id.ids),
]
return super()._search(
args,
offset=offset,
limit=limit,
order=order,
count=count,
access_rights_uid=access_rights_uid,
)