[IMP] pms_api_rest: add property on domain in get_invoices

This commit is contained in:
Sara Lago
2023-03-08 09:35:38 +01:00
committed by Darío Lodeiros
parent 56eaef7335
commit f2d9d0ee05
2 changed files with 6 additions and 2 deletions

View File

@@ -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"

View File

@@ -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(