mirror of
https://gitlab.com/flectra-community/partner-contact.git
synced 2024-11-15 10:42:06 +00:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
|
# Copyright 2021 Tecnativa - Carlos Dauden
|
||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||
|
|
||
|
from flectra import api, fields, models
|
||
|
|
||
|
|
||
|
class ResPartner(models.Model):
|
||
|
_inherit = "res.partner"
|
||
|
|
||
|
property_product_pricelist = fields.Many2one(
|
||
|
search="_search_property_product_pricelist"
|
||
|
)
|
||
|
|
||
|
@api.model
|
||
|
def search(self, args, offset=0, limit=None, order=None):
|
||
|
# Substitute pricelist tuple
|
||
|
partner_domain = [
|
||
|
(1, "=", 1)
|
||
|
if (isinstance(x, (list | tuple)) and x[0] == "property_product_pricelist")
|
||
|
else x
|
||
|
for x in args
|
||
|
]
|
||
|
return super(
|
||
|
ResPartner, self.with_context(search_partner_domain=partner_domain)
|
||
|
).search(args, offset=offset, limit=limit, order=order)
|
||
|
|
||
|
@api.model
|
||
|
def _search_property_product_pricelist(self, operator, value):
|
||
|
domain = self.env.context.get("search_partner_domain", [])
|
||
|
partners = self.with_context(prefetch_fields=False).search(domain)
|
||
|
key = "property_product_pricelist"
|
||
|
return [("id", "in", partners.filtered_domain([(key, operator, value)]).ids)]
|