-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79f613b
commit eb1582a
Showing
8 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
from . import pms_folio_short_info | ||
from . import pms_calendar_search_param | ||
from . import pms_calendar_short_info | ||
|
||
from . import pms_folio_search_param | ||
from . import pms_folio_short_info | ||
|
||
from . import pms_room_short_info | ||
from . import pms_room_search_param |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from marshmallow import fields | ||
|
||
from odoo.addons.datamodel.core import Datamodel | ||
|
||
|
||
class PmsCalendarSearchParam(Datamodel): | ||
_name = "pms.calendar.search.param" | ||
date_from = fields.String(required=False, allow_none=True) | ||
date_to = fields.String(required=False, allow_none=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from marshmallow import fields | ||
|
||
from odoo.addons.datamodel.core import Datamodel | ||
|
||
|
||
class PmsCalendarShortInfo(Datamodel): | ||
_name = "pms.calendar.short.info" | ||
date = fields.String(required=False, allow_none=True) | ||
roomId = fields.Integer(required=False, allow_none=True) | ||
partnerId = fields.Integer(required=False, allow_none=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from . import folio_services | ||
from . import room_services | ||
from . import calendar_service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from datetime import datetime | ||
|
||
from odoo.addons.base_rest import restapi | ||
from odoo.addons.base_rest_datamodel.restapi import Datamodel | ||
from odoo.addons.component.core import Component | ||
|
||
|
||
class PmsCalendarService(Component): | ||
_inherit = "base.rest.service" | ||
_name = "pms.calendar.service" | ||
_usage = "calendar" | ||
_collection = "pms.reservation.service" | ||
|
||
@restapi.method( | ||
[ | ||
( | ||
[ | ||
"/", | ||
], | ||
"GET", | ||
) | ||
], | ||
input_param=Datamodel("pms.calendar.search.param"), | ||
output_param=Datamodel("pms.calendar.short.info", is_list=True), | ||
auth="public", | ||
) | ||
def get_calendar(self, calendar_search_param): | ||
domain = [] | ||
if calendar_search_param.date_from: | ||
domain.append(("date", ">=", datetime.fromisoformat(calendar_search_param.date_from))) | ||
if calendar_search_param.date_to: | ||
domain.append(("date", "<=", datetime.fromisoformat(calendar_search_param.date_to))) | ||
result_lines = [] | ||
PmsCalendarShortInfo = self.env.datamodels["pms.calendar.short.info"] | ||
for line in ( | ||
self.env["pms.reservation.line"] | ||
.sudo() | ||
.search( | ||
domain, | ||
) | ||
): | ||
result_lines.append( | ||
PmsCalendarShortInfo( | ||
roomId=line.room_id.id, | ||
date=datetime.combine(line.date, datetime.min.time()).isoformat(), | ||
partnerId=line.reservation_id.partner_id.id, | ||
) | ||
) | ||
return result_lines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters