[IMP] pms_api_rest: add partner datamodel and service

This commit is contained in:
Sara
2022-08-23 12:17:35 +02:00
committed by Darío Lodeiros
parent 75e4d52469
commit e988239bdd
3 changed files with 7 additions and 6 deletions

View File

@@ -57,3 +57,5 @@ class PmsPartnerInfo(Datamodel):
daysAutoInvoice = fields.Integer(required=False, allow_none=True)
invoicingMonthDay = fields.Integer(required=False, allow_none=True)
invoiceToAgency = fields.String(required=False, allow_none=True)
tagIds = fields.List(fields.Integer(required=False, allow_none=True))
lastStay = fields.String(required=False, allow_none=True)

View File

@@ -107,6 +107,7 @@ class PmsPartnerService(Component):
invoiceToAgency=partner.invoice_to_agency
if partner.invoice_to_agency
else None,
tagIds=partner.category_id.ids if partner.category_id else [],
)
)
return result_partners
@@ -154,7 +155,7 @@ class PmsPartnerService(Component):
"GET",
)
],
output_param=Datamodel("pms.checkin.partner.info", is_list=True),
output_param=Datamodel("pms.partner.info", is_list=True),
auth="jwt_api_pms",
)
def get_partner_by_doc_number(self, document_type, document_number):
@@ -162,7 +163,7 @@ class PmsPartnerService(Component):
[("name", "=", document_number), ("category_id", "=", int(document_type))]
)
partners = []
PmsCheckinPartnerInfo = self.env.datamodels["pms.checkin.partner.info"]
PmsPartnerInfo = self.env.datamodels["pms.partner.info"]
if not doc_number:
pass
else:
@@ -173,7 +174,7 @@ class PmsPartnerService(Component):
"%d/%m/%Y"
)
partners.append(
PmsCheckinPartnerInfo(
PmsPartnerInfo(
# id=doc_number.partner_id.id,
name=doc_number.partner_id.name
if doc_number.partner_id.name

View File

@@ -29,9 +29,7 @@ class PmsPartnerCategoriesService(Component):
ResPartnerCategoryInfo(
id=category.id,
name=category.name,
parentId=category.parent_id.id
if category.parent_id.id
else 0,
parentId=category.parent_id.id if category.parent_id.id else 0,
)
)
return result_categories