[WIP] moved settings to company / hotel / user models

This commit is contained in:
Pablo
2019-08-29 18:11:28 +02:00
parent a2d94c19c5
commit a41c4c6902
17 changed files with 197 additions and 164 deletions

View File

@@ -35,7 +35,6 @@
'wizard/massive_price_reservation_days.xml',
'wizard/folio_make_invoice_advance_views.xml',
'data/hotel_sequence.xml',
'views/inherited_res_company_views.xml',
'views/inherited_res_users_views.xml',
'views/hotel_property_views.xml',
'views/hotel_floor_views.xml',

View File

@@ -40,6 +40,9 @@ class HotelProperty(models.Model):
# TODO: refactoring 'res.config.settings', 'tz_hotel' by the current hotel.property.tz (inherited in res.partner)
default_cancel_policy_days = fields.Integer('Cancellation Days')
default_cancel_policy_percent = fields.Float('Percent to pay')
def _check_hours(self):
r = re.compile('[0-2][0-9]:[0-5][0-9]')
if not r.match(self.arrival_hour):

View File

@@ -18,7 +18,7 @@ class HotelRoomTypeRestriction(models.Model):
help='If unchecked, it will allow you to hide the '
'restriction plan without removing it.')
hotel_ids = fields.One2many('hotel.property',
'restriction_id', string='Restriction Plan',
'restriction_id', string='Hotel',
default=_get_default_hotel, required=True)
@api.multi

View File

@@ -9,18 +9,18 @@ class ResCompany(models.Model):
hotel_ids = fields.One2many('hotel.property', 'company_id', 'Hotels')
additional_hours = fields.Integer('Additional Hours',
help="Provide the min hours value for \
check in, checkout days, whatever \
the hours will be provided here based \
on that extra days will be \
calculated.")
default_cancel_policy_days = fields.Integer('Cancelation Days')
default_cancel_policy_percent = fields.Integer('Percent to pay')
cardex_warning = fields.Text(
'Warning in Cardex',
default="Time to access rooms: 14: 00h. Departure time: \
12: 00h. If the accommodation is not left at that time, \
the establishment will charge a day's stay according to \
current rate that day",
help="Notice under the signature on the traveler's ticket.")
# TODO: need extra explanation or remove otherwise
# additional_hours = fields.Integer('Additional Hours',
# help="Provide the min hours value for \
# check in, checkout days, whatever \
# the hours will be provided here based \
# on that extra days will be \
# calculated.")
# TODO: move the text to the default template for confirmed reservations
# cardex_warning = fields.Text(
# 'Warning in Cardex',
# default="Time to access rooms: 14: 00h. Departure time: \
# 12: 00h. If the accommodation is not left at that time, \
# the establishment will charge a day's stay according to \
# current rate that day",
# help="Notice under the signature on the traveler's ticket.")

View File

@@ -20,19 +20,23 @@
</group>
</page>
<page string="Settings" name="hotel_settings">
<group colspan="4" col="4">
<group colspan="4" col="4" string="Price and Restriction Plans">
<field name="pricelist_id" required="True" />
<field name="restriction_id" required="True" />
</group>
<group>
<group string="Timezone">
<field name="tz" widget="timezone_mismatch"/>
</group>
<group colspan="4" col="4">
<group colspan="4" col="4" string="Check-in hours">
<field name="arrival_hour" />
<field name="departure_hour" />
</group>
<group colspan="4" col="4" string="Cancellation policies">
<field name="default_cancel_policy_days" />
<field name="default_cancel_policy_percent" />
</group>
</page>
<page string="Rooms" name="hotel_settings">
<page string="Rooms" name="hotel_rooms">
<group>
<field name="room_type_ids"/>
<field name="room_ids"/>

View File

@@ -22,14 +22,13 @@
'data': [
'views/general.xml',
'views/actions.xml',
'views/inherited_hotel_property_views.xml',
'views/inherited_res_company_views.xml',
'views/inherited_res_users_views.xml',
# 'views/inherited_hotel_room_type_views.xml',
# 'views/inherited_hotel_room_views.xml',
'views/hotel_reservation_views.xml',
'views/hotel_calendar_management_views.xml',
'views/hotel_calendar_views.xml',
'data/menus.xml',
'views/res_config.xml',
'data/ir_config_parameter.xml',
'security/ir.model.access.csv',
],

View File

@@ -1,12 +1,12 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import inherited_hotel_property
from . import hotel_calendar
from . import bus_hotel_calendar
from . import hotel_calendar_management
from . import inherited_hotel_reservation
from . import inherited_res_company
from . import inherited_res_users
# from . import inherited_hotel_room
# from . import inherited_hotel_room_type
from . import inherited_hotel_room_type_restriction_item
from . import inherited_product_pricelist
from . import inherited_product_pricelist_item

View File

@@ -216,18 +216,15 @@ class HotelCalendarManagement(models.TransientModel):
if not dfrom or not dto:
raise ValidationError(_('Input Error: No dates defined!'))
vals = {}
# TODO: res.config by hotel
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
if not pricelist_id:
pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
pricelist_id = self.env.user.hotel_id.pricelist_id.id
# TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id
if not restriction_id:
restriction_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_restriction_id')
restriction_id = self.env.user.hotel_id.restriction_id.id
# TODO: ensure pricelist_id and restriction_id belong to the current hotel
pricelist_id = int(pricelist_id)
vals.update({'pricelist_id': pricelist_id})
restriction_id = int(restriction_id)
vals.update({'restriction_id': restriction_id})
restriction_item_ids = self.env['hotel.room.type.restriction.item'].search([

View File

@@ -0,0 +1,50 @@
# Copyright 2019 Pablo Quesada
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class HotelProperty(models.Model):
_inherit = 'hotel.property'
pms_show_num_rooms = fields.Integer('Number of rooms to show',
default=0)
pms_divide_rooms_by_capacity = fields.Boolean('Divide rooms by capacity',
default=True)
pms_end_day_week = fields.Selection([
('1', 'Monday'),
('2', 'Tuesday'),
('3', 'Wednesday'),
('4', 'Thursday'),
('5', 'Friday'),
('6', 'Saturday'),
('7', 'Sunday')
], string='Highlight column of day', default='6')
pms_end_day_week_offset = fields.Selection([
('0', '0 Days'),
('1', '1 Days'),
('2', '2 Days'),
('3', '3 Days'),
('4', '4 Days'),
('5', '5 Days'),
('6', '6 Days')
], string='Also illuminate the previous', default='0')
pms_default_num_days = fields.Selection([
('month', '1 Month'),
('21', '3 Weeks'),
('14', '2 Weeks'),
('7', '1 Week')
], string='Default number of days', default='month')
# TODO: review the use of the following option in the calendar js functions
pms_type_move = fields.Selection([
('normal', 'Normal'),
('assisted', 'Assisted'),
('allow_invalid', 'Allow Invalid')
], string='Reservation move mode', default='normal')
pms_allowed_events_tags = fields.Many2many(
'calendar.event.type',
string="Allow Calendar Event Tags")
pms_denied_events_tags = fields.Many2many(
'calendar.event.type',
string="Deny Calendar Event Tags")

View File

@@ -133,10 +133,8 @@ class HotelReservation(models.Model):
@api.model
def _hcalendar_room_data(self, rooms):
_logger.warning('_found [%s] rooms for hotel [%s]', len(rooms), self.env.user.hotel_id.id)
pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_id:
pricelist_id = int(pricelist_id)
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_id = self.env.user.hotel_id.pricelist_id.id
json_rooms = [
{
'id': room.id,
@@ -242,13 +240,9 @@ class HotelReservation(models.Model):
@api.model
def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt):
pricelist_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_id:
pricelist_id = int(pricelist_id)
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_id = self.env.user.hotel_id.pricelist_id.id
hotel_id = self.env.user.hotel_id.id
room_types_ids = self.env['hotel.room.type'].search([
('hotel_id', '=', hotel_id)
])
@@ -301,13 +295,9 @@ class HotelReservation(models.Model):
@api.model
def get_hcalendar_restrictions_data(self, dfrom_dt, dto_dt):
restriction_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_restriction_id')
if restriction_id:
restriction_id = int(restriction_id)
# TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id
restriction_id = self.env.user.hotel_id.restriction_id.id
hotel_id = self.env.user.hotel_id.id
# Get Restrictions
json_rooms_rests = {}
room_typed_ids = self.env['hotel.room.type'].search([], order='sequence ASC')
@@ -369,10 +359,8 @@ class HotelReservation(models.Model):
'days': user_id.pms_default_num_days,
'allow_invalid_actions': type_move == 'allow_invalid',
'assisted_movement': type_move == 'assisted',
'default_arrival_hour': self.env['ir.default'].sudo().get(
'res.config.settings', 'default_arrival_hour'),
'default_departure_hour': self.env['ir.default'].sudo().get(
'res.config.settings', 'default_departure_hour'),
'default_arrival_hour': self.env.user.hotel_id.arrival_hour,
'default_departure_hour': self.env.user.hotel_id.departure_hour,
'show_notifications': user_id.pms_show_notifications,
'show_pricelist': user_id.pms_show_pricelist,
'show_availability': user_id.pms_show_availability,

View File

@@ -11,11 +11,8 @@ class HotelRoomTypeResrtrictionItem(models.Model):
@api.model
def create(self, vals):
res = super(HotelRoomTypeResrtrictionItem, self).create(vals)
restrictions_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_restriction_id')
if restrictions_default_id:
restrictions_default_id = int(restrictions_default_id)
if res.restriction_id.id == restrictions_default_id:
# TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id
if res.restriction_id.id == self.env.user.hotel_id.restriction_id.id:
self.env['bus.hotel.calendar'].send_restriction_notification({
'restriction_id': res.restriction_id.id,
'date': res.date,
@@ -53,14 +50,12 @@ class HotelRoomTypeResrtrictionItem(models.Model):
@api.multi
def unlink(self):
restrictions_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_restriction_id')
if restrictions_default_id:
restrictions_default_id = int(restrictions_default_id)
# TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id
default_restriction_id = self.env.user.hotel_id.restriction_id.id
# Construct dictionary with relevant info of removed records
unlink_vals = []
for record in self:
if record.restriction_id.id != restrictions_default_id:
if record.restriction_id.id != default_restriction_id:
continue
unlink_vals.append({
'restriction_id': record.restriction_id.id,

View File

@@ -9,6 +9,7 @@ class ProductPricelistItem(models.Model):
@api.model
def create(self, vals):
res = super(ProductPricelistItem, self).create(vals)
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:
@@ -37,6 +38,7 @@ class ProductPricelistItem(models.Model):
@api.multi
def write(self, vals):
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:
@@ -76,6 +78,7 @@ class ProductPricelistItem(models.Model):
@api.multi
def unlink(self):
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:

View File

@@ -0,0 +1,30 @@
# Copyright 2019 Pablo Quesada
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class ResCompany(models.Model):
_inherit = 'res.company'
color_pre_reservation = fields.Char('Pre-reservation', default='#A24680')
color_reservation = fields.Char('Confirmed Reservation ', default='#7C7BAD')
color_reservation_pay = fields.Char('Paid Reservation', default='#584D76')
color_stay = fields.Char('Checkin', default='#FF4040')
color_stay_pay = fields.Char('Paid Checkin', default='#82BF07')
color_checkout = fields.Char('Checkout', default='#7E7E7E')
color_dontsell = fields.Char('Dont Sell', default='#000000')
color_staff = fields.Char('Staff', default='#C08686')
color_to_assign = fields.Char('Ota Reservation to Assign', default='#ED722E')
color_payment_pending = fields.Char('Payment Pending', default='#A24689')
color_letter_pre_reservation = fields.Char('Letter Pre-reservation', default='#FFFFFF')
color_letter_reservation = fields.Char('Letter Confirmed Reservation ', default='#FFFFFF')
color_letter_reservation_pay = fields.Char('Letter Paid Reservation', default='#FFFFFF')
color_letter_stay = fields.Char('Letter Checkin', default='#FFFFFF')
color_letter_stay_pay = fields.Char('Letter Stay Pay', default='#FFFFFF')
color_letter_checkout = fields.Char('Letter Checkout', default='#FFFFFF')
color_letter_dontsell = fields.Char('Letter Dont Sell', default='#FFFFFF')
color_letter_staff = fields.Char('Letter Staff', default='#FFFFFF')
color_letter_to_assign = fields.Char('Letter Ota to Assign', default='#FFFFFF')
color_letter_payment_pending = fields.Char('Letter Payment Pending', default='#FFFFFF')

View File

@@ -6,50 +6,10 @@ from odoo import models, fields
class ResUsers(models.Model):
_inherit = 'res.users'
pms_divide_rooms_by_capacity = fields.Boolean('Divide rooms by capacity',
default=True)
pms_end_day_week = fields.Selection([
('1', 'Monday'),
('2', 'Tuesday'),
('3', 'Wednesday'),
('4', 'Thursday'),
('5', 'Friday'),
('6', 'Saturday'),
('7', 'Sunday')
], string='End day of week', default='6')
pms_end_day_week_offset = fields.Selection([
('0', '0 Days'),
('1', '1 Days'),
('2', '2 Days'),
('3', '3 Days'),
('4', '4 Days'),
('5', '5 Days'),
('6', '6 Days')
], string='Also illuminate the previous', default='0')
pms_type_move = fields.Selection([
('normal', 'Normal'),
('assisted', 'Assisted'),
('allow_invalid', 'Allow Invalid')
], string='Reservation move mode', default='normal')
pms_default_num_days = fields.Selection([
('month', '1 Month'),
('21', '3 Weeks'),
('14', '2 Weeks'),
('7', '1 Week')
], string='Default number of days', default='month')
pms_show_notifications = fields.Boolean('Show Notifications', default=True)
pms_show_pricelist = fields.Boolean('Show Pricelist', default=True)
pms_show_availability = fields.Boolean('Show Availability', default=True)
pms_show_num_rooms = fields.Integer('Show Num. Rooms', default=0)
pms_allowed_events_tags = fields.Many2many(
'calendar.event.type',
string="Allow Calander Event Tags")
pms_denied_events_tags = fields.Many2many(
'calendar.event.type',
string="Deny Calander Event Tags")
# TODO Allow calendar events? by user / by hotel / by company ?
npms_end_day_week = fields.Selection([
('1', 'Monday'),
('2', 'Tuesday'),
@@ -77,10 +37,10 @@ class ResUsers(models.Model):
npms_allowed_events_tags = fields.Many2many(
'calendar.event.type',
string="Allow Calander Event Tags")
string="Allow Calandar Event Tags")
npms_denied_events_tags = fields.Many2many(
'calendar.event.type',
string="Deny Calander Event Tags")
string="Deny Calandar Event Tags")
def __init__(self, pool, cr):
""" Override of __init__ to add access rights.
@@ -91,40 +51,14 @@ class ResUsers(models.Model):
# duplicate list to avoid modifying the original reference
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
type(self).SELF_WRITEABLE_FIELDS.extend([
'pms_divide_rooms_by_capacity',
'pms_end_day_week',
'pms_end_day_week_offset',
'pms_type_move',
'pms_default_num_days',
'pms_show_notifications',
'pms_show_pricelist',
'pms_show_availability',
'pms_show_num_rooms',
'pms_allowed_events_tags',
'pms_denied_events_tags',
'npms_end_day_week',
'npms_end_day_week_offset',
'npms_default_num_days',
'npms_allowed_events_tags',
'npms_denied_events_tags',
])
# duplicate list to avoid modifying the original reference
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend([
'pms_divide_rooms_by_capacity',
'pms_end_day_week',
'pms_end_day_week_offset',
'pms_type_move',
'pms_default_num_days',
'pms_show_notifications',
'pms_show_pricelist',
'pms_show_availability',
'pms_show_num_rooms',
'pms_allowed_events_tags',
'pms_denied_events_tags',
'npms_end_day_week',
'npms_end_day_week_offset',
'npms_default_num_days',
'npms_allowed_events_tags',
'npms_denied_events_tags',
])

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hotel_property_views_form" model="ir.ui.view">
<field name="model">hotel.property</field>
<field name="inherit_id" ref="hotel.hotel_property_views_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='hotel_settings']" position="after">
<page string='Calendar Settings' name="hotel_calendar">
<group colspan="4">
<group string="Rooms and Reservations">
<field name="pms_show_num_rooms" />
<field name="pms_divide_rooms_by_capacity" />
<field name="pms_type_move" required="True" />
</group>
<group string="Calendar (PMS)">
<field name="pms_end_day_week" required="True" />
<field name="pms_end_day_week_offset" required="True" />
<field name="pms_default_num_days" required="True" />
</group>
<group string="Events">
<field name="pms_allowed_events_tags" widget="many2many_tags" />
<field name="pms_denied_events_tags" widget="many2many_tags" />
</group>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

View File

@@ -8,9 +8,32 @@
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//page" position="after">
<page string="Hotels" name="hotel_page">
<group name="hotel">
<field name="hotel_ids"/>
<page string="Hotel Preferences" name="hotel_preferences">
<group>
<group string="Reservation Background Colors">
<field name="color_pre_reservation" widget="color" />
<field name="color_reservation" widget="color" />
<field name="color_reservation_pay" widget="color" />
<field name="color_stay" widget="color" />
<field name="color_stay_pay" widget="color" />
<field name="color_checkout" widget="color" />
<field name="color_dontsell" widget="color" />
<field name="color_staff" widget="color" />
<field name="color_to_assign" widget="color" />
<field name="color_payment_pending" widget="color" />
</group>
<group string="Reservation Letter Colors">
<field name="color_letter_pre_reservation" widget="color" />
<field name="color_letter_reservation" widget="color" />
<field name="color_letter_reservation_pay" widget="color" />
<field name="color_letter_stay" widget="color" />
<field name="color_letter_stay_pay" widget="color" />
<field name="color_letter_checkout" widget="color" />
<field name="color_letter_dontsell" widget="color" />
<field name="color_letter_staff" widget="color" />
<field name="color_letter_to_assign" widget="color" />
<field name="color_letter_payment_pending" widget="color" />
</group>
</group>
</page>
</xpath>

View File

@@ -1,43 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_users_view_form" model="ir.ui.view">
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form" />
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<xpath expr="//page/group/group[@name='preferences']" position="before">
<group string="Calendar (PMS)" name="calendar">
<group colspan="4">
<xpath expr="//group[@name='preferences']" position="after">
<group string="Calendar (PMS) Preferences" name="preferences_calendar">
<group col="8" colspan="4">
<field name="pms_show_notifications" />
<field name="pms_show_pricelist" />
<field name="pms_show_availability" />
<field name="pms_show_num_rooms" />
</group>
<group colspan="4">
<field name="pms_divide_rooms_by_capacity" />
<field name="pms_end_day_week" required="True" />
<field name="pms_end_day_week_offset" required="True" />
<field name="pms_type_move" required="True" />
<field name="pms_default_num_days" required="True" />
</group>
<group colspan="4">
<field name="pms_allowed_events_tags" widget="many2many_tags" />
<field name="pms_denied_events_tags" widget="many2many_tags" />
</group>
</group>
<group string="Calendar Management (Revenue PMS)" name="calendar">
<group colspan="4">
<field name="npms_end_day_week" required="True" />
<field name="npms_end_day_week_offset" required="True" />
<field name="npms_default_num_days" required="True" />
</group>
<group colspan="4">
<field name="npms_allowed_events_tags" widget="many2many_tags" />
<field name="npms_denied_events_tags" widget="many2many_tags" />
</group>
</group>
</xpath>
</field>
</record>
</odoo>
</odoo>