diff --git a/hotel/models/hotel_folio.py b/hotel/models/hotel_folio.py
index 85de9f48d..668106463 100644
--- a/hotel/models/hotel_folio.py
+++ b/hotel/models/hotel_folio.py
@@ -314,7 +314,7 @@ class HotelFolio(models.Model):
@api.model
def create(self, vals):
- if vals.get('name', _('New')) == _('New'):
+ if vals.get('name', _('New')) == _('New') or 'name' not in vals:
if 'company_id' in vals:
vals['name'] = self.env['ir.sequence'].with_context(
force_company=vals['company_id']
@@ -492,18 +492,16 @@ class HotelFolio(models.Model):
def _compute_cardex_count(self):
_logger.info('_compute_cardex_amount')
for record in self:
- if record.reservation_type == 'normal':
+ if record.reservation_type == 'normal' and record.room_lines:
write_vals = {}
- filtered_reservs = record.filtered(
- lambda x: x.room_lines.state != 'cancelled' and \
- not x.room_lines.parent_reservation)
-
+ filtered_reservs = record.room_lines.filtered(
+ lambda x: x.state != 'cancelled' and \
+ not x.parent_reservation)
mapped_cardex = filtered_reservs.mapped('cardex_ids.id')
- write_vals.update({'cardex_count': len(mapped_cardex)})
+ record.cardex_count = len(mapped_cardex)
mapped_cardex_count = filtered_reservs.mapped(
lambda x: (x.adults + x.children) - len(x.cardex_ids))
- write_vals.update({'cardex_pending_count': sum(mapped_cardex_count)})
- record.write(write_vals)
+ record.cardex_pending_count = sum(mapped_cardex_count)
"""
MAILING PROCESS
diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py
index 33e1c2db6..f2a9eab6b 100644
--- a/hotel/models/hotel_reservation.py
+++ b/hotel/models/hotel_reservation.py
@@ -334,12 +334,11 @@ class HotelReservation(models.Model):
def _prepare_add_missing_fields(self, values):
""" Deduce missing required fields from the onchange """
res = {}
- onchange_fields = ['room_id', 'reservation_type', 'currency_id']
+ onchange_fields = ['room_id', 'reservation_type', 'currency_id', 'name']
if values.get('partner_id') and values.get('room_type_id'):
line = self.new(values)
if any(f not in values for f in onchange_fields):
line.onchange_room_id()
- if 'name' not in values:
line.onchange_compute_reservation_description()
if 'pricelist_id' not in values:
line.onchange_partner_id()
@@ -892,11 +891,9 @@ class HotelReservation(models.Model):
def _compute_cardex_count(self):
_logger.info('_compute_cardex_count')
for record in self:
- record.write({
- 'cardex_count': len(record.cardex_ids),
- 'cardex_pending_count': (record.adults + record.children) \
+ record.cardex_count = len(record.cardex_ids)
+ record.cardex_pending_count = (record.adults + record.children) \
- len(record.cardex_ids)
- })
# 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_folio.xml b/hotel/views/hotel_folio.xml
index be1003cce..a3a3c73a7 100644
--- a/hotel/views/hotel_folio.xml
+++ b/hotel/views/hotel_folio.xml
@@ -64,7 +64,7 @@
Checks
-
+
-
-
+