diff --git a/hotel/models/hotel_folio.py b/hotel/models/hotel_folio.py
index c180c89fc..61a4d1a37 100644
--- a/hotel/models/hotel_folio.py
+++ b/hotel/models/hotel_folio.py
@@ -280,7 +280,7 @@ class HotelFolio(models.Model):
'amount_total': amount_untaxed + amount_tax,
})
- @api.depends('amount_total', 'payment_ids', 'return_ids')
+ @api.depends('amount_total', 'payment_ids', 'return_ids', 'reservation_type')
@api.multi
def compute_amount(self):
acc_pay_obj = self.env['account.payment']
@@ -630,64 +630,73 @@ class HotelFolio(models.Model):
@api.depends('room_lines')
def _compute_has_confirmed_reservations_to_send(self):
has_to_send = False
- for rline in self.room_lines:
- if rline.splitted:
- master_reservation = rline.parent_reservation or rline
- has_to_send = self.env['hotel.reservation'].search_count([
- ('splitted', '=', True),
- ('folio_id', '=', self.id),
- ('to_send', '=', True),
- ('state', 'in', ('confirm', 'booking')),
- '|',
- ('parent_reservation', '=', master_reservation.id),
- ('id', '=', master_reservation.id),
- ]) > 0
- elif rline.to_send and rline.state in ('confirm', 'booking'):
- has_to_send = True
- break
- self.has_confirmed_reservations_to_send = has_to_send
+ if self.reservation_type != 'out':
+ for rline in self.room_lines:
+ if rline.splitted:
+ master_reservation = rline.parent_reservation or rline
+ has_to_send = self.env['hotel.reservation'].search_count([
+ ('splitted', '=', True),
+ ('folio_id', '=', self.id),
+ ('to_send', '=', True),
+ ('state', 'in', ('confirm', 'booking')),
+ '|',
+ ('parent_reservation', '=', master_reservation.id),
+ ('id', '=', master_reservation.id),
+ ]) > 0
+ elif rline.to_send and rline.state in ('confirm', 'booking'):
+ has_to_send = True
+ break
+ self.has_confirmed_reservations_to_send = has_to_send
+ else:
+ self.has_confirmed_reservations_to_send = False
@api.depends('room_lines')
def _compute_has_cancelled_reservations_to_send(self):
has_to_send = False
- for rline in self.room_lines:
- if rline.splitted:
- master_reservation = rline.parent_reservation or rline
- has_to_send = self.env['hotel.reservation'].search_count([
- ('splitted', '=', True),
- ('folio_id', '=', self.id),
- ('to_send', '=', True),
- ('state', '=', 'cancelled'),
- '|',
- ('parent_reservation', '=', master_reservation.id),
- ('id', '=', master_reservation.id),
- ]) > 0
- elif rline.to_send and rline.state == 'cancelled':
- has_to_send = True
- break
- self.has_cancelled_reservations_to_send = has_to_send
+ if self.reservation_type != 'out':
+ for rline in self.room_lines:
+ if rline.splitted:
+ master_reservation = rline.parent_reservation or rline
+ has_to_send = self.env['hotel.reservation'].search_count([
+ ('splitted', '=', True),
+ ('folio_id', '=', self.id),
+ ('to_send', '=', True),
+ ('state', '=', 'cancelled'),
+ '|',
+ ('parent_reservation', '=', master_reservation.id),
+ ('id', '=', master_reservation.id),
+ ]) > 0
+ elif rline.to_send and rline.state == 'cancelled':
+ has_to_send = True
+ break
+ self.has_cancelled_reservations_to_send = has_to_send
+ else:
+ self.has_cancelled_reservations_to_send = False
@api.depends('room_lines')
def _compute_has_checkout_to_send(self):
has_to_send = True
- for rline in self.room_lines:
- if rline.splitted:
- master_reservation = rline.parent_reservation or rline
- nreservs = self.env['hotel.reservation'].search_count([
- ('splitted', '=', True),
- ('folio_id', '=', self.id),
- ('to_send', '=', True),
- ('state', '=', 'done'),
- '|',
- ('parent_reservation', '=', master_reservation.id),
- ('id', '=', master_reservation.id),
- ])
- if nreservs != len(self.room_lines):
+ if self.reservation_type != 'out':
+ for rline in self.room_lines:
+ if rline.splitted:
+ master_reservation = rline.parent_reservation or rline
+ nreservs = self.env['hotel.reservation'].search_count([
+ ('splitted', '=', True),
+ ('folio_id', '=', self.id),
+ ('to_send', '=', True),
+ ('state', '=', 'done'),
+ '|',
+ ('parent_reservation', '=', master_reservation.id),
+ ('id', '=', master_reservation.id),
+ ])
+ if nreservs != len(self.room_lines):
+ has_to_send = False
+ elif not rline.to_send or rline.state != 'done':
has_to_send = False
- elif not rline.to_send or rline.state != 'done':
- has_to_send = False
- break
- self.has_checkout_to_send = has_to_send
+ break
+ self.has_checkout_to_send = has_to_send
+ else:
+ self.has_checkout_to_send = False
@api.multi
def send_reservation_mail(self):
diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py
index f93fab504..332178131 100644
--- a/hotel/models/hotel_reservation.py
+++ b/hotel/models/hotel_reservation.py
@@ -838,7 +838,7 @@ class HotelReservation(models.Model):
@api.depends('reservation_line_ids.discount')
def _compute_discount(self):
for record in self:
- record.discount = sum(line.price * (1 - (line.discount or 0.0) * 0.01) \
+ record.discount = sum(line.price * ((line.discount or 0.0) * 0.01) \
for line in record.reservation_line_ids)
@api.depends('reservation_line_ids.price', 'discount', 'tax_ids')
@@ -1022,9 +1022,13 @@ class HotelReservation(models.Model):
def _compute_checkin_partner_count(self):
_logger.info('_compute_checkin_partner_count')
for record in self:
- record.checkin_partner_count = len(record.checkin_partner_ids)
- record.checkin_partner_pending_count = (record.adults + record.children) \
- - len(record.checkin_partner_ids)
+ if record.reservation_type != 'out':
+ record.checkin_partner_count = len(record.checkin_partner_ids)
+ record.checkin_partner_pending_count = (record.adults + record.children) \
+ - len(record.checkin_partner_ids)
+ else:
+ record.checkin_partner_count = 0
+ record.checkin_partner_pending_count = 0
# https://www.odoo.com/es_ES/forum/ayuda-1/question/calculated-fields-in-search-filter-possible-118501
@api.multi
diff --git a/hotel/views/hotel_reservation_views.xml b/hotel/views/hotel_reservation_views.xml
index cd2ce2a47..46a91aaca 100644
--- a/hotel/views/hotel_reservation_views.xml
+++ b/hotel/views/hotel_reservation_views.xml
@@ -25,15 +25,13 @@
+ attrs="{'invisible': ['|',('state', '=', 'draft'), ('reservation_type','not in',('normal'))]}" />
-
-