[IMP] computes reservation customer fields

This commit is contained in:
Dario Lodeiros
2021-06-30 08:34:06 +02:00
parent 1b69aec19b
commit 297b52330b
3 changed files with 35 additions and 4 deletions

View File

@@ -187,6 +187,7 @@ class PmsAvailabilityPlan(models.Model):
("room_type_id", "=", room_type_id),
("pms_property_id", "=", pms_property_id),
]
pricelist = False
if pricelist_id:
pricelist = self.env["product.pricelist"].browse(pricelist_id)
if pricelist and pricelist.availability_plan_id:

View File

@@ -765,27 +765,51 @@ class PmsFolio(models.Model):
else:
order.invoice_status = "no"
@api.depends("partner_id", "partner_id.name")
@api.depends("partner_id", "partner_id.name", "reservation_ids.partner_name")
def _compute_partner_name(self):
for record in self:
if record.partner_id and not record.partner_name:
record.partner_name = record.partner_id.name
# if there is only one customer name in the folio reservations
# we update the partner name of the folio when the partner name of
# the reservations is modified
elif (
len(record.reservation_ids.mapped("partner_name")) == 1
and not record.partner_name
):
record.partner_name = record.reservation_ids[0].partner_name
elif not record.partner_name:
record.partner_name = False
@api.depends("partner_id", "partner_id.email")
@api.depends("partner_id", "partner_id.email", "reservation_ids.partner_email")
def _compute_email(self):
for record in self:
if record.partner_id and not record.email:
record.email = record.partner_id.email
# if there is only one customer email in the folio reservations
# we update the partner email of the folio when the partner email of
# the reservations is modified
elif (
len(record.reservation_ids.mapped("partner_email")) == 1
and not record.email
):
record.email = record.reservation_ids[0].partner_email
elif not record.email:
record.email = False
@api.depends("partner_id", "partner_id.mobile")
@api.depends("partner_id", "partner_id.mobile", "reservation_ids.partner_mobile")
def _compute_mobile(self):
for record in self:
if record.partner_id and not record.mobile:
record.mobile = record.partner_id.mobile
# if there is only one customer mobile in the folio reservations
# we update the partner mobile of the folio when the partner mobile of
# the reservations is modified
elif (
len(record.reservation_ids.mapped("partner_mobile")) == 1
and not record.mobile
):
record.mobile = record.reservation_ids[0].partner_mobile
elif not record.mobile:
record.mobile = False

View File

@@ -1210,11 +1210,13 @@ class PmsReservation(models.Model):
else:
record.shared_folio = False
@api.depends("partner_id", "partner_id.name")
@api.depends("partner_id", "partner_id.name", "folio_id.partner_name")
def _compute_partner_name(self):
for record in self:
if record.partner_id and not record.partner_name:
record.partner_name = record.partner_id.name
elif record.folio_id.partner_name and not record.partner_name:
record.partner_name = record.folio_id.partner_name
elif not record.partner_name:
record.partner_name = False
@@ -1223,6 +1225,8 @@ class PmsReservation(models.Model):
for record in self:
if record.partner_id and not record.partner_email:
record.partner_email = record.partner_id.email
elif record.folio_id.email and not record.partner_email:
record.partner_email = record.folio_id.partner_email
elif not record.partner_email:
record.partner_email = False
@@ -1231,6 +1235,8 @@ class PmsReservation(models.Model):
for record in self:
if record.partner_id and not record.partner_mobile:
record.partner_mobile = record.partner_id.mobile
elif record.folio_id.mobile and not record.partner_mobile:
record.partner_mobile = record.folio_id.partner_mobile
elif not record.partner_mobile:
record.partner_mobile = False