mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
@@ -982,31 +982,30 @@ class PmsFolio(models.Model):
|
||||
automatic_included=True
|
||||
)
|
||||
paid_out = 0
|
||||
for journal in journals:
|
||||
paid_out += sum(
|
||||
self.env["account.move.line"]
|
||||
.search(
|
||||
[
|
||||
("folio_ids", "in", record.id),
|
||||
(
|
||||
"account_id",
|
||||
"in",
|
||||
tuple(
|
||||
journal.default_account_id.ids
|
||||
+ journal.payment_debit_account_id.ids
|
||||
+ journal.payment_credit_account_id.ids
|
||||
),
|
||||
paid_out += sum(
|
||||
self.env["account.move.line"]
|
||||
.search(
|
||||
[
|
||||
("folio_ids", "in", record.id),
|
||||
(
|
||||
"account_id",
|
||||
"in",
|
||||
tuple(
|
||||
journals.default_account_id.ids
|
||||
+ journals.payment_debit_account_id.ids
|
||||
+ journals.payment_credit_account_id.ids
|
||||
),
|
||||
(
|
||||
"display_type",
|
||||
"not in",
|
||||
("line_section", "line_note"),
|
||||
),
|
||||
("move_id.state", "!=", "cancel"),
|
||||
]
|
||||
)
|
||||
.mapped("balance")
|
||||
),
|
||||
(
|
||||
"display_type",
|
||||
"not in",
|
||||
("line_section", "line_note"),
|
||||
),
|
||||
("move_id.state", "!=", "cancel"),
|
||||
]
|
||||
)
|
||||
.mapped("balance")
|
||||
)
|
||||
total = record.amount_total
|
||||
# REVIEW: Must We ignored services in cancelled folios
|
||||
# pending amount?
|
||||
@@ -1641,9 +1640,13 @@ class PmsFolio(models.Model):
|
||||
(making sure to call super() to establish a clean extension chain).
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
journal = (
|
||||
self.env["account.move"]
|
||||
.with_context(default_move_type="out_invoice")
|
||||
.with_context(
|
||||
default_move_type="out_invoice",
|
||||
default_company_id=self.company_id.id,
|
||||
)
|
||||
._get_default_journal()
|
||||
)
|
||||
if not journal:
|
||||
|
||||
@@ -490,3 +490,58 @@ class PmsProperty(models.Model):
|
||||
vals.update({"checkin_sequence_id": checkin_sequence.id})
|
||||
record = super(PmsProperty, self).create(vals)
|
||||
return record
|
||||
|
||||
@api.model
|
||||
def daily_closing(
|
||||
self, pms_property_ids, room_type_ids=False, availability_plan_ids=False
|
||||
):
|
||||
"""
|
||||
This method is used to close the daily availability of rooms
|
||||
"""
|
||||
pms_properties = self.browse(pms_property_ids)
|
||||
for pms_property in pms_properties:
|
||||
if not room_type_ids:
|
||||
room_type_ids = self.env["pms.room.type"].search(
|
||||
[
|
||||
"|",
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("pms_property_id", "=", False),
|
||||
]
|
||||
)
|
||||
if not availability_plan_ids:
|
||||
availability_plan_ids = self.env["pms.availability.plan"].search(
|
||||
[
|
||||
"|",
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("pms_property_id", "=", False),
|
||||
]
|
||||
)
|
||||
for room_type in self.env["pms.room.type"].browse(room_type_ids):
|
||||
for availability_plan in self.env["pms.availability.plan"].browse(
|
||||
availability_plan_ids
|
||||
):
|
||||
rule = self.env["pms.availability.plan.rule"].search(
|
||||
[
|
||||
("pms_property_id", "=", pms_property.id),
|
||||
("room_type_id", "=", room_type.id),
|
||||
("availability_plan_id", "=", availability_plan.id),
|
||||
]
|
||||
)
|
||||
if not rule:
|
||||
rule = self.env["pms.availability.plan.rule"].create(
|
||||
{
|
||||
"pms_property_id": pms_property.id,
|
||||
"room_type_id": room_type.id,
|
||||
"availability_plan_id": availability_plan.id,
|
||||
"date": fields.date.today(),
|
||||
"closed": True,
|
||||
}
|
||||
)
|
||||
elif not rule.closed:
|
||||
rule.write(
|
||||
{
|
||||
"closed": True,
|
||||
}
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
@@ -248,7 +248,9 @@ class PmsReservationLine(models.Model):
|
||||
):
|
||||
if self.env.context.get("force_overbooking"):
|
||||
reservation.overbooking = True
|
||||
line.room_id = reservation.room_type_id.room_ids[0]
|
||||
line.room_id = reservation.room_type_id.room_ids.filtered(
|
||||
lambda r: r.pms_property_id == line.pms_property_id
|
||||
)[0]
|
||||
else:
|
||||
raise ValidationError(
|
||||
_("%s: No room type available")
|
||||
|
||||
@@ -380,6 +380,7 @@ class AvailabilityWizard(models.TransientModel):
|
||||
def _rules_to_overwrite_by_plans(self, availability_plans):
|
||||
self.ensure_one()
|
||||
domain = [
|
||||
("pms_property_id", "in", self.pms_property_ids.ids),
|
||||
("availability_plan_id", "in", availability_plans.ids),
|
||||
]
|
||||
|
||||
@@ -806,7 +807,9 @@ class AvailabilityWizard(models.TransientModel):
|
||||
"date"
|
||||
) and room_type in rules_to_overwrite.mapped("room_type_id"):
|
||||
overwrite = rules_to_overwrite.filtered(
|
||||
lambda x: x.room_type_id == room_type and x.date == date
|
||||
lambda x: x.room_type_id == room_type
|
||||
and x.date == date
|
||||
and x.pms_property_id.id == pms_property.id
|
||||
)
|
||||
overwrite.write(vals)
|
||||
new_items += overwrite.ids
|
||||
|
||||
Reference in New Issue
Block a user