mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] pms: mandatory closure reason if reservation is out & fix mandatory partner
This commit is contained in:
@@ -1137,7 +1137,7 @@ class PmsFolio(models.Model):
|
||||
@api.constrains("name")
|
||||
def _check_required_partner_name(self):
|
||||
for record in self:
|
||||
if not record.partner_name:
|
||||
if not record.partner_name and record.reservation_type != 'out':
|
||||
raise models.ValidationError(_("You must assign a customer name"))
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -125,6 +125,7 @@ class PmsReservation(models.Model):
|
||||
help="Reason why the reservation cannot be made",
|
||||
related="folio_id.closure_reason_id",
|
||||
check_pms_properties=True,
|
||||
readonly=False,
|
||||
)
|
||||
company_id = fields.Many2one(
|
||||
string="Company",
|
||||
@@ -1670,6 +1671,16 @@ class PmsReservation(models.Model):
|
||||
record, record.service_ids.service_line_ids
|
||||
)
|
||||
|
||||
@api.constrains("closure_reason_id")
|
||||
def _check_closure_reason_id(self):
|
||||
for record in self:
|
||||
if record.reservation_type == "out" and not record.closure_reason_id:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"A closure reason is mandatory when reservation type is 'out of service'"
|
||||
)
|
||||
)
|
||||
|
||||
@api.constrains("reservation_type")
|
||||
def _check_same_reservation_type(self):
|
||||
for record in self:
|
||||
@@ -1802,7 +1813,7 @@ class PmsReservation(models.Model):
|
||||
default_vals["partner_name"] = folio.partner_name
|
||||
default_vals["mobile"] = folio.mobile
|
||||
default_vals["email"] = folio.email
|
||||
else:
|
||||
elif vals.get("reservation_type") != "out":
|
||||
raise ValidationError(_("Partner contact name is required"))
|
||||
vals.update(default_vals)
|
||||
elif "pms_property_id" in vals and (
|
||||
@@ -1819,7 +1830,7 @@ class PmsReservation(models.Model):
|
||||
folio_vals["partner_name"] = vals.get("partner_name")
|
||||
folio_vals["mobile"] = vals.get("mobile")
|
||||
folio_vals["email"] = vals.get("email")
|
||||
else:
|
||||
elif vals.get("reservation_type") != "out":
|
||||
raise ValidationError(_("Partner contact name is required"))
|
||||
# Create the folio in case of need
|
||||
# (To allow to create reservations direct)
|
||||
|
||||
@@ -351,7 +351,7 @@
|
||||
</h3>
|
||||
<group>
|
||||
<group string="General Info" name="contact_details">
|
||||
<field name="partner_id" />
|
||||
<field name="partner_id" attrs="{'invisible':[('reservation_type','in',('out'))]}" />
|
||||
<field
|
||||
name="document_type"
|
||||
attrs="{'invisible':[('reservation_type','in',('out'))]}"
|
||||
|
||||
Reference in New Issue
Block a user