Merge branch 'pr_workflow_sales' into 11.0

This commit is contained in:
Dario Lodeiros
2019-03-14 00:19:08 +01:00
16 changed files with 3674 additions and 2631 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,8 @@
import datetime import datetime
from odoo import models, fields, api, _ from odoo import models, fields, api, _
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from odoo.tools import (
DEFAULT_SERVER_DATE_FORMAT)
class HotelCheckinPartner(models.Model): class HotelCheckinPartner(models.Model):
@@ -56,6 +58,15 @@ class HotelCheckinPartner(models.Model):
return reservation.partner_id return reservation.partner_id
return False return False
def _default_to_enter(self):
tz_hotel = self.env['ir.default'].sudo().get(
'res.config.settings', 'tz_hotel')
today = fields.Date.context_today(self.with_context(tz=tz_hotel))
today_str = fields.Date.from_string(today).strftime(
DEFAULT_SERVER_DATE_FORMAT)
if self._default_enter_date() == today_str:
return True
return False
partner_id = fields.Many2one('res.partner', default=_default_partner_id, partner_id = fields.Many2one('res.partner', default=_default_partner_id,
required=True) required=True)
@@ -64,9 +75,11 @@ class HotelCheckinPartner(models.Model):
reservation_id = fields.Many2one( reservation_id = fields.Many2one(
'hotel.reservation', default=_default_reservation_id) 'hotel.reservation', default=_default_reservation_id)
folio_id = fields.Many2one('hotel.folio', folio_id = fields.Many2one('hotel.folio',
default=_default_folio_id, readonly=True, required=True) default=_default_folio_id,
readonly=True, required=True)
enter_date = fields.Date(default=_default_enter_date, required=True) enter_date = fields.Date(default=_default_enter_date, required=True)
exit_date = fields.Date(default=_default_exit_date, required=True) exit_date = fields.Date(default=_default_exit_date, required=True)
auto_booking = fields.Boolean('Get in Now', default=_default_to_enter)
state = fields.Selection([('draft', 'Pending Entry'), state = fields.Selection([('draft', 'Pending Entry'),
('booking', 'On Board'), ('booking', 'On Board'),
('done', 'Out'), ('done', 'Out'),
@@ -74,11 +87,17 @@ class HotelCheckinPartner(models.Model):
'State', readonly=True, 'State', readonly=True,
default=lambda *a: 'draft', default=lambda *a: 'draft',
track_visibility='onchange') track_visibility='onchange')
@api.model
def create(self, vals):
record = super(HotelCheckinPartner, self).create(vals)
if vals.get('auto_booking', False):
record.action_on_board()
return record
# Validation for Departure date is after arrival date. # Validation for Departure date is after arrival date.
@api.multi @api.multi
@api.constrains('exit_date','enter_date') @api.constrains('exit_date', 'enter_date')
def _check_exit_date(self): def _check_exit_date(self):
for record in self: for record in self:
date_in = fields.Date.from_string(record.enter_date) date_in = fields.Date.from_string(record.enter_date)
@@ -104,8 +123,8 @@ class HotelCheckinPartner(models.Model):
def _check_partner_id(self): def _check_partner_id(self):
for record in self: for record in self:
checkins = self.env['hotel.checkin.partner'].search([ checkins = self.env['hotel.checkin.partner'].search([
('id','!=', record.id), ('id', '!=', record.id),
('reservation_id','=', record.reservation_id.id) ('reservation_id', '=', record.reservation_id.id)
]) ])
if record.partner_id.id in checkins.mapped('partner_id.id'): if record.partner_id.id in checkins.mapped('partner_id.id'):
raise models.ValidationError( raise models.ValidationError(
@@ -116,8 +135,8 @@ class HotelCheckinPartner(models.Model):
def _check_partner_id(self): def _check_partner_id(self):
for record in self: for record in self:
checkins = self.env['hotel.checkin.partner'].search([ checkins = self.env['hotel.checkin.partner'].search([
('id','!=', record.id), ('id', '!=', record.id),
('reservation_id','=', record.reservation_id.id) ('reservation_id', '=', record.reservation_id.id)
]) ])
if record.partner_id.id in checkins.mapped('partner_id.id'): if record.partner_id.id in checkins.mapped('partner_id.id'):
raise models.ValidationError( raise models.ValidationError(

View File

@@ -176,6 +176,7 @@ class HotelFolio(models.Model):
return_ids = fields.One2many('payment.return', 'folio_id', return_ids = fields.One2many('payment.return', 'folio_id',
readonly=True) readonly=True)
payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', oldname='payment_term') payment_term_id = fields.Many2one('account.payment.term', string='Payment Terms', oldname='payment_term')
credit_card_details = fields.Text('Credit Card Details')
#Amount Fields------------------------------------------------------ #Amount Fields------------------------------------------------------
pending_amount = fields.Monetary(compute='compute_amount', pending_amount = fields.Monetary(compute='compute_amount',

View File

@@ -369,9 +369,8 @@ class HotelReservation(models.Model):
vals['real_checkin'] = vals['checkin'] vals['real_checkin'] = vals['checkin']
vals['real_checkout'] = vals['checkout'] vals['real_checkout'] = vals['checkout']
record = super(HotelReservation, self).create(vals) record = super(HotelReservation, self).create(vals)
#~ if (record.state == 'draft' and record.folio_id.state == 'sale') or \ if record.preconfirm:
#~ record.preconfirm: record.confirm()
#~ record.confirm()
return record return record
@api.multi @api.multi
@@ -688,11 +687,16 @@ class HotelReservation(models.Model):
(fields.Date.from_string(self.checkout) - timedelta(days=1)). (fields.Date.from_string(self.checkout) - timedelta(days=1)).
strftime(DEFAULT_SERVER_DATE_FORMAT)) strftime(DEFAULT_SERVER_DATE_FORMAT))
rooms_occupied = occupied.mapped('room_id.id') rooms_occupied = occupied.mapped('room_id.id')
if self.room_id and self.room_id.id in rooms_occupied: if self.room_id:
warning_msg = _('You tried to change \ 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 with room those already reserved in this \
reservation period') reservation period: %s ') % occupied_name
raise ValidationError(warning_msg) raise ValidationError(warning_msg)
domain_rooms = [ domain_rooms = [
('id', 'not in', rooms_occupied) ('id', 'not in', rooms_occupied)
] ]
@@ -700,7 +704,7 @@ class HotelReservation(models.Model):
@api.onchange('partner_diff_invoicing') @api.onchange('partner_diff_invoicing')
def onchange_partner_diff_invoicing(self): 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}) self.update({'partner_invoice_id': self.partner_id.id})
elif self.partner_id == self.partner_invoice_id: elif self.partner_id == self.partner_invoice_id:
self.update({'partner_invoice_id': self.partner_id.address_get(['invoice'])['invoice'] or None}) self.update({'partner_invoice_id': self.partner_id.address_get(['invoice'])['invoice'] or None})
@@ -873,12 +877,15 @@ class HotelReservation(models.Model):
@api.model @api.model
def prepare_reservation_lines(self, dfrom, days, pricelist_id, vals=False, update_old_prices=False): def prepare_reservation_lines(self, dfrom, days, pricelist_id, vals=False, update_old_prices=False):
total_price = 0.0 total_price = 0.0
discount = 0
cmds = [(5, 0, 0)] cmds = [(5, 0, 0)]
if not vals: if not vals:
vals = {} vals = {}
room_type_id = vals.get('room_type_id') or self.room_type_id.id 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 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) 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): for i in range(0, days):
idate = (fields.Date.from_string(dfrom) + timedelta(days=i)).strftime( idate = (fields.Date.from_string(dfrom) + timedelta(days=i)).strftime(
DEFAULT_SERVER_DATE_FORMAT) DEFAULT_SERVER_DATE_FORMAT)
@@ -891,16 +898,18 @@ class HotelReservation(models.Model):
date=idate, date=idate,
pricelist=pricelist_id, pricelist=pricelist_id,
uom=product.uom_id.id) uom=product.uom_id.id)
line_price = self.env['account.tax']._fix_tax_included_price_company( # REVIEW this forces to have configured the taxes included in the price
product.price, product.taxes_id, self.tax_ids, self.company_id) line_price = product.price
if old_line and old_line.id: if old_line and old_line.id:
cmds.append((1, old_line.id, { cmds.append((1, old_line.id, {
'price': line_price 'price': line_price,
'discount': discount
})) }))
else: else:
cmds.append((0, False, { cmds.append((0, False, {
'date': idate, 'date': idate,
'price': line_price 'price': line_price,
'discount': discount
})) }))
else: else:
line_price = old_line.price line_price = old_line.price
@@ -1008,7 +1017,7 @@ class HotelReservation(models.Model):
occupied = occupied.filtered( occupied = occupied.filtered(
lambda r: r.room_id.id == self.room_id.id lambda r: r.room_id.id == self.room_id.id
and r.id != self.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: if occupied:
warning_msg = _('You tried to change/confirm \ warning_msg = _('You tried to change/confirm \
reservation with room those already reserved in this \ reservation with room those already reserved in this \

View File

@@ -21,4 +21,3 @@ class AccountInvoiceLine(models.Model):
'reservation_line_invoice_rel', 'reservation_line_invoice_rel',
'invoice_line_id', 'reservation_line_id', 'invoice_line_id', 'reservation_line_id',
string='Reservation Lines', readonly=True, copy=False) string='Reservation Lines', readonly=True, copy=False)

View File

@@ -6,7 +6,7 @@
name="Action checkin" name="Action checkin"
res_model="hotel.checkin.partner" res_model="hotel.checkin.partner"
view_mode="tree,form" /> view_mode="tree,form" />
<menuitem <menuitem
id="menu_hotel_checkin_partner" id="menu_hotel_checkin_partner"
name="Checkins" name="Checkins"
@@ -47,9 +47,12 @@
<button type="object" class="oe_stat_button" <button type="object" class="oe_stat_button"
icon="fa fa-2x fa-check-circle" icon="fa fa-2x fa-check-circle"
name="action_on_board" name="action_on_board"
attrs="{'invisible':[('state','not in', ['draft'])]}" attrs="{'invisible':['|',
help="Get in" ('state','not in', ['draft']),
('id','=',False)]}"
help="Get in"
/> />
<field name="auto_booking" attrs="{'invisible':[('id','!=',False)]}" />
<field name="partner_id" required="True"/> <field name="partner_id" required="True"/>
<field name="mobile"/> <field name="mobile"/>
<field name="email"/> <field name="email"/>
@@ -75,7 +78,7 @@
icon="fa fa-2x fa-check-circle" icon="fa fa-2x fa-check-circle"
name="action_on_board" name="action_on_board"
attrs="{'invisible':[('state','not in', ['draft'])]}" attrs="{'invisible':[('state','not in', ['draft'])]}"
help="Get in" help="Get in"
/> />
<field name="partner_id" required="True"/> <field name="partner_id" required="True"/>
<field name="mobile"/> <field name="mobile"/>
@@ -108,7 +111,7 @@
<filter string="Checkins Tomorrow" name="enter_tomorrow" <filter string="Checkins Tomorrow" name="enter_tomorrow"
domain="[('enter_date', '=', (context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')), domain="[('enter_date', '=', (context_today()+datetime.timedelta(days=1)).strftime('%Y-%m-%d')),
('state', '=', 'confirm')]" ('state', '=', 'confirm')]"
help="Show all checkins for enter tomorrow"/> help="Show all checkins for enter tomorrow"/>
<filter string="Checkins to 7 days" name="next_res_week" <filter string="Checkins to 7 days" name="next_res_week"
domain="[('enter_date', '&lt;', (context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')), domain="[('enter_date', '&lt;', (context_today()+datetime.timedelta(days=7)).strftime('%Y-%m-%d')),
('state', '=', 'confirm')]" ('state', '=', 'confirm')]"

View File

@@ -93,6 +93,7 @@
</group> </group>
<group> <group>
<field name="internal_comment"/> <field name="internal_comment"/>
<field name="credit_card_details" attrs="{'invisible':[('pending_amount','&lt;=',0)]}"/>
</group> </group>
<group colspan="2" class="oe_subtotal_footer oe_right"> <group colspan="2" class="oe_subtotal_footer oe_right">
<field name="amount_untaxed" sum="Untaxed amount" widget='monetary' /> <field name="amount_untaxed" sum="Untaxed amount" widget='monetary' />

View File

@@ -60,13 +60,6 @@
icon="fa-compress" icon="fa-compress"
attrs="{'invisible':[('splitted', '=', False)]}" attrs="{'invisible':[('splitted', '=', False)]}"
/> />
<label for="preconfirm"
string="Autoconfirm"
attrs="{'invisible':[('folio_id', '!=', False)]}"
/>
<span name="preconfirm" attrs="{'invisible':[('folio_id', '!=', False)]}">
<field name="preconfirm" />
</span>
<button name="open_master" string="Open Master" type="object" class="oe_highlight" icon="fa-file" attrs="{'invisible':['|',['parent_reservation', '=', False]]}" /> <button name="open_master" string="Open Master" type="object" class="oe_highlight" icon="fa-file" attrs="{'invisible':['|',['parent_reservation', '=', False]]}" />
<field name="state" widget="statusbar"/> <field name="state" widget="statusbar"/>
@@ -148,10 +141,13 @@
<span class="label label-danger" attrs="{'invisible': [('state', 'not in', ('cancelled'))]}">Cancelled Reservation!</span> <span class="label label-danger" attrs="{'invisible': [('state', 'not in', ('cancelled'))]}">Cancelled Reservation!</span>
<span class="label label-warning" attrs="{'invisible': [('overbooking', '=', False)]}">OverBooking!</span> <span class="label label-warning" attrs="{'invisible': [('overbooking', '=', False)]}">OverBooking!</span>
<h1> <h1>
<!-- <field name="edit_room" nolabel="1" class="fa fa-bed" /> --> <label for="preconfirm"
<!-- <field name="room_id" select="1" domain="[('isroom','=',True)]" string="Autoconfirm"
nolabel="1" options="{'no_create': True,'no_open': True}" placeholder="Room" attrs="{'invisible':[('folio_id', '!=', False)]}"
style="margin-right: 30px;"/> --> />
<span name="preconfirm" attrs="{'invisible':[('folio_id', '!=', False)]}">
<field name="preconfirm" />
</span>
<field name="room_id" select="1" <field name="room_id" select="1"
nolabel="1" options="{'no_create': True,'no_open': True}" placeholder="Room" nolabel="1" options="{'no_create': True,'no_open': True}" placeholder="Room"
style="margin-right: 30px;" required='1'/> style="margin-right: 30px;" required='1'/>
@@ -187,7 +183,10 @@
<field name="mobile" placeholder="mobile" widget="phone" <field name="mobile" placeholder="mobile" widget="phone"
attrs="{'invisible': [('reservation_type','in',('out'))]}"/> attrs="{'invisible': [('reservation_type','in',('out'))]}"/>
<field name="phone" placeholder="phone" widget="phone" <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" <field name="pricelist_id"
attrs="{'invisible': [('reservation_type','in',('out'))]}"/> attrs="{'invisible': [('reservation_type','in',('out'))]}"/>
<field name="partner_internal_comment" string="Partner Note" <field name="partner_internal_comment" string="Partner Note"
@@ -445,7 +444,7 @@
/> />
<field name="folio_id"/> <field name="folio_id"/>
<button type="object" class="oe_stat_button" <button type="object" class="oe_stat_button"
icon="fa fa-1x fa-user-plus" icon="fa fa-2x fa-user-plus"
name="action_checks" name="action_checks"
context="{'partner_id': partner_id,'enter_date': checkin, context="{'partner_id': partner_id,'enter_date': checkin,
'exit_date': checkout,'reservation_id': id, 'hidden_checkin_partner': True, 'edit_checkin_partner': True }" 'exit_date': checkout,'reservation_id': id, 'hidden_checkin_partner': True, 'edit_checkin_partner': True }"
@@ -497,6 +496,12 @@
<attribute name="delete">false</attribute> <attribute name="delete">false</attribute>
<attribute name="string">Rooms</attribute> <attribute name="string">Rooms</attribute>
</tree> </tree>
<xpath expr="//field[@name='state']" position="before">
<button type="object" class="oe_stat_button"
icon="fa fa-2x fa-suitcase"
name="open_reservation_form"
help="Open Reservation Room Detail"/>
</xpath>
<xpath expr="//field[@name='folio_id']" position="attributes"> <xpath expr="//field[@name='folio_id']" position="attributes">
<attribute name="invisible">1</attribute> <attribute name="invisible">1</attribute>
</xpath> </xpath>
@@ -506,9 +511,6 @@
<xpath expr="//button[@name='open_folio'][2]" position="attributes"> <xpath expr="//button[@name='open_folio'][2]" position="attributes">
<attribute name="invisible">True</attribute> <attribute name="invisible">True</attribute>
</xpath> </xpath>
<xpath expr="//button[@name='open_folio'][2]" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//button[@name='%(open_hotel_reservation_form_tree_all)d']" position="attributes"> <xpath expr="//button[@name='%(open_hotel_reservation_form_tree_all)d']" position="attributes">
<attribute name="invisible">True</attribute> <attribute name="invisible">True</attribute>
</xpath> </xpath>
@@ -521,6 +523,12 @@
<xpath expr="//field[@name='create_uid']" position="attributes"> <xpath expr="//field[@name='create_uid']" position="attributes">
<attribute name="invisible">True</attribute> <attribute name="invisible">True</attribute>
</xpath> </xpath>
<xpath expr="//field[@name='create_date']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
<xpath expr="//field[@name='last_updated_res']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
</field> </field>
</record> </record>

View File

@@ -8,7 +8,7 @@
<xpath expr="//field[@name='communication']" position="after"> <xpath expr="//field[@name='communication']" position="after">
<field name="folio_id"/> <field name="folio_id"/>
<field name="save_amount" invisible="1"/> <field name="save_amount" invisible="1"/>
<field name="save_journal" invisible="1"/> <field name="save_journal_id" invisible="1"/>
<field name="save_date" invisible="1"/> <field name="save_date" invisible="1"/>
</xpath> </xpath>
</field> </field>

View File

@@ -49,11 +49,26 @@ class FolioWizard(models.TransientModel):
if user.has_group('hotel.group_hotel_call'): if user.has_group('hotel.group_hotel_call'):
return 'phone' return 'phone'
partner_id = fields.Many2one('res.partner',string="Customer") @api.model
def _get_default_pricelist(self):
return self.env['ir.default'].sudo().get(
'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,
default=_get_default_pricelist,
help="Pricelist for current folio.")
checkin = fields.Date('Check In', required=True, checkin = fields.Date('Check In', required=True,
default=_get_default_checkin) default=_get_default_checkin)
checkout = fields.Date('Check Out', required=True, checkout = fields.Date('Check Out', required=True,
default=_get_default_checkout) default=_get_default_checkout)
credit_card_details = fields.Text('Credit Card Details')
internal_comment = fields.Text(string='Internal Folio Notes')
reservation_wizard_ids = fields.One2many('hotel.reservation.wizard', reservation_wizard_ids = fields.One2many('hotel.reservation.wizard',
'folio_wizard_id', 'folio_wizard_id',
string="Resevations") string="Resevations")
@@ -68,13 +83,28 @@ class FolioWizard(models.TransientModel):
('mail', 'Mail'), ('mail', 'Mail'),
('phone', 'Phone') ('phone', 'Phone')
], string='Sales Channel', default=_get_default_channel_type) ], string='Sales Channel', default=_get_default_channel_type)
room_type_wizard_ids = fields.Many2many('hotel.room.type.wizard', room_type_wizard_ids = fields.One2many('hotel.room.type.wizard',
string="Room Types") 'folio_wizard_id',
string="Room Types")
call_center = fields.Boolean(default=_get_default_center_user) call_center = fields.Boolean(default=_get_default_center_user)
def assign_rooms(self): def assign_rooms(self):
self.assign = True self.assign = True
@api.onchange('pricelist_id')
def onchange_pricelist_id(self):
if self.pricelist_id:
self.onchange_checks()
@api.onchange('partner_id')
def onchange_partner_id(self):
if self.partner_id:
pricelist = self.partner_id.property_product_pricelist and \
self.partner_id.property_product_pricelist.id or \
self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
self.pricelist_id = pricelist
@api.onchange('autoassign') @api.onchange('autoassign')
def create_reservations(self): def create_reservations(self):
self.ensure_one() self.ensure_one()
@@ -103,10 +133,7 @@ class FolioWizard(models.TransientModel):
checkout_dt = fields.Date.from_string(line.checkout) checkout_dt = fields.Date.from_string(line.checkout)
nights = abs((checkout_dt - checkin_dt).days) nights = abs((checkout_dt - checkin_dt).days)
for room in room_list: for room in room_list:
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.pricelist_id.id
'res.config.settings', 'default_pricelist_id')
if pricelist_id:
pricelist_id = int(pricelist_id)
res_price = 0 res_price = 0
for i in range(0, nights): for i in range(0, nights):
ndate = checkin_dt + timedelta(days=i) ndate = checkin_dt + timedelta(days=i)
@@ -224,6 +251,10 @@ class FolioWizard(models.TransientModel):
'channel_type': self.channel_type, 'channel_type': self.channel_type,
'room_lines': reservations, 'room_lines': reservations,
'service_lines': services, '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) newfol = self.env['hotel.folio'].create(vals)
if self.confirm: if self.confirm:
@@ -263,6 +294,22 @@ class HotelRoomTypeWizards(models.TransientModel):
checkout = fields.Date('Check Out', required=True, checkout = fields.Date('Check Out', required=True,
default=_get_default_checkout) default=_get_default_checkout)
can_confirm = fields.Boolean(compute="_can_confirm") 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 @api.multi
def _can_confirm(self): def _can_confirm(self):
@@ -281,9 +328,6 @@ class HotelRoomTypeWizards(models.TransientModel):
minstay_restrictions = self.env['hotel.room.type.restriction.item'].search([ minstay_restrictions = self.env['hotel.room.type.restriction.item'].search([
('room_type_id', '=', res.room_type_id.id), ('room_type_id', '=', res.room_type_id.id),
]) ])
avail_restrictions = self.env['hotel.room.type.availability'].search([
('room_type_id', '=', res.room_type_id.id)
])
real_max = len(res.room_type_id.check_availability_room_type( real_max = len(res.room_type_id.check_availability_room_type(
res.checkin, res.checkin,
res.checkout, res.checkout,
@@ -297,20 +341,12 @@ class HotelRoomTypeWizards(models.TransientModel):
dates.append(ndate_str) dates.append(ndate_str)
if minstay_restrictions: if minstay_restrictions:
date_min_days = minstay_restrictions.filtered( date_min_days = minstay_restrictions.filtered(
lambda r: r.date_start <= ndate_str and \ lambda r: r.date == ndate_str).min_stay
r.date_end >= ndate_str).min_stay
if date_min_days > min_stay: if date_min_days > min_stay:
min_stay = date_min_days min_stay = date_min_days
if user.has_group('hotel.group_hotel_call'):
if avail_restrictions:
max_avail = avail_restrictions.filtered(
lambda r: r.date == ndate_str).wmax_avail
if max_avail < avail:
avail = min(max_avail, real_max)
else: else:
avail = real_max avail = real_max
if 100000 > avail > 0: if 100000 > avail > 0:
res.max_rooms = avail res.max_rooms = avail
else: else:
@@ -330,12 +366,7 @@ class HotelRoomTypeWizards(models.TransientModel):
if chkin_utc_dt >= chkout_utc_dt: if chkin_utc_dt >= chkout_utc_dt:
chkout_utc_dt = chkin_utc_dt + timedelta(days=1) chkout_utc_dt = chkin_utc_dt + timedelta(days=1)
nights = abs((chkout_utc_dt - chkin_utc_dt).days) nights = abs((chkout_utc_dt - chkin_utc_dt).days)
pricelist_id = self.folio_wizard_id.pricelist_id.id
pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_id:
pricelist_id = int(pricelist_id)
res_price = 0 res_price = 0
for i in range(0, nights): for i in range(0, nights):
ndate = chkin_utc_dt + timedelta(days=i) ndate = chkin_utc_dt + timedelta(days=i)
@@ -347,8 +378,7 @@ class HotelRoomTypeWizards(models.TransientModel):
date=ndate_str, date=ndate_str,
pricelist=pricelist_id, pricelist=pricelist_id,
uom=record.room_type_id.product_id.uom_id.id) uom=record.room_type_id.product_id.uom_id.id)
res_price += self.env['account.tax']._fix_tax_included_price_company( res_price += product.price
product.price, product.taxes_id, product.taxes_id, self.env.user.company_id)
price = res_price - ((res_price * record.discount) * 0.01) price = res_price - ((res_price * record.discount) * 0.01)
total_price = record.rooms_num * price total_price = record.rooms_num * price
@@ -427,10 +457,7 @@ class ReservationWizard(models.TransientModel):
end_date_utc_dt = fields.Date.from_string(line.checkout) end_date_utc_dt = fields.Date.from_string(line.checkout)
if line.room_type_id: if line.room_type_id:
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.folio_wizard_id.pricelist_id.id
'res.config.settings', 'default_pricelist_id')
if pricelist_id:
pricelist_id = int(pricelist_id)
nights = abs((end_date_utc_dt - start_date_utc_dt).days) nights = abs((end_date_utc_dt - start_date_utc_dt).days)
res_price = 0 res_price = 0
for i in range(0, nights): for i in range(0, nights):
@@ -443,8 +470,7 @@ class ReservationWizard(models.TransientModel):
date=ndate_str, date=ndate_str,
pricelist=pricelist_id, pricelist=pricelist_id,
uom=line.room_type_id.product_id.uom_id.id) uom=line.room_type_id.product_id.uom_id.id)
res_price += self.env['account.tax']._fix_tax_included_price_company( res_price += product.price
product.price, product.taxes_id, product.taxes_id, self.env.user.company_id)
res_price = res_price - (res_price * self.discount) * 0.01 res_price = res_price - (res_price * self.discount) * 0.01
line.amount_reservation = res_price line.amount_reservation = res_price
line.price = res_price line.price = res_price
@@ -469,79 +495,24 @@ class ServiceWizard(models.TransientModel):
default=0.0) default=0.0)
price_total = fields.Float(compute='_compute_amount', string='Subtotal', price_total = fields.Float(compute='_compute_amount', string='Subtotal',
readonly=True, store=True) readonly=True, store=True)
reservation_wizard_ids = fields.Many2many('hotel.reservation.wizard', 'Rooms')
product_uom_qty = fields.Float(string='Quantity', product_uom_qty = fields.Float(string='Quantity',
digits=dp.get_precision('Product Unit of Measure'), digits=dp.get_precision('Product Unit of Measure'),
required=True, required=True,
default=1.0) default=1.0)
@api.onchange('product_id', 'reservation_wizard_ids') @api.onchange('product_id')
def onchange_product_id(self): def onchange_product_id(self):
if self.product_id: if self.product_id:
vals = {}
qty = 0
vals['product_uom_qty'] = 1.0
service_obj = self.env['hotel.service']
if self.product_id.per_day:
product = self.product_id
for room in self.reservation_wizard_ids:
lines = {}
lines.update(service_obj.prepare_service_lines(
dfrom=room.checkin,
days=room.nights,
per_person=product.per_person,
persons=room.adults))
qty += lines.get('service_line_ids')[1][2]['day_qty']
if self.product_id.daily_limit > 0:
limit = self.product_id.daily_limit
for day in self.service_line_ids:
out_qty = sum(self.env['hotel.service.line'].search([
('product_id', '=', self.product_id.id),
('date', '=', self.date),
('service_id', '!=', self.product_id.id)
]).mapped('day_qty'))
if limit < out_qty + self.day_qty:
raise ValidationError(
_("%s limit exceeded for %s")% (self.service_id.product_id.name,
self.date))
vals['product_uom_qty'] = qty
"""
Description and warnings
"""
product = self.product_id.with_context(
lang=self.folio_wizard_id.partner_id.lang,
partner=self.folio_wizard_id.partner_id.id
)
title = False
message = False
warning = {}
if product.sale_line_warn != 'no-message':
title = _("Warning for %s") % product.name
message = product.sale_line_warn_msg
warning['title'] = title
warning['message'] = message
result = {'warning': warning}
if product.sale_line_warn == 'block':
self.product_id = False
return result
"""
Compute tax and price unit
"""
#REVIEW: self._compute_tax_ids()
# TODO change pricelist for partner # TODO change pricelist for partner
pricelist_id = self.env['ir.default'].sudo().get( pricelist_id = self.folio_wizard_id.pricelist_id.id
'res.config.settings', 'default_pricelist_id') prod = self.product_id.with_context(
product = self.product_id.with_context( lang=self.folio_wizard_id.partner_id.lang,
lang=self.folio_wizard_id.partner_id.lang, partner=self.folio_wizard_id.partner_id.id,
partner=self.folio_wizard_id.partner_id.id, quantity=1,
quantity=1, date=fields.Datetime.now(),
date=fields.Datetime.now(), pricelist=pricelist_id,
pricelist=pricelist_id, uom=self.product_id.uom_id.id)
uom=product.uom_id.id) self.price_unit = prod.price
vals['price_unit'] = self.env['account.tax']._fix_tax_included_price_company(
product.price, product.taxes_id, product.taxes_id, self.env.user.company_id)
import wdb; wdb.set_trace()
self.update(vals)
@api.depends('price_unit', 'product_uom_qty', 'discount') @api.depends('price_unit', 'product_uom_qty', 'discount')
def _compute_amount(self): def _compute_amount(self):

View File

@@ -11,11 +11,16 @@
<group> <group>
<field name="checkin" required="1" /> <field name="checkin" required="1" />
<field name="checkout" required="1" /> <field name="checkout" required="1" />
<field name="partner_id"/>
<field name="mobile" required="1"/>
<field name="email" required="1"/>
</group> </group>
<group> <group>
<field name="call_center" invisible="1" /> <field name="call_center" invisible="1" />
<field name="channel_type" required="1" attrs="{'readonly':[('call_center','=',True)]}"/> <field name="channel_type" required="1" force_save="1" attrs="{'readonly':[('call_center','=',True)]}"/>
<field name="partner_id"/> <field name="pricelist_id"/>
<field name="internal_comment"/>
<field name="credit_card_details" />
</group> </group>
</group> </group>
<group> <group>
@@ -27,13 +32,17 @@
decoration-success="max_rooms &gt;= rooms_num and rooms_num &gt; 0"> decoration-success="max_rooms &gt;= rooms_num and rooms_num &gt; 0">
<field name="min_stay" /> <field name="min_stay" />
<field name="max_rooms" /> <field name="max_rooms" />
<field name="room_type_id" string="Room Type" readonly="1"/> <field name="folio_wizard_id" />
<field name="rooms_num" attrs="{'readonly': [('can_confirm','=',False)]}" /> <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="board_service_room_id"
attrs="{'readonly': [('rooms_num', '=', 0)]}"
options="{'no_create': True,'no_open': True}" />
<field name="checkin" widget="date" /> <field name="checkin" widget="date" />
<field name="checkout" widget="date" /> <field name="checkout" widget="date" />
<field name="discount" attrs="{'readonly': [('can_confirm','=',False)]}"/> <field name="discount" force_save="1" attrs="{'readonly': [('can_confirm','=',False)]}"/>
<field name="price" attrs="{'readonly': [('can_confirm','=',False)]}"/> <field name="price" force_save="1" attrs="{'readonly': [('can_confirm','=',False)]}"/>
<field name="amount_reservation" readonly="1" /> <field name="amount_reservation" force_save="1" readonly="1" />
<field name="total_price" invisible="1" /> <field name="total_price" invisible="1" />
<field name="can_confirm" invisible="1" /> <field name="can_confirm" invisible="1" />
</tree> </tree>
@@ -56,7 +65,7 @@
<field name="nights" /> <field name="nights" />
<field name="adults" /> <field name="adults" />
<field name="children" /> <field name="children" />
<field name="discount" /> <field name="discount" />
<field name="amount_reservation" /> <field name="amount_reservation" />
<field name="price" invisible = "1"/> <field name="price" invisible = "1"/>
<field name="partner_id" invisible = "1" /> <field name="partner_id" invisible = "1" />
@@ -71,13 +80,13 @@
nolabel="1" > nolabel="1" >
<tree string="Services" editable="buttom"> <tree string="Services" editable="buttom">
<field name="product_id" string="Service" options="{'no_create': True}" <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="folio_wizard_id" invisible = "1" />
<field name="product_uom_qty" /> <field name="product_uom_qty" />
<field name="price_unit" /> <field name="price_unit" />
<field name="discount" /> <field name="discount" />
<field name="reservation_wizard_ids" widget="many2many_tags"
domain="[('folio_wizard_id', '=', folio_wizard_id)]"/>
<field name="price_total" /> <field name="price_total" />
</tree> </tree>
</field> </field>

View File

@@ -1,111 +1,88 @@
# Translation of Odoo Server. # Translation of Odoo Server.
# This file contains the translation of the following modules: # This file contains the translation of the following modules:
# * hotel_calendar_wubook # * hotel_calendar_channel_connector
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-22 06:41+0000\n" "POT-Creation-Date: 2019-03-13 21:59+0000\n"
"PO-Revision-Date: 2018-05-22 06:41+0000\n" "PO-Revision-Date: 2019-03-13 23:01+0100\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: es\n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.actions.act_window,name:hotel_calendar_channel_connector.calendar_channel_connector_issues_action
msgid "Channel Connector Issues"
msgstr "Aviso de Conexión"
#. module: hotel_calendar_channel_connector
#. openerp-web #. openerp-web
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_templates.xml:10 #: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:30
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_view.xml:24
#, python-format #, python-format
msgid "Channel:" msgid "Channel:"
msgstr "Canal:" msgstr "Canal:"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree #: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_reservation
msgid "Final Price"
msgstr "Precio Final"
#. module: hotel_calendar_wubook
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Folio Pending Amount"
msgstr "Pendiente en Ficha"
#. module: hotel_calendar_wubook
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Hotel Reservation" msgid "Hotel Reservation"
msgstr "Reserva" msgstr "Reserva del hotel"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#. openerp-web #. openerp-web
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_view.xml:15 #: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:11
#, python-format #, python-format
msgid "ISSUES" msgid "Issues"
msgstr "AVISOS" msgstr "Avisos"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.hotel_reservation_view_form #: model:ir.ui.view,arch_db:hotel_calendar_channel_connector.hotel_reservation_view_form
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Mark as Read" msgid "Mark as Read"
msgstr "Marcar como leídp" msgstr "Marcar como leído"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: code:addons/hotel_calendar_wubook/models/inherited_wubook_issue.py:33 #: model:ir.actions.act_window,name:hotel_calendar_channel_connector.hotel_reservation_action_manager_request
#, python-format msgid "Reservations to Assign from Channel"
msgid "Oops! Issue Reported!!" msgstr "Reservas por asignar"
msgstr "Oops! ¡Aviso generado!"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Persons"
msgstr "Personas"
#. module: hotel_calendar_wubook
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Reservation Price"
msgstr "Precio de Reserva"
#. module: hotel_calendar_wubook
#: model:ir.actions.act_window,name:hotel_calendar_wubook.hotel_reservation_action_manager_request
msgid "Reservations to Assign from WuBook"
msgstr "Reservas por Asignar desde WuBook"
#. module: hotel_calendar_wubook
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Reserved Room Type"
msgstr "Tipo Habitación Reservada"
#. module: hotel_calendar_wubook
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
msgid "Room"
msgstr "Habitación"
#. module: hotel_calendar_wubook
#. openerp-web #. openerp-web
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_templates.xml:4 #: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_templates.xml:4
#, python-format #, python-format
msgid "Section:" msgid "Section:"
msgstr "Sección" msgstr "Sección:"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.actions.act_window,name:hotel_calendar_wubook.calendar_wubook_issues_action #. openerp-web
msgid "WuBook Issues" #: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:20
msgstr "Problemas de WuBook" #, python-format
msgid "To Assign"
msgstr "Por Asignar"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_wubook.model_bus_hotel_calendar #. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_templates.xml:11
#, python-format
msgid "WuBook:"
msgstr "WuBook:"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_bus_hotel_calendar
msgid "bus.hotel.calendar" msgid "bus.hotel.calendar"
msgstr "bus.hotel.calendar" msgstr "bus.hotel.calendar"
#. module: hotel_calendar_wubook #. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_wubook.model_hotel_reservation #: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_calendar_management
msgid "hotel reservation" msgid "hotel.calendar.management"
msgstr "Reserva" msgstr "hotel.calendar.management"
#. module: hotel_calendar_wubook
#: model:ir.model,name:hotel_calendar_wubook.model_wubook_issue
msgid "wubook.issue"
msgstr "wubook.issue"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_room_type_availability
msgid "hotel.room.type.availability"
msgstr "hotel.room.type.availability"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -60,8 +60,24 @@ class HotelReservation(models.Model):
if user.has_group('hotel.group_hotel_call'): if user.has_group('hotel.group_hotel_call'):
self.write({'to_assign': True}) self.write({'to_assign': True})
<<<<<<< HEAD
<<<<<<< 2076e6f9957b19690791d7ef40bbd5b5c59c96dd
return super(HotelReservation, self).action_cancel() return super(HotelReservation, self).action_cancel()
=======
res = super(HotelReservation, self).action_cancel()
for record in self:
# Only can cancel reservations created directly in wubook
for binding in record.channel_bind_ids:
if binding.external_id and not binding.ota_id and \
int(binding.channel_status) in WUBOOK_STATUS_GOOD:
self.sudo().env['channel.hotel.reservation']._event('on_record_cancel').notify(binding)
return res
>>>>>>> [WIP] Payments Notifications
=======
return super(HotelReservation, self).action_cancel()
>>>>>>> 11.0
@api.multi @api.multi
def confirm(self): def confirm(self):

File diff suppressed because it is too large Load Diff