mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Wizard Reservation with services
This commit is contained in:
@@ -688,11 +688,16 @@ class HotelReservation(models.Model):
|
||||
(fields.Date.from_string(self.checkout) - timedelta(days=1)).
|
||||
strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
rooms_occupied = occupied.mapped('room_id.id')
|
||||
if self.room_id and self.room_id.id in rooms_occupied:
|
||||
warning_msg = _('You tried to change \
|
||||
if self.room_id:
|
||||
occupied = occupied.filtered(
|
||||
lambda r: r.room_id.id == self.room_id.id
|
||||
and r.id != self._origin.id)
|
||||
if occupied:
|
||||
occupied_name = ', '.join(str(x.folio_id.name) for x in occupied)
|
||||
warning_msg = _('You tried to change/confirm \
|
||||
reservation with room those already reserved in this \
|
||||
reservation period')
|
||||
raise ValidationError(warning_msg)
|
||||
reservation period: %s ') % occupied_name
|
||||
raise ValidationError(warning_msg)
|
||||
domain_rooms = [
|
||||
('id', 'not in', rooms_occupied)
|
||||
]
|
||||
@@ -700,7 +705,7 @@ class HotelReservation(models.Model):
|
||||
|
||||
@api.onchange('partner_diff_invoicing')
|
||||
def onchange_partner_diff_invoicing(self):
|
||||
if self.partner_diff_invoicing == False:
|
||||
if self.partner_diff_invoicing is False:
|
||||
self.update({'partner_invoice_id': self.partner_id.id})
|
||||
elif self.partner_id == self.partner_invoice_id:
|
||||
self.update({'partner_invoice_id': self.partner_id.address_get(['invoice'])['invoice'] or None})
|
||||
@@ -873,12 +878,15 @@ class HotelReservation(models.Model):
|
||||
@api.model
|
||||
def prepare_reservation_lines(self, dfrom, days, pricelist_id, vals=False, update_old_prices=False):
|
||||
total_price = 0.0
|
||||
discount = 0
|
||||
cmds = [(5, 0, 0)]
|
||||
if not vals:
|
||||
vals = {}
|
||||
room_type_id = vals.get('room_type_id') or self.room_type_id.id
|
||||
product = self.env['hotel.room.type'].browse(room_type_id).product_id
|
||||
partner = self.env['res.partner'].browse(vals.get('partner_id') or self.partner_id.id)
|
||||
if 'discount' in vals and vals.get('discount') > 0:
|
||||
discount = vals.get('discount')
|
||||
for i in range(0, days):
|
||||
idate = (fields.Date.from_string(dfrom) + timedelta(days=i)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
@@ -895,12 +903,14 @@ class HotelReservation(models.Model):
|
||||
line_price = product.price
|
||||
if old_line and old_line.id:
|
||||
cmds.append((1, old_line.id, {
|
||||
'price': line_price
|
||||
'price': line_price,
|
||||
'discount': discount
|
||||
}))
|
||||
else:
|
||||
cmds.append((0, False, {
|
||||
'date': idate,
|
||||
'price': line_price
|
||||
'price': line_price,
|
||||
'discount': discount
|
||||
}))
|
||||
else:
|
||||
line_price = old_line.price
|
||||
@@ -1008,7 +1018,7 @@ class HotelReservation(models.Model):
|
||||
occupied = occupied.filtered(
|
||||
lambda r: r.room_id.id == self.room_id.id
|
||||
and r.id != self.id)
|
||||
occupied_name = ','.join(str(x.room_id.name) for x in occupied)
|
||||
occupied_name = ', '.join(str(x.folio_id.name) for x in occupied)
|
||||
if occupied:
|
||||
warning_msg = _('You tried to change/confirm \
|
||||
reservation with room those already reserved in this \
|
||||
|
||||
@@ -21,4 +21,3 @@ class AccountInvoiceLine(models.Model):
|
||||
'reservation_line_invoice_rel',
|
||||
'invoice_line_id', 'reservation_line_id',
|
||||
string='Reservation Lines', readonly=True, copy=False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user