Skip to content

Commit

Permalink
[DEL]pms: delete priority reservation/folio compute field
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Dec 30, 2024
1 parent 1113c09 commit 38d2b97
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 105 deletions.
15 changes: 0 additions & 15 deletions pms/data/cron_jobs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,6 @@
<field name="code">model.auto_departure_delayed()</field>
</record>

<record model="ir.cron" id="priority_reservations">
<field name="name">Recompute priority on reservations</field>
<field name="interval_number">1</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="model_pms_reservation" />
<field
name="nextcall"
eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 05:30:00')"
/>
<field name="code">model.update_daily_priority_reservation()</field>
</record>
<!-- Scheduler for send confirmed email -->
<!-- <record model="ir.cron" id="send_confirmation_email_folio">
<field name="name">Send Confirmation Email</field>
Expand Down
14 changes: 1 addition & 13 deletions pms/models/pms_folio.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,6 @@ class PmsFolio(models.Model):
compute="_compute_amount_all",
tracking=True,
)
max_reservation_priority = fields.Integer(
string="Max reservation priority on the entire folio",
help="Max reservation priority on the entire folio",
compute="_compute_max_reservation_priority",
store=True,
)
invoice_status = fields.Selection(
string="Invoice Status",
help="Invoice Status; it can be: invoiced, to invoice, to confirm, no",
Expand Down Expand Up @@ -1368,12 +1362,6 @@ def _get_amount_vals(self, mls, advance_amount, folio_ids=False):
}
return vals

@api.depends("reservation_ids", "reservation_ids.priority")
def _compute_max_reservation_priority(self):
for record in self.filtered("reservation_ids"):
reservation_priors = record.reservation_ids.mapped("priority")
record.max_reservation_priority = max(reservation_priors)

def _compute_checkin_partner_count(self):
for record in self:
if (
Expand Down Expand Up @@ -2196,7 +2184,7 @@ def do_payment(
# Review: force to autoreconcile payment with invoices already created
pay.flush()
for move in folio.move_ids:
move._autoreconcile_folio_payments()
move.sudo()._autoreconcile_folio_payments()

# Automatic register payment in cash register
# TODO: cash_register to avoid flow in the new api (delete it in the future)
Expand Down
77 changes: 0 additions & 77 deletions pms/models/pms_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ class PmsReservation(models.Model):
help="Techinal field to get reservation name",
readonly=True,
)
priority = fields.Integer(
string="Priority",
help="Priority of a reservation",
store="True",
compute="_compute_priority",
)
preferred_room_id = fields.Many2one(
string="Room",
help="It's the preferred room assigned to reservation, "
Expand Down Expand Up @@ -772,71 +766,6 @@ def _compute_check_adults(self):
for record in self:
record.check_adults = True

@api.depends(
"checkin",
"checkout",
"state",
"folio_payment_state",
"to_assign",
)
def _compute_priority(self):
# TODO: Notifications priority
for record in self:
if record.to_assign or record.state in (
"arrival_delayed",
"departure_delayed",
):
record.priority = 1
elif record.state == "cancel":
record.priority = record.cancel_priority()
elif record.state == "onboard":
record.priority = record.onboard_priority()
elif record.state in ("draf", "confirm"):
record.priority = record.reservations_future_priority()
elif record.state == "done":
record.priority = record.reservations_past_priority()

def cancel_priority(self):
self.ensure_one()
if self.folio_pending_amount > 0:
return 2
elif self.checkout >= fields.date.today():
return 100
else:
return 1000 * (fields.date.today() - self.checkout).days

def onboard_priority(self):
self.ensure_one()
days_for_checkout = (self.checkout - fields.date.today()).days
if self.folio_pending_amount > 0:
return days_for_checkout
else:
return 3 * days_for_checkout

def reservations_future_priority(self):
self.ensure_one()
days_for_checkin = (self.checkin - fields.date.today()).days
if days_for_checkin < 3:
return 2 * days_for_checkin
elif days_for_checkin < 20:
return 3 * days_for_checkin
else:
return 4 * days_for_checkin

def reservations_past_priority(self):
self.ensure_one()
if self.folio_pending_amount > 0:
return 3
days_from_checkout = (fields.date.today() - self.checkout).days
if days_from_checkout <= 1:
return 6
elif days_from_checkout < 15:
return 5 * days_from_checkout
elif days_from_checkout <= 90:
return 10 * days_from_checkout
elif days_from_checkout > 90:
return 100 * days_from_checkout

@api.depends("pricelist_id", "room_type_id")
def _compute_board_service_room_id(self):
for reservation in self:
Expand Down Expand Up @@ -2341,12 +2270,6 @@ def autocheckout(self, reservation):
)
return True

@api.model
def update_daily_priority_reservation(self):
reservations = self.env["pms.reservation"].search([("priority", "<", 1000)])
reservations._compute_priority()
return True

def action_confirm(self):
for record in self:
vals = {}
Expand Down

0 comments on commit 38d2b97

Please sign in to comment.