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)
|
||||
|
||||
|
||||
@@ -187,7 +187,10 @@
|
||||
<field name="mobile" placeholder="mobile" widget="phone"
|
||||
attrs="{'invisible': [('reservation_type','in',('out'))]}"/>
|
||||
<field name="phone" placeholder="phone" widget="phone"
|
||||
attrs="{'invisible': [('reservation_type','in',('out'))]}"/>
|
||||
attrs="{'invisible': [('reservation_type','in',('out'))],
|
||||
'required': [('channel_type','in',('door','mail','phone')),
|
||||
('mobile','=','')]}"
|
||||
/>
|
||||
<field name="pricelist_id"
|
||||
attrs="{'invisible': [('reservation_type','in',('out'))]}"/>
|
||||
<field name="partner_internal_comment" string="Partner Note"
|
||||
@@ -500,7 +503,8 @@
|
||||
<xpath expr="//field[@name='state']" position="before">
|
||||
<button type="object" class="oe_stat_button"
|
||||
icon="fa fa-2x fa-suitcase"
|
||||
name="open_reservation_form"/>
|
||||
name="open_reservation_form"
|
||||
help="Open Reservation Room Detail"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='folio_id']" position="attributes">
|
||||
<attribute name="invisible">1</attribute>
|
||||
|
||||
@@ -55,6 +55,9 @@ class FolioWizard(models.TransientModel):
|
||||
'res.config.settings', 'default_pricelist_id')
|
||||
|
||||
partner_id = fields.Many2one('res.partner', required=True, string="Customer")
|
||||
email = fields.Char('E-mail')
|
||||
mobile = fields.Char('Mobile')
|
||||
|
||||
pricelist_id = fields.Many2one('product.pricelist',
|
||||
string='Pricelist',
|
||||
required=True,
|
||||
@@ -250,6 +253,8 @@ class FolioWizard(models.TransientModel):
|
||||
'service_lines': services,
|
||||
'internal_comment': self.internal_comment,
|
||||
'credit_card_details': self.credit_card_details,
|
||||
'email': self.email,
|
||||
'mobile': self.mobile,
|
||||
}
|
||||
newfol = self.env['hotel.folio'].create(vals)
|
||||
if self.confirm:
|
||||
@@ -289,6 +294,22 @@ class HotelRoomTypeWizards(models.TransientModel):
|
||||
checkout = fields.Date('Check Out', required=True,
|
||||
default=_get_default_checkout)
|
||||
can_confirm = fields.Boolean(compute="_can_confirm")
|
||||
board_service_room_id = fields.Many2one('hotel.board.service.room.type',
|
||||
string="Board Service")
|
||||
|
||||
@api.multi
|
||||
@api.onchange('rooms_num')
|
||||
def domain_board_service(self):
|
||||
for line in self:
|
||||
board_service_room_ids = []
|
||||
if line.room_type_id:
|
||||
pricelist_id = self.folio_wizard_id.pricelist_id.id
|
||||
board_services_room_type = self.env['hotel.board.service.room.type'].\
|
||||
search([('hotel_room_type_id', '=', self.room_type_id.id),
|
||||
('pricelist_id', 'in', (pricelist_id, False))])
|
||||
board_service_room_ids = board_services_room_type.ids
|
||||
domain_boardservice = [('id', 'in', board_service_room_ids)]
|
||||
return {'domain': {'board_service_room_id': domain_boardservice}}
|
||||
|
||||
@api.multi
|
||||
def _can_confirm(self):
|
||||
@@ -479,7 +500,7 @@ class ServiceWizard(models.TransientModel):
|
||||
required=True,
|
||||
default=1.0)
|
||||
|
||||
@api.onchange('product_id', 'reservation_wizard_ids')
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
if self.product_id:
|
||||
# TODO change pricelist for partner
|
||||
|
||||
@@ -12,13 +12,15 @@
|
||||
<field name="checkin" required="1" />
|
||||
<field name="checkout" required="1" />
|
||||
<field name="partner_id"/>
|
||||
<field name="credit_card_details" />
|
||||
<field name="mobile" required="1"/>
|
||||
<field name="email" required="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="call_center" invisible="1" />
|
||||
<field name="channel_type" required="1" force_save="1" attrs="{'readonly':[('call_center','=',True)]}"/>
|
||||
<field name="pricelist_id"/>
|
||||
<field name="internal_comment"/>
|
||||
<field name="credit_card_details" />
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
@@ -32,7 +34,10 @@
|
||||
<field name="max_rooms" />
|
||||
<field name="folio_wizard_id" />
|
||||
<field name="room_type_id" string="Room Type" force_save="1" readonly="1"/>
|
||||
<field name="rooms_num" force_save="1" attrs="{'readonly': [('can_confirm','=',False)]}" />
|
||||
<field name="rooms_num" force_save="1" attrs="{'readonly': [('can_confirm', '=', False)]}" />
|
||||
<field name="board_service_room_id"
|
||||
attrs="{'readonly': [('rooms_num', '=', 0)]}"
|
||||
options="{'no_create': True,'no_open': True}" />
|
||||
<field name="checkin" widget="date" />
|
||||
<field name="checkout" widget="date" />
|
||||
<field name="discount" force_save="1" attrs="{'readonly': [('can_confirm','=',False)]}"/>
|
||||
@@ -75,7 +80,9 @@
|
||||
nolabel="1" >
|
||||
<tree string="Services" editable="buttom">
|
||||
<field name="product_id" string="Service" options="{'no_create': True}"
|
||||
domain="[('sale_ok', '=', True)]"/>
|
||||
domain="[('sale_ok', '=', True),
|
||||
('per_day', '=', False),
|
||||
('per_person', '=', False)]"/>
|
||||
<field name="folio_wizard_id" invisible = "1" />
|
||||
<field name="product_uom_qty" />
|
||||
<field name="price_unit" />
|
||||
|
||||
Reference in New Issue
Block a user