mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms_api_rest: add partner type filter in partner list
This commit is contained in:
committed by
Darío Lodeiros
parent
37ed2ab3b6
commit
9297ca17a6
@@ -14,6 +14,7 @@ class PmsPartnerSearchParam(Datamodel):
|
||||
name = fields.String(required=False, allow_none=True)
|
||||
housed = fields.Boolean(required=False, allow_none=True)
|
||||
filter = fields.String(required=False, allow_none=True)
|
||||
filterByType = fields.String(required=False, allow_none=True)
|
||||
|
||||
|
||||
class PmsPartnerInfo(Datamodel):
|
||||
|
||||
@@ -39,6 +39,17 @@ class PmsPartnerService(Component):
|
||||
.mapped("partner_id")
|
||||
)
|
||||
domain.append(("id", "in", partners_housed.ids))
|
||||
if (
|
||||
pms_partner_search_params.filterByType
|
||||
and pms_partner_search_params.filterByType != "all"
|
||||
):
|
||||
if pms_partner_search_params.filterByType == "company":
|
||||
domain.append(("is_company", "=", True))
|
||||
elif pms_partner_search_params.filterByType == "agency":
|
||||
domain.append(("is_agency", "=", True))
|
||||
elif pms_partner_search_params.filterByType == "individual":
|
||||
domain.append(("is_company", "=", False))
|
||||
domain.append(("is_agency", "=", False))
|
||||
if pms_partner_search_params.filter:
|
||||
domain.append(("display_name", "ilike", pms_partner_search_params.filter))
|
||||
if pms_partner_search_params.vatNumberOrName:
|
||||
|
||||
Reference in New Issue
Block a user