[IMP] Replace room_lines and service_lines by _ids

This commit is contained in:
Dario Lodeiros
2019-09-24 19:18:17 +02:00
parent ca6a0e669a
commit 22b7ec6626
21 changed files with 89 additions and 89 deletions

View File

@@ -331,7 +331,7 @@
</tr>
<tr>
<td class="subheading" style="color: #555555" align="justify">
<strong>Noches</strong>: ${len(object.room_lines[0].reservation_lines)}</td>
<strong>Noches</strong>: ${len(object.reservation_ids[0].reservation_lines)}</td>
</tr>
<tr>
<td class="paragraph" style="padding: 10px 0 0 0;" align="justify">

View File

@@ -205,8 +205,8 @@
</tr>
<tr>
<td align="justify" class="paragraph" style="padding: 10px 0 0 0;">Hola ${object.partner_id.firstname}<br />
Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.room_lines[0].checkin[8:10]} del ${object.room_lines[0].checkin[5:7]} de
${object.room_lines[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />
Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.reservation_ids[0].checkin[8:10]} del ${object.reservation_ids[0].checkin[5:7]} de
${object.reservation_ids[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />
</td>
</tr>
<tr>
@@ -524,7 +524,7 @@
<div>
<div class="h2" style="font-family: sans-serif; font-size: 18px; font-weight: bold; color: #45C2B1; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;">Información de la
habitación</div>
% set room_type_ids = object.room_lines.filtered('to_send').mapped('room_type_id.id')
% set room_type_ids = object.reservation_ids.filtered('to_send').mapped('room_type_id.id')
% set room_types = user.env['hotel.room.type'].browse(room_type_ids)
% for room_type in room_types:

View File

@@ -339,7 +339,7 @@
<!-- reservation of 1 economic room for 1 person -->
<record id="hotel_folio_0" model="hotel.folio">
<field name="partner_id" ref="base.res_partner_address_27"/>
<field name="room_lines"
<field name="reservation_ids"
eval="[(5, 0), (0, 0, {
'pricelist_id': 1,
'room_type_id': ref('hotel_room_type_0'),
@@ -353,7 +353,7 @@
<!-- reservation of 1 triple room for 3 people on behalf on the company -->
<record id="hotel_folio_1" model="hotel.folio">
<field name="partner_id" ref="base.res_partner_12"/>
<field name="room_lines"
<field name="reservation_ids"
eval="[(5, 0), (0, 0, {
'pricelist_id': 1,
'room_type_id': ref('hotel_room_type_3'),
@@ -367,7 +367,7 @@
<!-- TODO: The third reservation is marked from State: Cancelled to Pending Entry at Folio creation -->
<record id="hotel_folio_2" model="hotel.folio">
<field name="partner_id" ref="base.res_partner_address_10"/>
<field name="room_lines"
<field name="reservation_ids"
eval="[(5, 0),
(0, 0, {
'pricelist_id': 1,
@@ -397,7 +397,7 @@
<!-- reservation of the conference room for 1 day on behalf of a company -->
<record id="hotel_folio_3" model="hotel.folio">
<field name="partner_id" ref="base.res_partner_12"/>
<field name="room_lines"
<field name="reservation_ids"
eval="[(5, 0), (0, 0, {
'pricelist_id': 1,
'room_type_id': ref('hotel_room_type_4'),
@@ -411,7 +411,7 @@
<record id="hotel_folio_4" model="hotel.folio">
<field name="partner_id" ref="main_hotel_property"/>
<field name="reservation_type">out</field>
<field name="room_lines"
<field name="reservation_ids"
eval="[(5, 0), (0, 0, {
'pricelist_id': 1,
'room_type_id': ref('hotel_room_type_1'),

View File

@@ -226,7 +226,7 @@ msgid ""
" </tr>\n"
" <tr>\n"
" <td align=\"justify\" class=\"subheading\" style=\"color: #555555\">\n"
" <strong>Noches</strong>: ${len(object.room_lines[0].reservation_lines)}</td>\n"
" <strong>Noches</strong>: ${len(object.reservation_ids[0].reservation_lines)}</td>\n"
" </tr>\n"
" <tr>\n"
" <td align=\"justify\" class=\"paragraph\" style=\"padding: 10px 0 0 0;\">\n"
@@ -750,7 +750,7 @@ msgstr ""
" </tr>\n"
" <tr>\n"
" <td class=\"subheading\" style=\"padding:0px;color: #555555\" align=\"justify\">\n"
" <strong style=\"font-weight:bold;\">Noches</strong>: ${len(object.room_lines[0].reservation_lines)}</td>\n"
" <strong style=\"font-weight:bold;\">Noches</strong>: ${len(object.reservation_ids[0].reservation_lines)}</td>\n"
" </tr>\n"
" <tr>\n"
" <td class=\"paragraph\" style=\"padding: 10px 0 0 0;\" align=\"justify\">\n"
@@ -1401,8 +1401,8 @@ msgid ""
" </tr>\n"
" <tr>\n"
" <td align=\"justify\" class=\"paragraph\" style=\"padding: 10px 0 0 0;\">Hola ${object.partner_id.firstname}<br />\n"
" Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.room_lines[0].checkin[8:10]} del ${object.room_lines[0].checkin[5:7]} de\n"
" ${object.room_lines[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />\n"
" Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.reservation_ids[0].checkin[8:10]} del ${object.reservation_ids[0].checkin[5:7]} de\n"
" ${object.reservation_ids[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />\n"
" </td>\n"
" </tr>\n"
" <tr>\n"
@@ -1720,7 +1720,7 @@ msgid ""
" <div>\n"
" <div class=\"h2\" style=\"font-family: sans-serif; font-size: 18px; font-weight: bold; color: #45C2B1; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;\">Información de la\n"
" habitación</div>\n"
" % set room_type_ids = object.room_lines.filtered('to_send').mapped('room_type_id.id')\n"
" % set room_type_ids = object.reservation_ids.filtered('to_send').mapped('room_type_id.id')\n"
" % set room_types = user.env['hotel.room.type'].browse(room_type_ids)\n"
" % for room_type in room_types:\n"
"\n"
@@ -2406,8 +2406,8 @@ msgstr ""
" </tr>\n"
" <tr>\n"
" <td align=\"justify\" class=\"paragraph\" style=\"padding: 10px 0 0 0;\">Hola ${object.partner_id.firstname}<br />\n"
" Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.room_lines[0].checkin[8:10]} del ${object.room_lines[0].checkin[5:7]} de\n"
" ${object.room_lines[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />\n"
" Tu reserva en <b>${object.company_id.property_name}</b> queda confirmada. Te esperamos el día <b>${object.reservation_ids[0].checkin[8:10]} del ${object.reservation_ids[0].checkin[5:7]} de\n"
" ${object.reservation_ids[0].checkin[0:4]}</b>. Si podemos ayudarte en cualquier tipo de gestión, no dudes en hacérnoslo saber.<br />\n"
" </td>\n"
" </tr>\n"
" <tr>\n"
@@ -2725,7 +2725,7 @@ msgstr ""
" <div>\n"
" <div class=\"h2\" style=\"font-family: sans-serif; font-size: 18px; font-weight: bold; color: #45C2B1; padding: 0 0 0 0; text-transform: uppercase; letter-spacing: 0.5px;\">Información de la\n"
" habitación</div>\n"
" % set room_type_ids = object.room_lines.filtered('to_send').mapped('room_type_id.id')\n"
" % set room_type_ids = object.reservation_ids.filtered('to_send').mapped('room_type_id.id')\n"
" % set room_types = user.env['hotel.room.type'].browse(room_type_ids)\n"
" % for room_type in room_types:\n"
"\n"
@@ -6120,7 +6120,7 @@ msgid "Hotel Ubications"
msgstr "Ubicaciones"
#. module: hotel
#: model:ir.model.fields,help:hotel.field_hotel_folio_room_lines
#: model:ir.model.fields,help:hotel.field_hotel_folio_reservation_ids
msgid "Hotel room reservation detail."
msgstr "Detalle de la reserva"
@@ -7781,7 +7781,7 @@ msgid "Room Line"
msgstr "Línea de habitación"
#. module: hotel
#: model:ir.model.fields,field_description:hotel.field_hotel_folio_room_lines
#: model:ir.model.fields,field_description:hotel.field_hotel_folio_reservation_ids
#: model:ir.ui.view,arch_db:hotel.hotel_folio_wizard
msgid "Room Lines"
msgstr "Líneas de habitación"

View File

@@ -126,7 +126,7 @@ class HotelBoardServiceRoomType(models.Model):
def create(self, vals):
if 'hotel_board_service_id' in vals:
vals.update(
self.prepare_board_service_room_lines(
self.prepare_board_service_reservation_ids(
vals['hotel_board_service_id'])
)
return super(HotelBoardServiceRoomType, self).create(vals)
@@ -135,14 +135,14 @@ class HotelBoardServiceRoomType(models.Model):
def write(self, vals):
if 'hotel_board_service_id' in vals:
vals.update(
self.prepare_board_service_room_lines(
self.prepare_board_service_reservation_ids(
vals['hotel_board_service_id'])
)
return super(HotelBoardServiceRoomType, self).write(vals)
# Business methods
@api.model
def prepare_board_service_room_lines(self, board_service_id):
def prepare_board_service_reservation_ids(self, board_service_id):
"""
Prepare line to price products config
"""

View File

@@ -28,7 +28,7 @@ class HotelCheckinPartner(models.Model):
])
partner_ids = []
if reservation.folio_id:
for room in reservation.folio_id.room_lines:
for room in reservation.folio_id.reservation_ids:
partner_ids.append(room.mapped(
'checkin_partner_ids.partner_id.id'))
if 'checkin_partner_ids' in self.env.context:

View File

@@ -29,8 +29,8 @@ class HotelReservation(models.Model):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].checkin
if folio and folio.reservation_ids:
return folio.reservation_ids[0].checkin
else:
tz_hotel = self.env.user.hotel_id.tz
today = fields.Date.context_today(self.with_context(tz=tz_hotel))
@@ -43,8 +43,8 @@ class HotelReservation(models.Model):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].checkout
if folio and folio.reservation_ids:
return folio.reservation_ids[0].checkout
else:
tz_hotel = self.env.user.hotel_id.tz
today = fields.Date.context_today(self.with_context(tz=tz_hotel))
@@ -58,8 +58,8 @@ class HotelReservation(models.Model):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].arrival_hour
if folio and folio.reservation_ids:
return folio.reservation_ids[0].arrival_hour
else:
return default_arrival_hour
@@ -70,8 +70,8 @@ class HotelReservation(models.Model):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].departure_hour
if folio and folio.reservation_ids:
return folio.reservation_ids[0].departure_hour
else:
return default_departure_hour
@@ -686,7 +686,7 @@ class HotelReservation(models.Model):
res.update(
self.env['hotel.service']._prepare_add_missing_fields(
res))
res.update(self.env['hotel.service'].prepare_service_lines(
res.update(self.env['hotel.service'].prepare_service_ids(
dfrom=self.checkin,
days=self.nights,
per_person=product.per_person,
@@ -916,7 +916,7 @@ class HotelReservation(models.Model):
).days
for service in record.service_ids:
if service.product_id.per_day:
service.update(service.prepare_service_lines(
service.update(service.prepare_service_ids(
dfrom=real_checkin,
days=service_days_diff,
per_person=service.product_id.per_person,
@@ -943,7 +943,7 @@ class HotelReservation(models.Model):
# Yes?, then, this is share folio ;)
for record in self:
if record.folio_id:
record.shared_folio = len(record.folio_id.room_lines) > 1 or \
record.shared_folio = len(record.folio_id.reservation_ids) > 1 or \
any(record.folio_id.service_ids.filtered(
lambda x: x.ser_room_line.id != record.id))

View File

@@ -43,8 +43,8 @@ class HotelService(models.Model):
@api.model
def _default_ser_room_line(self):
if self.env.context.get('room_lines'):
ids = [item[1] for item in self.env.context['room_lines']]
if self.env.context.get('reservation_ids'):
ids = [item[1] for item in self.env.context['reservation_ids']]
return self.env['hotel.reservation'].browse([
(ids)], limit=1)
elif self.env.context.get('default_ser_room_line'):
@@ -186,7 +186,7 @@ class HotelService(models.Model):
checkin_dt = fields.Date.from_string(checkin)
checkout_dt = fields.Date.from_string(checkout)
nights = abs((checkout_dt - checkin_dt).days)
vals.update(self.prepare_service_lines(
vals.update(self.prepare_service_ids(
dfrom=checkin,
days=nights,
per_person=product.per_person,
@@ -221,7 +221,7 @@ class HotelService(models.Model):
checkin_dt = fields.Date.from_string(checkin)
checkout_dt = fields.Date.from_string(checkout)
nights = abs((checkout_dt - checkin_dt).days)
record.update(record.prepare_service_lines(
record.update(record.prepare_service_ids(
dfrom=checkin,
days=nights,
per_person=product.per_person,
@@ -289,7 +289,7 @@ class HotelService(models.Model):
"""
Compute the default quantity according to the
configuration of the selected product, in per_day product configuration,
the qty is autocalculated and readonly based on service_lines qty
the qty is autocalculated and readonly based on service_ids qty
"""
if not self.product_id:
return
@@ -313,7 +313,7 @@ class HotelService(models.Model):
checkin_dt = fields.Date.from_string(checkin)
checkout_dt = fields.Date.from_string(checkout)
nights = abs((checkout_dt - checkin_dt).days)
vals.update(record.prepare_service_lines(
vals.update(record.prepare_service_ids(
dfrom=checkin,
days=nights,
per_person=product.per_person,
@@ -393,7 +393,7 @@ class HotelService(models.Model):
origin.company_id)
@api.model
def prepare_service_lines(self, **kwargs):
def prepare_service_ids(self, **kwargs):
"""
Prepare line and respect the old manual changes on lines
"""
@@ -454,7 +454,7 @@ class HotelService(models.Model):
record.update(vals)
@api.multi
def open_service_lines(self):
def open_service_ids(self):
action = self.env.ref('hotel.action_hotel_services_form').read()[0]
action['views'] = [(self.env.ref('hotel.hotel_service_view_form').id, 'form')]
action['res_id'] = self.id
@@ -465,7 +465,7 @@ class HotelService(models.Model):
#~ def constrains_qty_per_day(self):
#~ for record in self:
#~ if record.per_day:
#~ service_lines = self.env['hotel.service_line']
#~ total_day_qty = sum(service_lines.with_context({'service_id': record.id}).mapped('day_qty'))
#~ service_ids = self.env['hotel.service_line']
#~ total_day_qty = sum(service_ids.with_context({'service_id': record.id}).mapped('day_qty'))
#~ if record.product_qty != total_day_qty:
#~ raise ValidationError (_('The quantity per line and per day does not correspond'))

View File

@@ -15,7 +15,7 @@ class MailComposeMessage(models.TransientModel):
self._context['default_res_id']
])
if folio:
cmds = [(1, lid, {'to_send': False}) for lid in folio.room_lines.ids]
cmds = [(1, lid, {'to_send': False}) for lid in folio.reservation_ids.ids]
if any(cmds):
folio.room_lines = cmds
folio.reservation_ids = cmds
return super(MailComposeMessage, self).send_mail(auto_commit=auto_commit)

View File

@@ -49,7 +49,7 @@
</div>
<!-- Is there a discount on at least one line? -->
<t t-set="display_discount" t-value="any([l.discount for l in doc.room_lines])"/>
<t t-set="display_discount" t-value="any([l.discount for l in doc.reservation_ids])"/>
<table class="table table-condensed">
<thead>
@@ -64,7 +64,7 @@
</thead>
<tbody class="sale_tbody">
<!-- Lines associated -->
<t t-foreach="doc.room_lines" t-as="l">
<t t-foreach="doc.reservation_ids" t-as="l">
<t t-if="l.to_print == True and l.price_total > 0">
<tr>
<td><span t-field="l.name"/></td>

View File

@@ -47,9 +47,9 @@ class TestHotelReservations(TestHotel):
org_reserv_end_utc_dt,
self.hotel_room_simple_100,
"Reservation Test #2")
self.assertEqual(len(folio.room_lines), 2, 'Invalid room lines count')
self.assertEqual(len(folio.reservation_ids), 2, 'Invalid room lines count')
folio.action_cancel()
self.assertEqual(folio.state, 'cancel', 'Invalid folio state')
for rline in folio.room_lines:
for rline in folio.reservation_ids:
self.assertEqual(rline.state, 'cancelled',
'Invalid reservation state')

View File

@@ -117,8 +117,8 @@
</group>
<notebook colspan="4" col="1">
<page string="Reservation Rooms">
<field name="room_lines" colspan="4" string="Room Line"
nolabel="1" context="{'from_folio':True,'room_lines':room_lines,'folio_id': id,'tree_view_ref':'hotel.hotel_reservation_view_bottom_tree', 'form_view_ref':'hotel.hotel_reservation_view_form'}"/>
<field name="reservation_ids" colspan="4" string="Room Line"
nolabel="1" context="{'from_folio':True,'reservation_ids':reservation_ids,'folio_id': id,'tree_view_ref':'hotel.hotel_reservation_view_bottom_tree', 'form_view_ref':'hotel.hotel_reservation_view_form'}"/>
</page>
<page string="Services">
<separator string="Service Lines" colspan="4"/>
@@ -233,7 +233,7 @@
<field name="name"/>
<field name="partner_id" select="1"/>
<field name="date_order" select="1"/>
<field name="room_lines" widget="many2many_tags" />
<field name="reservation_ids" widget="many2many_tags" />
<field name="amount_total" sum="Total amount"/>
<field name="pending_amount" sum="Total debt"/>
<field name="invoice_status" />
@@ -250,7 +250,7 @@
<kanban class="o_res_partner_kanban" limit="80">
<field name="name"/>
<field name="partner_id"/>
<field name="room_lines"/>
<field name="reservation_ids"/>
<field name="service_ids"/>
<field name="pending_amount"/>
<field name="refund_amount"/>

View File

@@ -260,7 +260,7 @@
<field name="hotel_id" invisible="0"/>
<button type="object" class="oe_stat_button"
icon="fa fa-1x fa-bed"
name="open_service_lines"
name="open_service_ids"
attrs="{'invisible':[('is_board_service','=', False)]}" />
<field name="per_day" invisible="1" readonly="1"/>
<field name="folio_id" invisible="1"/>
@@ -273,7 +273,7 @@
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
<button type="object" class="oe_stat_button"
icon="fa fa-2x fa-bars"
name="open_service_lines"
name="open_service_ids"
attrs="{'invisible': [('per_day','=',False)]}"/>
<field name="days_qty" invisible="1"/>
<field name="price_unit" />

View File

@@ -56,7 +56,7 @@
<field name="to_print" />
<button type="object" class="oe_stat_button"
icon="fa fa-1x fa-bed"
name="open_service_lines"
name="open_service_ids"
attrs="{'invisible':[('is_board_service','=', False)]}" />
<field name="per_day" invisible="1" readonly="1"/>
<field name="folio_id" invisible="1"/>
@@ -71,7 +71,7 @@
<field name="product_qty" attrs="{'readonly': [('per_day','=',True)]}" force_save="1"/>
<button type="object" class="oe_stat_button"
icon="fa fa-2x fa-bars"
name="open_service_lines"
name="open_service_ids"
attrs="{'invisible': [('per_day','=',False)]}"/>
<field name="days_qty" invisible="1"/>
<field name="price_unit" />

View File

@@ -39,7 +39,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
folios = self._get_default_folio()
reservations = self.env['hotel.reservation']
for folio in folios:
reservations |= folio.room_lines
reservations |= folio.reservation_ids
return reservations
@api.model
@@ -304,7 +304,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
'price_unit': service.price_unit,
'service_id': service.id,
}
for reservation in folio.room_lines.filtered(
for reservation in folio.reservation_ids.filtered(
lambda x: x.id in self.reservation_ids.ids and
x.invoice_status == 'to invoice'):
board_service = reservation.board_service_room_id
@@ -363,7 +363,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
services = self.env['hotel.service']
old_folio_ids = self.reservation_ids.mapped('folio_id.id')
for folio in folios.filtered(lambda r: r.id not in old_folio_ids):
folio_reservations = folio.room_lines
folio_reservations = folio.reservation_ids
if folio_reservations:
reservations |= folio_reservations
self.reservation_ids |= reservations

View File

@@ -28,8 +28,8 @@ class FolioWizard(models.TransientModel):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].checkin
if folio and folio.reservation_ids:
return folio.reservation_ids[0].checkin
return fields.Date.today()
@api.model
@@ -39,8 +39,8 @@ class FolioWizard(models.TransientModel):
folio = self.env['hotel.folio'].search([
('id', '=', self._context['folio_id'])
])
if folio and folio.room_lines:
return folio.room_lines[0].checkout
if folio and folio.reservation_ids:
return folio.reservation_ids[0].checkout
return fields.Date.today()
@api.model
@@ -253,7 +253,7 @@ class FolioWizard(models.TransientModel):
vals = {
'partner_id': self.partner_id.id,
'channel_type': self.channel_type,
'room_lines': reservations,
'reservation_ids': reservations,
'service_ids': services,
'pricelist_id': self.pricelist_id.id,
'internal_comment': self.internal_comment,
@@ -263,7 +263,7 @@ class FolioWizard(models.TransientModel):
}
newfol = self.env['hotel.folio'].create(vals)
if self.confirm:
newfol.room_lines.confirm()
newfol.reservation_ids.confirm()
action = self.env.ref('hotel.open_hotel_folio1_form_tree_all').read()[0]
if newfol:
action['views'] = [(self.env.ref('hotel.hotel_folio_view_form').id, 'form')]
@@ -543,7 +543,7 @@ class ReservationWizard(models.TransientModel):
checkin_dt = fields.Date.from_string(line.checkin)
checkout_dt = fields.Date.from_string(line.checkout)
nights = abs((checkout_dt - checkin_dt).days)
vals.update(service_line.prepare_service_lines(
vals.update(service_line.prepare_service_ids(
dfrom=line.checkin,
days=nights,
per_person=product.per_person,

View File

@@ -10,17 +10,17 @@ class HotelFolio(models.Model):
@api.multi
def write(self, vals):
ret = super(HotelFolio, self).write(vals)
fields_to_check = ('room_lines', 'service_lines', 'pending_amount')
fields_to_check = ('reservation_ids', 'service_ids', 'pending_amount')
fields_checked = [elm for elm in fields_to_check if elm in vals]
if any(fields_checked):
for record in self:
record.room_lines.send_bus_notification('write', 'noshow')
record.reservation_ids.send_bus_notification('write', 'noshow')
return ret
@api.multi
def unlink(self):
for record in self:
record.room_lines.send_bus_notification('unlink', 'warn',
record.reservation_ids.send_bus_notification('unlink', 'warn',
_("Folio Deleted"))
return super(HotelFolio, self).unlink()
@@ -30,5 +30,5 @@ class HotelFolio(models.Model):
ret = super(HotelFolio, self).compute_amount()
with self.env.norecompute():
for record in self:
record.room_lines.send_bus_notification('write', 'noshow')
record.reservation_ids.send_bus_notification('write', 'noshow')
return ret

View File

@@ -8,10 +8,10 @@ from odoo.addons.queue_job.job import job
class HotelFolio(models.Model):
_inherit = 'hotel.folio'
@api.depends('room_lines')
@api.depends('reservation_ids')
def _has_channel_reservations(self):
for record in self:
channel_reservations = record.room_lines.filtered(lambda x: x.room_id)
channel_reservations = record.reservation_ids.filtered(lambda x: x.room_id)
record.has_channel_reservations = any(channel_reservations)
customer_notes = fields.Text("Channel Customer Notes",
@@ -31,7 +31,7 @@ class HotelFolio(models.Model):
@api.multi
def action_confirm(self):
for rec in self:
rec.room_lines.write({
rec.reservation_ids.write({
'to_assign': False,
})
return super().action_confirm()
@@ -41,12 +41,12 @@ class HotelFolio(models.Model):
super().get_grouped_reservations_json(state, import_all=import_all)
self.ensure_one()
info_grouped = []
for rline in self.room_lines:
for rline in self.reservation_ids:
if (import_all or rline.to_send) and not rline.parent_reservation and rline.state == state and ((rline.state == 'cancelled' and not rline.channel_modified) or rline.state != 'cancelled'):
dates = (rline.real_checkin, rline.real_checkout)
vals = {
'num': len(
self.room_lines.filtered(lambda r: r.real_checkin == dates[0] and r.real_checkout == dates[1] and r.room_type_id.id == rline.room_type_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled'))
self.reservation_ids.filtered(lambda r: r.real_checkin == dates[0] and r.real_checkout == dates[1] and r.room_type_id.id == rline.room_type_id.id and (r.to_send or import_all) and not r.parent_reservation and r.state == rline.state and ((r.state == 'cancelled' and not r.channel_modified) or r.state != 'cancelled'))
),
'room_type': {
'id': rline.room_type_id.id,
@@ -68,12 +68,12 @@ class HotelFolio(models.Model):
return sorted(sorted(info_grouped, key=lambda k: k['num'],
reverse=True), key=lambda k: k['room_type']['id'])
@api.depends('room_lines')
@api.depends('reservation_ids')
def _compute_has_cancelled_reservations_to_send(self):
super()._compute_has_cancelled_reservations_to_send()
channel_hotel_reserv_obj = self.env['channel.hotel.reservation']
for record in self:
splitted_reservation_ids = record.room_lines.filtered(lambda x: x.splitted)
splitted_reservation_ids = record.reservation_ids.filtered(lambda x: x.splitted)
has_to_send = False
for rline in splitted_reservation_ids:
master_reservation = rline.parent_reservation or rline

View File

@@ -9,22 +9,22 @@
<field name="has_channel_reservations" invisible="True" />
<field name="customer_notes" readonly="True" attrs="{'invisible':[('has_channel_reservations', '=', False)]}"/>
</xpath>
<!--xpath expr="//notebook/page/field[@name='room_lines']/tree/field[@name='checkout']" position="after">
<!--xpath expr="//notebook/page/field[@name='reservation_ids']/tree/field[@name='checkout']" position="after">
<field name="is_from_ota" invisible="1"/>
</xpath>
<xpath expr="//notebook/page/field[@name='room_lines']/tree/field[@name='checkout']" position="attributes">
<xpath expr="//notebook/page/field[@name='reservation_ids']/tree/field[@name='checkout']" position="attributes">
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
</xpath>
<xpath expr="//notebook/page/field[@name='room_lines']/tree/field[@name='checkin']" position="attributes">
<xpath expr="//notebook/page/field[@name='reservation_ids']/tree/field[@name='checkin']" position="attributes">
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
</xpath>
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/header/field[@name='folio_id']" position="after">
<xpath expr="//notebook/page/field[@name='reservation_ids']/form/sheet/header/field[@name='folio_id']" position="after">
<field name="is_from_ota" invisible="1"/>
</xpath>
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/h3/field[@name='checkout']" position="attributes">
<xpath expr="//notebook/page/field[@name='reservation_ids']/form/sheet/h3/field[@name='checkout']" position="attributes">
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
</xpath>
<xpath expr="//notebook/page/field[@name='room_lines']/form/sheet/h3/field[@name='checkin']" position="attributes">
<xpath expr="//notebook/page/field[@name='reservation_ids']/form/sheet/h3/field[@name='checkin']" position="attributes">
<attribute name="attrs">{'readonly': [('is_from_ota', '!=', False)]}</attribute>
</xpath-->
</field>

View File

@@ -634,7 +634,7 @@ class HotelReservationImporter(Component):
addons = str(book['addons_list']) if any(book['addons_list']) else ''
discounts = book.get('discount', '')
vals = {
'room_lines': reservations,
'reservation_ids': reservations,
'customer_notes': "%s\nADDONS:\n%s\nDISCOUNT:\n%s" % (
book['customer_notes'], addons, discounts),
'channel_type': 'web',
@@ -654,14 +654,14 @@ class HotelReservationImporter(Component):
# Update Reservation Spitted Parents
sorted_rlines = folio_id.room_lines.sorted(key='id')
sorted_rlines = folio_id.reservation_ids.sorted(key='id')
for k_pid, v_pid in splitted_map.items():
preserv = sorted_rlines[k_pid-1]
for pid in v_pid:
creserv = sorted_rlines[pid-1]
creserv.parent_reservation = preserv.id
# Bind reservations
rlines = sorted_rlines = folio_id.room_lines
rlines = sorted_rlines = folio_id.reservation_ids
for rline in rlines:
for rline_bind in rline.channel_bind_ids:
self.binder.bind(rline_bind.external_id, rline_bind)

View File

@@ -20,7 +20,7 @@ class HotelReservation(models.Model):
# the proportional deposit part if the folio has more rooms that the
# reservations code (this happens when in the same folio are
# reservations with different checkins/outs convinations)
if len(folio.room_lines) > len(reservations) and folio.invoices_paid > 0:
if len(folio.reservation_ids) > len(reservations) and folio.invoices_paid > 0:
total_reservations = sum(reservations.mapped('price_total'))
paid_in_folio = folio.invoices_paid