mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP]pms: Add check to block past reservations creation
This commit is contained in:
@@ -237,6 +237,11 @@ class PmsProperty(models.Model):
|
||||
string="Image in checkin",
|
||||
default=get_default_logo(),
|
||||
)
|
||||
block_create_past_reservations = fields.Boolean(
|
||||
string="Block Create Past Reservations",
|
||||
help="Block the creation of reservations in the past",
|
||||
default=False,
|
||||
)
|
||||
|
||||
@api.depends_context(
|
||||
"checkin",
|
||||
|
||||
@@ -570,3 +570,10 @@ class PmsReservationLine(models.Model):
|
||||
)
|
||||
if duplicated:
|
||||
raise ValidationError(_("Duplicated reservation line date"))
|
||||
|
||||
@api.constrains("date")
|
||||
def _check_past_reservations(self):
|
||||
for record in self:
|
||||
if record.pms_property_id.block_create_past_reservations:
|
||||
if record.date < fields.Date.today():
|
||||
raise ValidationError(_("You can't create past reservations"))
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
>
|
||||
<field name="default_pricelist_id" required="True" />
|
||||
</group>
|
||||
<group string="Reservation">
|
||||
<field name="block_create_past_reservations" />
|
||||
</group>
|
||||
<group string="Timezone">
|
||||
<field name="tz" widget="timezone_mismatch" />
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user