diff --git a/pms_api_rest/datamodels/pms_invoice.py b/pms_api_rest/datamodels/pms_invoice.py index defeb41cd..d3ea667ef 100644 --- a/pms_api_rest/datamodels/pms_invoice.py +++ b/pms_api_rest/datamodels/pms_invoice.py @@ -12,6 +12,7 @@ class PmsInvoiceSearchParam(Datamodel): paymentState = fields.String(required=False, allow_none=True) dateStart = fields.String(required=False, allow_none=True) dateEnd = fields.String(required=False, allow_none=True) + pmsPropertyId = fields.Integer(required=False, allow_none=True) class PmsAccountInvoiceInfo(Datamodel): _name = "pms.invoice.info" @@ -39,6 +40,7 @@ class PmsAccountInvoiceInfo(Datamodel): originDownPaymentId = fields.Integer(required=False, allow_none=True) originAgencyId = fields.Integer(required=False, allow_none=True) ref = fields.String(required=False, allow_none=True) + pmsPropertyId = fields.Integer(required=False, allow_none=True) class PmsInvoiceResults(Datamodel): _name = "pms.invoice.results" diff --git a/pms_api_rest/services/pms_invoice_service.py b/pms_api_rest/services/pms_invoice_service.py index e1909fef0..d378a1fd9 100644 --- a/pms_api_rest/services/pms_invoice_service.py +++ b/pms_api_rest/services/pms_invoice_service.py @@ -43,6 +43,8 @@ class PmsInvoiceService(Component): domain_fields.append( ("origin_agency_id", "=", pms_invoice_search_param.originAgencyId), ) + if pms_invoice_search_param.pmsPropertyId: + domain_fields.append(("pms_property_id", "=", pms_invoice_search_param.pmsPropertyId)) if pms_invoice_search_param.paymentState == "paid": domain_fields.append( ("payment_state", "in", ("paid", "reversed", "invoicing_legacy")) @@ -83,7 +85,6 @@ class PmsInvoiceService(Component): domain = expression.AND([domain_fields, domain_filter[0]]) else: domain = domain_fields - PmsInvoiceResults = self.env.datamodels["pms.invoice.results"] PmsInvoiceInfo = self.env.datamodels["pms.invoice.info"] PmsInvoiceLineInfo = self.env.datamodels["pms.invoice.line.info"] @@ -171,7 +172,8 @@ class PmsInvoiceService(Component): originAgencyId=invoice.origin_agency_id.id if invoice.origin_agency_id else None, - ref=invoice.ref, + ref=invoice.ref if invoice.ref else None, + pmsPropertyId=invoice.pms_property_id if invoice.pms_property_id else None, ) ) return PmsInvoiceResults(