mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] origin and priority
This commit is contained in:
@@ -46,6 +46,11 @@ class PmsFolio(models.Model):
|
|||||||
states={"done": [("readonly", True)]},
|
states={"done": [("readonly", True)]},
|
||||||
help="Room reservation detail.",
|
help="Room reservation detail.",
|
||||||
)
|
)
|
||||||
|
number_of_rooms = fields.Integer(
|
||||||
|
"Number of Rooms",
|
||||||
|
compute="_compute_number_of_rooms",
|
||||||
|
store="True",
|
||||||
|
)
|
||||||
service_ids = fields.One2many(
|
service_ids = fields.One2many(
|
||||||
"pms.service",
|
"pms.service",
|
||||||
"folio_id",
|
"folio_id",
|
||||||
@@ -289,6 +294,13 @@ class PmsFolio(models.Model):
|
|||||||
sequence = fields.Integer(string="Sequence", default=10)
|
sequence = fields.Integer(string="Sequence", default=10)
|
||||||
|
|
||||||
# Compute and Search methods
|
# Compute and Search methods
|
||||||
|
@api.depends("reservation_ids", "reservation_ids.state")
|
||||||
|
def _compute_number_of_rooms(self):
|
||||||
|
for folio in self:
|
||||||
|
folio.number_of_rooms = len(folio.reservation_ids.filtered(
|
||||||
|
lambda a: a.state != "cancelled"
|
||||||
|
))
|
||||||
|
|
||||||
@api.depends("partner_id")
|
@api.depends("partner_id")
|
||||||
def _compute_pricelist_id(self):
|
def _compute_pricelist_id(self):
|
||||||
for folio in self:
|
for folio in self:
|
||||||
@@ -300,6 +312,7 @@ class PmsFolio(models.Model):
|
|||||||
if folio.pricelist_id.id != pricelist_id:
|
if folio.pricelist_id.id != pricelist_id:
|
||||||
# TODO: Warning change de pricelist?
|
# TODO: Warning change de pricelist?
|
||||||
folio.pricelist_id = pricelist_id
|
folio.pricelist_id = pricelist_id
|
||||||
|
|
||||||
@api.depends("partner_id")
|
@api.depends("partner_id")
|
||||||
def _compute_user_id(self):
|
def _compute_user_id(self):
|
||||||
for folio in self:
|
for folio in self:
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ class PmsReservation(models.Model):
|
|||||||
name = fields.Text(
|
name = fields.Text(
|
||||||
"Reservation Description", compute="_compute_name", store=True, readonly=False,
|
"Reservation Description", compute="_compute_name", store=True, readonly=False,
|
||||||
)
|
)
|
||||||
|
priority = fields.Integer(compute="_compute_priority", store="True", index=True)
|
||||||
room_id = fields.Many2one(
|
room_id = fields.Many2one(
|
||||||
"pms.room",
|
"pms.room",
|
||||||
string="Room",
|
string="Room",
|
||||||
@@ -293,6 +294,15 @@ class PmsReservation(models.Model):
|
|||||||
string="Sales Channel",
|
string="Sales Channel",
|
||||||
default="direct",
|
default="direct",
|
||||||
)
|
)
|
||||||
|
subchannel_direct = fields.Selection([
|
||||||
|
("door", "Door"),
|
||||||
|
("mail", "Mail"),
|
||||||
|
("phone", "Phone"),
|
||||||
|
],
|
||||||
|
string="Direct Channel",
|
||||||
|
)
|
||||||
|
origin = fields.Char("Origin", compute="_compute_origin", store=True)
|
||||||
|
detail_origin = fields.Char("Detail Origin", compute="_compute_detail_origin", store=True)
|
||||||
# TODO: Review functionality of last_update_res
|
# TODO: Review functionality of last_update_res
|
||||||
last_updated_res = fields.Datetime(
|
last_updated_res = fields.Datetime(
|
||||||
"Last Updated", compute="_compute_last_updated_res", store=True, readonly=False,
|
"Last Updated", compute="_compute_last_updated_res", store=True, readonly=False,
|
||||||
@@ -412,6 +422,11 @@ class PmsReservation(models.Model):
|
|||||||
else:
|
else:
|
||||||
reservation.name = "/"
|
reservation.name = "/"
|
||||||
|
|
||||||
|
@api.depends("checkin")
|
||||||
|
def _compute_priority(self):
|
||||||
|
#TODO: Logic priority (100 by example)
|
||||||
|
self.priority = 100
|
||||||
|
|
||||||
@api.depends("reservation_line_ids", "reservation_line_ids.room_id")
|
@api.depends("reservation_line_ids", "reservation_line_ids.room_id")
|
||||||
def _compute_room_id(self):
|
def _compute_room_id(self):
|
||||||
for reservation in self:
|
for reservation in self:
|
||||||
@@ -1053,6 +1068,20 @@ class PmsReservation(models.Model):
|
|||||||
record.checkin_partner_count = 0
|
record.checkin_partner_count = 0
|
||||||
record.checkin_partner_pending_count = 0
|
record.checkin_partner_pending_count = 0
|
||||||
|
|
||||||
|
@api.depends("channel_type", "subchannel_direct")
|
||||||
|
def _compute_origin(self):
|
||||||
|
for reservation in self:
|
||||||
|
if reservation.channel_type == "direct":
|
||||||
|
reservation.origin = reservation.subchannel_direct
|
||||||
|
elif reservation.channel_type == "agency":
|
||||||
|
reservation.origin = reservation.agency_id.name
|
||||||
|
|
||||||
|
@api.depends("origin")
|
||||||
|
def _compute_detail_origin(self):
|
||||||
|
for reservation in self:
|
||||||
|
if reservation.channel_type in ["direct","agency"]:
|
||||||
|
reservation.detail_origin = reservation.sudo().create_uid.name
|
||||||
|
|
||||||
# https://www.odoo.com/es_ES/forum/ayuda-1/question/calculated-fields-in-search-filter-possible-118501
|
# https://www.odoo.com/es_ES/forum/ayuda-1/question/calculated-fields-in-search-filter-possible-118501
|
||||||
|
|
||||||
def _search_checkin_partner_pending(self, operator, value):
|
def _search_checkin_partner_pending(self, operator, value):
|
||||||
|
|||||||
Reference in New Issue
Block a user