Skip to content

Commit

Permalink
[FIX] pms_api_rest: fix structure errors
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpadin committed May 7, 2024
1 parent 5496377 commit 4af11d3
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 159 deletions.
7 changes: 4 additions & 3 deletions pms_api_rest/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright Commitsun S.L. (https://www.commitsun.com)
# Copyright Nuobit Solutions, S.L. (https://www.nuobit.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "API REST PMS",
"author": "Commit [Sun], Odoo Community Association (OCA)",
"summary": "A property management system API REST",
"website": "https://github.com/OCA/pms",
"category": "Generic Modules/Property Management System",
"version": "14.0.1.0.0",
Expand All @@ -15,16 +19,13 @@
"base_location",
"l10n_es_aeat",
"sql_export_excel",
"feed_rss",
],
"external_dependencies": {
"python": ["jwt", "simplejson", "marshmallow", "jose"],
},
"data": [
"security/ir.model.access.csv",
"data/sql_reports.xml",
"data/auth_jwt_validator.xml",
"data/pms_app_reset_password_template.xml",
"data/cron_jobs.xml",
"views/pms_property_views.xml",
"views/res_users_views.xml",
Expand Down
1 change: 0 additions & 1 deletion pms_api_rest/datamodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
from . import pms_reservation_message
from . import pms_avail
from . import pms_dashboard
from . import feed_post

from . import pms_wizard_state

Expand Down
1 change: 0 additions & 1 deletion pms_api_rest/datamodels/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class PmsReservationShortInfo(Datamodel):
reservationType = fields.String(required=False, allow_none=True)



class PmsReservationInfo(Datamodel):
_name = "pms.reservation.info"
id = fields.Integer(required=False, allow_none=True)
Expand Down
1 change: 1 addition & 0 deletions pms_api_rest/datamodels/pms_wizard_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from odoo.addons.datamodel.core import Datamodel


class PmsWizardStateInfo(Datamodel):
_name = "pms.wizard.state.info"
code = fields.String(required=True, allow_none=False)
Expand Down
38 changes: 38 additions & 0 deletions pms_api_rest/migrations/14.0.1.0.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_xmlids(
env.cr,
[
(
"pms_api_rest.pms_reset_password_email",
"pms_api_rest_roomdoo.pms_reset_password_email",
),
(
"pms_api_rest.date_from_field_variable_sql",
"pms_api_rest_roomdoo.date_from_field_variable_sql",
),
(
"pms_api_rest.date_to_field_variable_sql",
"pms_api_rest_roomdoo.date_to_field_variable_sql",
),
(
"pms_api_rest.pms_property_field_variable_sql",
"pms_api_rest_roomdoo.pms_property_field_variable_sql",
),
(
"pms_api_rest.sql_export_departures",
"pms_api_rest_roomdoo.sql_export_departures",
),
(
"pms_api_rest.sql_export_arrivals",
"pms_api_rest_roomdoo.sql_export_arrivals",
),
(
"pms_api_rest.sql_export_services",
"pms_api_rest_roomdoo.sql_export_services",
),
],
)
1 change: 0 additions & 1 deletion pms_api_rest/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from . import pms_property
from . import res_users
from . import account_payment
from . import sql_export
from . import pms_room_type_class
from . import account_bank_statement
from . import product_template
Expand Down
19 changes: 11 additions & 8 deletions pms_api_rest/models/pms_checkin_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@


class PmsCheckinPartner(models.Model):
_inherit = 'pms.checkin.partner'
_inherit = "pms.checkin.partner"

origin_input_data = fields.Selection([
('wizard', 'Wizard'),
('form', 'Form'),
('regular_customer', 'Regular Customer'),
('ocr', 'OCR'),
('precheckin', 'Precheckin'),
], string='Origin Input Data')
origin_input_data = fields.Selection(
[
("wizard", "Wizard"),
("form", "Form"),
("regular_customer", "Regular Customer"),
("ocr", "OCR"),
("precheckin", "Precheckin"),
],
string="Origin Input Data",
)
4 changes: 0 additions & 4 deletions pms_api_rest/services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from . import pms_folio_service
from . import pms_room_service
from . import pms_room_type_service
from . import pms_calendar_service
from . import pms_partner_service

from . import pms_reservation_service
Expand Down Expand Up @@ -39,8 +38,5 @@
from . import pms_account_payment_terms_service
from . import pms_account_journal_service
from . import pms_invoice_service
from . import pms_notification_service
from . import pms_avail_service
from . import pms_user_service
from . import pms_dashboard_service
from . import feed_post_service
27 changes: 15 additions & 12 deletions pms_api_rest/services/pms_partner_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,30 @@ def get_partners(self, pms_partner_search_params):
.filtered(lambda x: x.checkout)
.mapped("checkout")
)
doc_record = False
document_number = False
document_type = False
document_support_number = False
document_country_id = False
document_expedition_date = False
if partner.id_numbers:
doc_record = partner.id_numbers[0]
if doc_record:
if doc_record.name:
document_number = doc_record.name
if doc_record.category_id:
document_type = doc_record.category_id.id
if doc_record.support_number:
document_support_number = doc_record.support_number
if doc_record.country_id:
document_country_id = doc_record.country_id.id
if doc_record.valid_from:
document_expedition_date = datetime.combine(
document_number = doc_record.name if doc_record.name else False
document_type = (
doc_record.category_id.id if doc_record.category_id else False
)
document_support_number = (
doc_record.support_number if doc_record.support_number else False
)
document_country_id = (
doc_record.country_id.id if doc_record.country_id else False
)
document_expedition_date = (
datetime.combine(
doc_record.valid_from, datetime.min.time()
).isoformat()
if doc_record.valid_from
else False
)
result_partners.append(
PmsPartnerInfo(
id=partner.id,
Expand Down
15 changes: 11 additions & 4 deletions pms_api_rest/services/pms_reservation_line_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,24 @@ def get_reservation_lines(self, pms_reservation_lines_search_param):
and pms_reservation_lines_search_param.dateTo
and pms_reservation_lines_search_param.pmsPropertyId
):
date_from = datetime.strptime(pms_reservation_lines_search_param.dateFrom, "%Y-%m-%d").date()
date_to = datetime.strptime(pms_reservation_lines_search_param.dateTo, "%Y-%m-%d").date()
date_from = datetime.strptime(
pms_reservation_lines_search_param.dateFrom, "%Y-%m-%d"
).date()
date_to = datetime.strptime(
pms_reservation_lines_search_param.dateTo, "%Y-%m-%d"
).date()

domain = [
("date", ">=", date_from),
("date", "<", date_to),
("pms_property_id", "=", pms_reservation_lines_search_param.pmsPropertyId)
(
"pms_property_id",
"=",
pms_reservation_lines_search_param.pmsPropertyId,
),
]
PmsReservationLineInfo = self.env.datamodels["pms.reservation.line.info"]
for reservation_line in self.env["pms.reservation.line"].search(domain):
print(reservation_line.state)
result.append(
PmsReservationLineInfo(
id=reservation_line.id,
Expand Down
Loading

0 comments on commit 4af11d3

Please sign in to comment.