diff --git a/hotel_calendar/models/__init__.py b/hotel_calendar/models/__init__.py index 2fab6a2c2..714a80ba9 100644 --- a/hotel_calendar/models/__init__.py +++ b/hotel_calendar/models/__init__.py @@ -8,7 +8,6 @@ from . import inherited_hotel_reservation from . import inherited_res_company from . import inherited_res_users from . import inherited_hotel_room_type_restriction_item -from . import inherited_product_pricelist from . import inherited_product_pricelist_item from . import inherited_hotel_folio from . import ir_actions_act_window_view diff --git a/hotel_calendar/models/hotel_calendar.py b/hotel_calendar/models/hotel_calendar.py index 072fc3456..68938f2ff 100644 --- a/hotel_calendar/models/hotel_calendar.py +++ b/hotel_calendar/models/hotel_calendar.py @@ -1,8 +1,6 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models, api, _, fields -from odoo.exceptions import ValidationError +from odoo import models, fields, api class HotelCalendar(models.Model): diff --git a/hotel_calendar/models/inherited_hotel_folio.py b/hotel_calendar/models/inherited_hotel_folio.py index 69a5165e5..027379387 100644 --- a/hotel_calendar/models/inherited_hotel_folio.py +++ b/hotel_calendar/models/inherited_hotel_folio.py @@ -6,7 +6,7 @@ from odoo import models, api, _ class HotelFolio(models.Model): _inherit = 'hotel.folio' - # CRUD methods + # ORM overrides @api.multi def write(self, vals): ret = super(HotelFolio, self).write(vals) diff --git a/hotel_calendar/models/inherited_hotel_property.py b/hotel_calendar/models/inherited_hotel_property.py index 1adf6c502..77a5093e7 100644 --- a/hotel_calendar/models/inherited_hotel_property.py +++ b/hotel_calendar/models/inherited_hotel_property.py @@ -6,6 +6,7 @@ from odoo import models, fields class HotelProperty(models.Model): _inherit = 'hotel.property' + # Fields declaration pms_show_num_rooms = fields.Integer('Number of rooms to show', default=0) pms_divide_rooms_by_capacity = fields.Boolean('Divide rooms by capacity', diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index ed3416e23..4f131f2da 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -18,7 +18,7 @@ class HotelReservation(models.Model): reserve_color_text = fields.Char(compute='_compute_color', string='Color', store=True) - # Business methods + # TODO: Add the following method into _compute_color @api.multi def _generate_color(self): self.ensure_one() @@ -58,6 +58,7 @@ class HotelReservation(models.Model): reserv_color_text = company_id.color_letter_payment_pending return reserv_color, reserv_color_text + # Constraints and onchanges @api.depends('state', 'reservation_type', 'folio_id.pending_amount', 'to_assign') def _compute_color(self): for record in self: @@ -67,24 +68,30 @@ class HotelReservation(models.Model): 'reserve_color_text': colors[1], }) + # ORM overrides @api.model - def get_hcalendar_settings(self): - type_move = self.env.user.hotel_id.pms_type_move - return { - 'divide_rooms_by_capacity': self.env.user.hotel_id.pms_divide_rooms_by_capacity, - 'eday_week': self.env.user.hotel_id.pms_end_day_week, - 'eday_week_offset': self.env.user.hotel_id.pms_end_day_week_offset, - 'days': self.env.user.hotel_id.pms_default_num_days, - 'allow_invalid_actions': type_move == 'allow_invalid', - 'assisted_movement': type_move == 'assisted', - 'default_arrival_hour': self.env.user.hotel_id.default_arrival_hour, - 'default_departure_hour': self.env.user.hotel_id.default_departure_hour, - 'show_notifications': self.env.user.pms_show_notifications, - 'show_pricelist': self.env.user.pms_show_pricelist, - 'show_availability': self.env.user.pms_show_availability, - 'show_num_rooms': self.env.user.hotel_id.pms_show_num_rooms, - } + def create(self, vals): + reservation_id = super(HotelReservation, self).create(vals) + reservation_id.send_bus_notification('create', + 'notify', + _("Reservation Created")) + return reservation_id + @api.multi + def write(self, vals): + _logger.info("RESERV WRITE") + ret = super(HotelReservation, self).write(vals) + self.send_bus_notification('write', 'noshow') + return ret + + @api.multi + def unlink(self): + self.send_bus_notification('unlink', + 'warn', + _("Reservation Deleted")) + return super(HotelReservation, self).unlink() + + # Business methods @api.model def _hcalendar_room_data(self, rooms): _logger.warning('_found [%s] rooms for hotel [%s]', len(rooms), self.env.user.hotel_id.id) @@ -404,6 +411,24 @@ class HotelReservation(models.Model): } return vals + @api.model + def get_hcalendar_settings(self): + type_move = self.env.user.hotel_id.pms_type_move + return { + 'divide_rooms_by_capacity': self.env.user.hotel_id.pms_divide_rooms_by_capacity, + 'eday_week': self.env.user.hotel_id.pms_end_day_week, + 'eday_week_offset': self.env.user.hotel_id.pms_end_day_week_offset, + 'days': self.env.user.hotel_id.pms_default_num_days, + 'allow_invalid_actions': type_move == 'allow_invalid', + 'assisted_movement': type_move == 'assisted', + 'default_arrival_hour': self.env.user.hotel_id.default_arrival_hour, + 'default_departure_hour': self.env.user.hotel_id.default_departure_hour, + 'show_notifications': self.env.user.pms_show_notifications, + 'show_pricelist': self.env.user.pms_show_pricelist, + 'show_availability': self.env.user.pms_show_availability, + 'show_num_rooms': self.env.user.hotel_id.pms_show_num_rooms, + } + @api.multi def generate_bus_values(self, naction, ntype, ntitle=''): self.ensure_one() @@ -494,26 +519,3 @@ class HotelReservation(models.Model): }) return True - - # CRUD methods - @api.model - def create(self, vals): - reservation_id = super(HotelReservation, self).create(vals) - reservation_id.send_bus_notification('create', - 'notify', - _("Reservation Created")) - return reservation_id - - @api.multi - def write(self, vals): - _logger.info("RESERV WRITE") - ret = super(HotelReservation, self).write(vals) - self.send_bus_notification('write', 'noshow') - return ret - - @api.multi - def unlink(self): - self.send_bus_notification('unlink', - 'warn', - _("Reservation Deleted")) - return super(HotelReservation, self).unlink() diff --git a/hotel_calendar/models/inherited_hotel_room.py b/hotel_calendar/models/inherited_hotel_room.py deleted file mode 100644 index 2a85c788a..000000000 --- a/hotel_calendar/models/inherited_hotel_room.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2018 Alexandre Díaz -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields - - -class HotelRoom(models.Model): - _inherit = 'hotel.room' - - # hcal_sequence = fields.Integer('Calendar Sequence', default=0) diff --git a/hotel_calendar/models/inherited_hotel_room_type.py b/hotel_calendar/models/inherited_hotel_room_type.py deleted file mode 100644 index afd768d70..000000000 --- a/hotel_calendar/models/inherited_hotel_room_type.py +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright 2018 Alexandre Díaz -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields - - -class HotelRoomType(models.Model): - _inherit = 'hotel.room.type' - - # hcal_sequence = fields.Integer('Calendar Sequence', default=0) diff --git a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py index fa3afa6b2..d8f4e6e60 100644 --- a/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py +++ b/hotel_calendar/models/inherited_hotel_room_type_restriction_item.py @@ -1,18 +1,17 @@ # Copyright 2018 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import logging -from odoo import models, fields, api +from odoo import models, api _logger = logging.getLogger(__name__) -class HotelRoomTypeResrtrictionItem(models.Model): +class HotelRoomTypeRestrictionItem(models.Model): _inherit = 'hotel.room.type.restriction.item' - # CRUD methods + # ORM overrides @api.model def create(self, vals): - res = super(HotelRoomTypeResrtrictionItem, self).create(vals) - # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id + res = super(HotelRoomTypeRestrictionItem, self).create(vals) if res.restriction_id.id == self.env.user.hotel_id.default_restriction_id.id: self.env['bus.hotel.calendar'].send_restriction_notification({ 'restriction_id': res.restriction_id.id, @@ -31,7 +30,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): @api.multi def write(self, vals): - ret_vals = super(HotelRoomTypeResrtrictionItem, self).write(vals) + ret_vals = super(HotelRoomTypeRestrictionItem, self).write(vals) bus_hotel_calendar_obj = self.env['bus.hotel.calendar'] for record in self: bus_hotel_calendar_obj.send_restriction_notification({ @@ -51,7 +50,6 @@ class HotelRoomTypeResrtrictionItem(models.Model): @api.multi def unlink(self): - # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id default_restriction_id = self.env.user.hotel_id.default_restriction_id.id # Construct dictionary with relevant info of removed records unlink_vals = [] @@ -71,7 +69,7 @@ class HotelRoomTypeResrtrictionItem(models.Model): 'room_type_id': record.room_type_id.id, 'id': record.id, }) - res = super(HotelRoomTypeResrtrictionItem, self).unlink() + res = super(HotelRoomTypeRestrictionItem, self).unlink() bus_hotel_calendar_obj = self.env['bus.hotel.calendar'] for uval in unlink_vals: bus_hotel_calendar_obj.send_restriction_notification(uval) diff --git a/hotel_calendar/models/inherited_product_pricelist.py b/hotel_calendar/models/inherited_product_pricelist.py deleted file mode 100644 index 5de869248..000000000 --- a/hotel_calendar/models/inherited_product_pricelist.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2018 Alexandre Díaz -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api - - -class ProductPricelist(models.Model): - _inherit = 'product.pricelist' - - # TODO REVIEW: deprecated ?¿ - - @api.multi - def update_price(self, room_type_id, date, price): - import wdb; wdb.set_trace() - room_type = self.env['hotel.room.type'].browse(room_type_id) - pritem_obj = self.env['product.pricelist.item'] - for record in self: - plitem = pritem_obj.search([ - ('pricelist_id', '=', record.id), - ('product_tmpl_id', '=', room_type.product_id.product_tmpl_id.id), - ('date_start', '=', date), - ('date_end', '=', date), - ('applied_on', '=', '1_product'), - ('compute_price', '=', 'fixed') - ]) - if plitem: - plitem.fixed_price = price - else: - pritem_obj.create({ - 'pricelist_id': record.id, - 'product_tmpl_id': room_type.product_id.product_tmpl_id.id, - 'date_start': date, - 'date_end': date, - 'applied_on': '1_product', - 'compute_price': 'fixed', - 'fixed_price': price - }) diff --git a/hotel_calendar/models/inherited_product_pricelist_item.py b/hotel_calendar/models/inherited_product_pricelist_item.py index f3c93ab1d..ec5721b13 100644 --- a/hotel_calendar/models/inherited_product_pricelist_item.py +++ b/hotel_calendar/models/inherited_product_pricelist_item.py @@ -6,7 +6,7 @@ from odoo import models, api class ProductPricelistItem(models.Model): _inherit = 'product.pricelist.item' - # CRUD methods + # ORM overrides @api.model def create(self, vals): res = super(ProductPricelistItem, self).create(vals) diff --git a/hotel_calendar/models/inherited_res_company.py b/hotel_calendar/models/inherited_res_company.py index 63465f40c..34dcf8068 100644 --- a/hotel_calendar/models/inherited_res_company.py +++ b/hotel_calendar/models/inherited_res_company.py @@ -1,13 +1,12 @@ # 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 +from odoo import models, fields class ResCompany(models.Model): _inherit = 'res.company' - # background reservation colors + # Fields declaration 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') @@ -18,7 +17,6 @@ class ResCompany(models.Model): 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') - # foreground reservation colors 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') diff --git a/hotel_calendar/models/inherited_res_users.py b/hotel_calendar/models/inherited_res_users.py index 11a7fb139..55725cf5b 100644 --- a/hotel_calendar/models/inherited_res_users.py +++ b/hotel_calendar/models/inherited_res_users.py @@ -6,10 +6,12 @@ from odoo import models, fields class ResUsers(models.Model): _inherit = 'res.users' + # Fields declaration 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) + # ORM overrides def __init__(self, pool, cr): """ Override of __init__ to add access rights. Access rights are disabled by default, but allowed on some specific diff --git a/hotel_calendar/models/ir_actions_act_window_view.py b/hotel_calendar/models/ir_actions_act_window_view.py index e72648595..44022e3dc 100644 --- a/hotel_calendar/models/ir_actions_act_window_view.py +++ b/hotel_calendar/models/ir_actions_act_window_view.py @@ -6,4 +6,5 @@ from odoo import models, fields class ActWindowView(models.Model): _inherit = 'ir.actions.act_window.view' + # Fields declaration view_mode = fields.Selection(selection_add=[('pms', "PMS"), ('mpms', 'Management PMS')]) diff --git a/hotel_calendar/models/ir_ui_view.py b/hotel_calendar/models/ir_ui_view.py index d32601531..e878c9d6e 100644 --- a/hotel_calendar/models/ir_ui_view.py +++ b/hotel_calendar/models/ir_ui_view.py @@ -6,4 +6,5 @@ from odoo import models, fields class View(models.Model): _inherit = 'ir.ui.view' + # Fields declaration type = fields.Selection(selection_add=[('pms', "PMS"), ('mpms', 'Management PMS')])