From f035d4ba75a99f9fc9eadbb99089ffe7ee1ac4fb Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 28 Aug 2019 19:35:30 +0200 Subject: [PATCH] [WIP] refactoring hotel settings --- hotel/__init__.py | 1 - hotel/__manifest__.py | 2 - hotel/data/hotel_data.xml | 7 +- hotel/data/hotel_demo.xml | 10 ++- hotel/data/records.xml | 26 ------ hotel/models/__init__.py | 1 - hotel/models/hotel_amenity.py | 2 +- hotel/models/hotel_amenity_type.py | 2 +- hotel/models/hotel_cancelation_rule.py | 1 + hotel/models/hotel_checkin_partner.py | 12 +-- hotel/models/hotel_folio.py | 4 +- hotel/models/hotel_property.py | 31 ++++++- hotel/models/hotel_reservation.py | 21 ++--- hotel/models/hotel_room_type_restriction.py | 18 ++-- .../hotel_room_type_restriction_item.py | 8 +- hotel/models/inherited_product_pricelist.py | 16 +--- hotel/models/res_config.py | 86 ------------------- hotel/views/hotel_folio_views.xml | 3 +- hotel/views/hotel_property_views.xml | 27 +++++- .../hotel_room_type_restriction_views.xml | 2 +- .../inherited_product_pricelist_views.xml | 4 + hotel/views/res_config.xml | 79 ----------------- hotel/wizard/service_on_day.py | 6 +- hotel/wizard/wizard_reservation.py | 9 +- ...inherited_product_pricelist_item_views.xml | 4 - .../models/channel_backend/common.py | 1 + 26 files changed, 108 insertions(+), 275 deletions(-) delete mode 100644 hotel/data/records.xml delete mode 100644 hotel/models/res_config.py delete mode 100644 hotel/views/res_config.xml diff --git a/hotel/__init__.py b/hotel/__init__.py index 9e9ffdbb0..4d2f414c9 100644 --- a/hotel/__init__.py +++ b/hotel/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# Copyright 2018 Tecnotel - Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from . import models from . import wizard diff --git a/hotel/__manifest__.py b/hotel/__manifest__.py index f1e827455..af910c76c 100644 --- a/hotel/__manifest__.py +++ b/hotel/__manifest__.py @@ -28,7 +28,6 @@ 'wizard/massive_changes.xml', 'wizard/split_reservation.xml', 'wizard/service_on_day.xml', - 'views/res_config.xml', 'data/menus.xml', 'views/inherited_account_payment_views.xml', 'views/inherited_account_invoice_views.xml', @@ -62,7 +61,6 @@ 'views/hotel_cancelation_rule_views.xml', 'views/inherited_webclient_templates.xml', 'data/cron_jobs.xml', - 'data/records.xml', 'data/email_template_cancel.xml', 'data/email_template_reserv.xml', 'data/email_template_exit.xml', diff --git a/hotel/data/hotel_data.xml b/hotel/data/hotel_data.xml index 423e93c49..fc3a3d6d8 100644 --- a/hotel/data/hotel_data.xml +++ b/hotel/data/hotel_data.xml @@ -1,11 +1,16 @@ - + + Restriction Plan + + My Hotel + + diff --git a/hotel/data/hotel_demo.xml b/hotel/data/hotel_demo.xml index 1bc63cdff..cd6ce0a75 100644 --- a/hotel/data/hotel_demo.xml +++ b/hotel/data/hotel_demo.xml @@ -5,7 +5,7 @@ - + @@ -364,6 +364,7 @@ })]"/> + - - + out - diff --git a/hotel/data/records.xml b/hotel/data/records.xml deleted file mode 100644 index 87772c922..000000000 --- a/hotel/data/records.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Default Restrictions - - - - - - - - - - - - - diff --git a/hotel/models/__init__.py b/hotel/models/__init__.py index d0664b9a5..480468fc1 100644 --- a/hotel/models/__init__.py +++ b/hotel/models/__init__.py @@ -25,7 +25,6 @@ from . import hotel_room_type_restriction_item from . import hotel_reservation_line from . import hotel_checkin_partner from . import inherited_product_pricelist -from . import res_config from . import inherited_res_partner from . import inherited_mail_compose_message from . import hotel_room_type_class diff --git a/hotel/models/hotel_amenity.py b/hotel/models/hotel_amenity.py index da5a11c0b..9bb5bf47e 100644 --- a/hotel/models/hotel_amenity.py +++ b/hotel/models/hotel_amenity.py @@ -12,6 +12,6 @@ class HotelRoomAmenitie(models.Model): default_code = fields.Char('Internal Reference') room_amenity_type_id = fields.Many2one('hotel.amenity.type', 'Amenity Catagory') - hotel_ids = fields.Many2many('hotel.property', 'Hotels', required=False, ondelete='restrict') + hotel_ids = fields.Many2many('hotel.property', string='Hotels', required=False, ondelete='restrict') #TODO: Constrain coherence hotel_ids with amenity types hotel_ids diff --git a/hotel/models/hotel_amenity_type.py b/hotel/models/hotel_amenity_type.py index 8ad160eeb..04138ceb8 100644 --- a/hotel/models/hotel_amenity_type.py +++ b/hotel/models/hotel_amenity_type.py @@ -13,6 +13,6 @@ class HotelRoomAmenitieType(models.Model): room_amenity_ids = fields.One2many('hotel.amenity', 'room_amenity_type_id', 'Amenities in this category') - hotel_ids = fields.Many2many('hotel.property', 'Hotels', required=False, ondelete='restrict') + hotel_ids = fields.Many2many('hotel.property', string='Hotels', required=False, ondelete='restrict') #TODO: Constrain coherence hotel_ids with amenities hotel_ids diff --git a/hotel/models/hotel_cancelation_rule.py b/hotel/models/hotel_cancelation_rule.py index 4280b766e..eb0d1dd66 100644 --- a/hotel/models/hotel_cancelation_rule.py +++ b/hotel/models/hotel_cancelation_rule.py @@ -4,6 +4,7 @@ from odoo import models, fields +# TODO: refactoring to cancellation.rule class HotelCancelationRule(models.Model): _name = 'hotel.cancelation.rule' _description = 'Cancelation Rules' diff --git a/hotel/models/hotel_checkin_partner.py b/hotel/models/hotel_checkin_partner.py index fef4973d6..d806e810d 100644 --- a/hotel/models/hotel_checkin_partner.py +++ b/hotel/models/hotel_checkin_partner.py @@ -189,14 +189,12 @@ class HotelCheckinPartner(models.Model): def _get_arrival_hour(self): self.ensure_one() - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Datetime.context_timestamp( self.with_context(tz=tz_hotel), datetime.datetime.strptime(fields.Date.today(), DEFAULT_SERVER_DATE_FORMAT)) - default_arrival_hour = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_arrival_hour') + default_arrival_hour = self.env.user.hotel_id.arrival_hour if self.reservation_id.checkin < today.strftime(DEFAULT_SERVER_DATE_FORMAT): return default_arrival_hour now = fields.Datetime.context_timestamp( @@ -208,14 +206,12 @@ class HotelCheckinPartner(models.Model): def _get_departure_hour(self): self.ensure_one() - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Datetime.context_timestamp( self.with_context(tz=tz_hotel), datetime.datetime.strptime(fields.Date.today(), DEFAULT_SERVER_DATE_FORMAT)) - default_departure_hour = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_departure_hour') + default_departure_hour = self.env.user.hotel_id.departure_hour if self.reservation_id.checkout < today.strftime(DEFAULT_SERVER_DATE_FORMAT): return default_departure_hour now = fields.Datetime.context_timestamp( diff --git a/hotel/models/hotel_folio.py b/hotel/models/hotel_folio.py index 99d97d6be..78504a18a 100644 --- a/hotel/models/hotel_folio.py +++ b/hotel/models/hotel_folio.py @@ -462,8 +462,8 @@ class HotelFolio(models.Model): addr = self.partner_id.address_get(['invoice']) 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.partner_id.property_product_pricelist.id or \ + self.env.user.hotel_id.pricelist_id.id values = { 'pricelist_id': pricelist, 'payment_term_id': self.partner_id.property_payment_term_id and self.partner_id.property_payment_term_id.id or False, diff --git a/hotel/models/hotel_property.py b/hotel/models/hotel_property.py index a3531b4fb..c08a3dc55 100644 --- a/hotel/models/hotel_property.py +++ b/hotel/models/hotel_property.py @@ -2,7 +2,9 @@ # Copyright 2019 Dario Lodeiros # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, api, fields +import re +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError class HotelProperty(models.Model): @@ -18,4 +20,29 @@ class HotelProperty(models.Model): string='Accepted Users') room_type_ids = fields.One2many('hotel.room.type', 'hotel_id', 'Room Types') - room_ids = fields.One2many('hotel.room', 'hotel_id', 'Room') + room_ids = fields.One2many('hotel.room', 'hotel_id', 'Rooms') + + # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id + pricelist_id = fields.Many2one('product.pricelist', 'Product Pricelist', + help='The default pricelist used in this hotel.', + required=True) + # TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id + restriction_id = fields.Many2one('hotel.room.type.restriction', 'Restriction Plan', + help='The default restriction plan used in this hotel.', + required=True) + + # TODO: refactoring 'res.config.settings', 'default_arrival_hour' by the current hotel.property.arrival_hour + arrival_hour = fields.Char('Arrival Hour (GMT)', + help="HH:mm Format", default="14:00") + # TODO: refactoring 'res.config.settings', 'default_departure_hour' by the current hotel.property.departure_hour + departure_hour = fields.Char('Departure Hour (GMT)', + help="HH:mm Format", default="12:00") + + # TODO: refactoring 'res.config.settings', 'tz_hotel' by the current hotel.property.tz (inherited in res.partner) + + def _check_hours(self): + r = re.compile('[0-2][0-9]:[0-5][0-9]') + if not r.match(self.arrival_hour): + raise ValidationError(_("Invalid arrival hour (Format: HH:mm)")) + if not r.match(self.departure_hour): + raise ValidationError(_("Invalid departure hour (Format: HH:mm)")) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 69d45844f..5c15ad1a1 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -31,8 +31,7 @@ class HotelReservation(models.Model): if folio and folio.room_lines: return folio.room_lines[0].checkin else: - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Date.context_today(self.with_context(tz=tz_hotel)) return fields.Date.from_string(today).strftime(DEFAULT_SERVER_DATE_FORMAT) @@ -45,16 +44,14 @@ class HotelReservation(models.Model): if folio and folio.room_lines: return folio.room_lines[0].checkout else: - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Date.context_today(self.with_context(tz=tz_hotel)) return (fields.Date.from_string(today) + timedelta(days=1)).strftime( DEFAULT_SERVER_DATE_FORMAT) def _get_default_arrival_hour(self): folio = False - default_arrival_hour = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_arrival_hour') + default_arrival_hour = self.env.user.hotel_id.arrival_hour if 'folio_id' in self._context: folio = self.env['hotel.folio'].search([ ('id', '=', self._context['folio_id']) @@ -66,8 +63,7 @@ class HotelReservation(models.Model): def _get_default_departure_hour(self): folio = False - default_departure_hour = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_departure_hour') + default_departure_hour = self.env.user.hotel_id.departure_hour if 'folio_id' in self._context: folio = self.env['hotel.folio'].search([ ('id', '=', self._context['folio_id']) @@ -226,7 +222,7 @@ class HotelReservation(models.Model): partner_id = fields.Many2one(related='folio_id.partner_id') tour_operator_id = fields.Many2one(related='folio_id.tour_operator_id') - partner_invoice_id = fields.Many2one(related='folio_id.partner_invoice_id') + partner_invoice_id = fields.Many2one(related='folio_id.partner_invoice_id') partner_invoice_vat = fields.Char(related="partner_invoice_id.vat") partner_invoice_name = fields.Char(related="partner_invoice_id.name") partner_invoice_street = fields.Char(related="partner_invoice_id.street") @@ -673,8 +669,8 @@ class HotelReservation(models.Model): def onchange_partner_id(self): addr = self.partner_id.address_get(['invoice']) 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.partner_id.property_product_pricelist.id or \ + self.env.user.hotel_id.pricelist_id.id values = { 'pricelist_id': pricelist, 'partner_invoice_id': addr['invoice'], @@ -896,8 +892,7 @@ class HotelReservation(models.Model): self.ensure_one() pricelist = self.pricelist_id if pricelist and pricelist.cancelation_rule_id: - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Date.context_today(self.with_context( tz=tz_hotel)) days_diff = (fields.Date.from_string(self.real_checkin) - diff --git a/hotel/models/hotel_room_type_restriction.py b/hotel/models/hotel_room_type_restriction.py index f07fabd78..9891c4a80 100644 --- a/hotel/models/hotel_room_type_restriction.py +++ b/hotel/models/hotel_room_type_restriction.py @@ -14,20 +14,18 @@ class HotelRoomTypeRestriction(models.Model): item_ids = fields.One2many('hotel.room.type.restriction.item', 'restriction_id', string='Restriction Items', copy=True) - active = fields.Boolean('Active', - help='If unchecked, it will allow you to hide the \ - restriction plan without removing it.', - default=True) - hotel_id = fields.Many2one('hotel.property', default=_get_default_hotel, - required=True, ondelete='cascade') + active = fields.Boolean('Active', default=True, + 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', + default=_get_default_hotel, required=True) @api.multi @api.depends('name') def name_get(self): - 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 names = [] for record in self: if record.id == restriction_id: diff --git a/hotel/models/hotel_room_type_restriction_item.py b/hotel/models/hotel_room_type_restriction_item.py index 7783d0cfd..f99add79a 100644 --- a/hotel/models/hotel_room_type_restriction_item.py +++ b/hotel/models/hotel_room_type_restriction_item.py @@ -21,8 +21,10 @@ class HotelRoomTypeRestrictionItem(models.Model): closed = fields.Boolean('Closed') closed_departure = fields.Boolean('Closed Departure') closed_arrival = fields.Boolean('Closed Arrival') - hotel_id = fields.Many2one('hotel.property', store=True, readonly=True, - related='restriction_id.hotel_id') + hotel_ids = fields.One2many('hotel.property', + 'restriction_id', string='Restriction Plan', + store=True, readonly=True, + related='restriction_id.hotel_ids') _sql_constraints = [('room_type_registry_unique', 'unique(restriction_id, room_type_id, date)', @@ -37,7 +39,7 @@ class HotelRoomTypeRestrictionItem(models.Model): raise ValidationError(_("Min. Stay can't be less than zero")) elif record.min_stay_arrival < 0: raise ValidationError( - ("Min. Stay Arrival can't be less than zero")) + _("Min. Stay Arrival can't be less than zero")) elif record.max_stay < 0: raise ValidationError(_("Max. Stay can't be less than zero")) elif record.max_stay_arrival < 0: diff --git a/hotel/models/inherited_product_pricelist.py b/hotel/models/inherited_product_pricelist.py index ac2e7d6a6..1c4028c94 100644 --- a/hotel/models/inherited_product_pricelist.py +++ b/hotel/models/inherited_product_pricelist.py @@ -14,21 +14,7 @@ class ProductPricelist(models.Model): cancelation_rule_id = fields.Many2one( 'hotel.cancelation.rule', string="Cancelation Policy") + hotel_ids = fields.Many2many('hotel.property', string='Hotels', required=False, ondelete='restrict') - @api.multi - @api.depends('name') - def name_get(self): - pricelist_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_pricelist_id') - if pricelist_id: - pricelist_id = int(pricelist_id) - org_names = super(ProductPricelist, self).name_get() - names = [] - for name in org_names: - if name[0] == pricelist_id: - names.append((name[0], '%s (Default)' % name[1])) - else: - names.append((name[0], name[1])) - return names diff --git a/hotel/models/res_config.py b/hotel/models/res_config.py deleted file mode 100644 index c2541f639..000000000 --- a/hotel/models/res_config.py +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2017-2018 Alexandre Díaz -# Copyright 2017 Dario Lodeiros -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import re -import pytz -from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError - - -@api.model -def _tz_get(self): - # put POSIX 'Etc/*' entries at the end to avoid confusing users - # see bug 1086728 - return [(tz, tz) for tz in sorted(pytz.all_timezones, - key=lambda tz: tz - if not tz.startswith('Etc/') else '_')] - - -class HotelConfiguration(models.TransientModel): - _inherit = 'res.config.settings' - - default_pricelist_id = fields.Many2one('product.pricelist', - 'Product Pricelist') - default_restriction_id = fields.Many2one('hotel.room.type.restriction', - 'Restrictions') - default_arrival_hour = fields.Char('Default Arrival Hour (GMT)', - help="HH:mm Format", default="14:00") - default_departure_hour = fields.Char('Default Departure Hour (GMT)', - help="HH:mm Format", default="12:00") - tz_hotel = fields.Selection(_tz_get, string='Timezone', - default=lambda self: self._context.get('tz'), - help="The hotel's timezone, used to manage \ - date and time values in reservations \ - It is important to set a value for this \ - field.") - - @api.multi - def set_values(self): - super(HotelConfiguration, self).set_values() - - self.env['ir.default'].sudo().set( - 'res.config.settings', 'default_pricelist_id', - self.default_pricelist_id.id) - self.env['ir.default'].sudo().set( - 'res.config.settings', 'default_restriction_id', - self.default_restriction_id.id) - self.env['ir.default'].sudo().set( - 'res.config.settings', 'tz_hotel', self.tz_hotel) - self.env['ir.default'].sudo().set( - 'res.config.settings', 'default_arrival_hour', - self.default_arrival_hour) - self.env['ir.default'].sudo().set( - 'res.config.settings', 'default_departure_hour', - self.default_departure_hour) - - @api.model - def get_values(self): - res = super(HotelConfiguration, self).get_values() - - # ONLY FOR v11. DO NOT FORWARD-PORT - default_pricelist_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_pricelist_id') - default_restriction_id = self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_restriction_id') - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') - 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') - res.update( - default_pricelist_id=default_pricelist_id, - default_restriction_id=default_restriction_id, - tz_hotel=tz_hotel, - default_arrival_hour=default_arrival_hour, - default_departure_hour=default_departure_hour, - ) - return res - - @api.constrains('default_arrival_hour', 'default_departure_hour') - def _check_hours(self): - r = re.compile('[0-2][0-9]:[0-5][0-9]') - if not r.match(self.default_arrival_hour): - raise ValidationError(_("Invalid arrival hour (Format: HH:mm)")) - if not r.match(self.default_departure_hour): - raise ValidationError(_("Invalid departure hour (Format: HH:mm)")) diff --git a/hotel/views/hotel_folio_views.xml b/hotel/views/hotel_folio_views.xml index 0b8e0f0ab..bf0d654ec 100644 --- a/hotel/views/hotel_folio_views.xml +++ b/hotel/views/hotel_folio_views.xml @@ -64,7 +64,6 @@ -

@@ -80,8 +79,8 @@ + - diff --git a/hotel/views/hotel_property_views.xml b/hotel/views/hotel_property_views.xml index 6190f144d..d94061446 100644 --- a/hotel/views/hotel_property_views.xml +++ b/hotel/views/hotel_property_views.xml @@ -13,12 +13,29 @@

+ - + + + + + - + + + + + + + + + + + + + @@ -41,10 +58,14 @@ - Hotel Property + Hotels hotel.property form tree,form + + + + diff --git a/hotel/views/hotel_room_type_restriction_views.xml b/hotel/views/hotel_room_type_restriction_views.xml index 9db4771fd..5e2df2a3f 100644 --- a/hotel/views/hotel_room_type_restriction_views.xml +++ b/hotel/views/hotel_room_type_restriction_views.xml @@ -22,7 +22,7 @@

- +
diff --git a/hotel/views/inherited_product_pricelist_views.xml b/hotel/views/inherited_product_pricelist_views.xml index d62051239..50fe7f044 100644 --- a/hotel/views/inherited_product_pricelist_views.xml +++ b/hotel/views/inherited_product_pricelist_views.xml @@ -16,4 +16,8 @@ + + diff --git a/hotel/views/res_config.xml b/hotel/views/res_config.xml deleted file mode 100644 index 14892aab2..000000000 --- a/hotel/views/res_config.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - res.config.settings.view.form.inherit.hotel - res.config.settings - - - - -
-

Hotel Default

-
-
-
-
-
-
-

Hotel Default Hours

-
-
-
-
-
-
-
-
-
-
-
-
- -
diff --git a/hotel/wizard/service_on_day.py b/hotel/wizard/service_on_day.py index c6c269804..d50cedda4 100644 --- a/hotel/wizard/service_on_day.py +++ b/hotel/wizard/service_on_day.py @@ -1,6 +1,6 @@ # Copyright 2017 Darío Lodeiros # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api +from odoo import models, fields, api from odoo.tools import ( DEFAULT_SERVER_DATE_FORMAT) @@ -9,12 +9,10 @@ class ServiceOnDay(models.TransientModel): _name = 'service.on.day' def _get_default_date(self): - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Date.context_today(self.with_context(tz=tz_hotel)) return fields.Date.from_string(today).strftime(DEFAULT_SERVER_DATE_FORMAT) - product_id = fields.Many2one('product.product', 'Service', required=True, domain=[('per_day', '=', True)]) product_qty = fields.Integer('Quantity', default=1) diff --git a/hotel/wizard/wizard_reservation.py b/hotel/wizard/wizard_reservation.py index 084e76bfd..a251d808e 100644 --- a/hotel/wizard/wizard_reservation.py +++ b/hotel/wizard/wizard_reservation.py @@ -51,8 +51,7 @@ class FolioWizard(models.TransientModel): @api.model def _get_default_pricelist(self): - return self.env['ir.default'].sudo().get( - 'res.config.settings', 'default_pricelist_id') + return self.env.user.hotel_id.pricelist_id.id partner_id = fields.Many2one('res.partner', required=True, string="Customer") email = fields.Char('E-mail') @@ -107,8 +106,7 @@ class FolioWizard(models.TransientModel): vals = {} 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.env.user.hotel_id.pricelist_id.id vals.update({ 'pricelist_id': pricelist, 'email': self.partner_id.email, @@ -171,8 +169,7 @@ class FolioWizard(models.TransientModel): @param self: object pointer ''' self.ensure_one() - tz_hotel = self.env['ir.default'].sudo().get( - 'res.config.settings', 'tz_hotel') + tz_hotel = self.env.user.hotel_id.tz today = fields.Date.context_today(self.with_context(tz=tz_hotel)) checkin_dt = fields.Date.from_string(today) if not self.checkin else fields.Date.from_string(self.checkin) checkout_dt = fields.Date.from_string(today) if not self.checkout else fields.Date.from_string(self.checkout) diff --git a/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml index ad97582b0..9f93bdc2b 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_item_views.xml @@ -22,8 +22,4 @@ - - diff --git a/hotel_channel_connector_wubook/models/channel_backend/common.py b/hotel_channel_connector_wubook/models/channel_backend/common.py index db7f59134..5b11e8c77 100644 --- a/hotel_channel_connector_wubook/models/channel_backend/common.py +++ b/hotel_channel_connector_wubook/models/channel_backend/common.py @@ -23,6 +23,7 @@ class ChannelBackend(models.Model): return 'https://wired.wubook.net/xrws/' def _get_default_wubook_parity(self): + # TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id return self.env['ir.default'].sudo().get('res.config.settings', 'default_pricelist_id') lcode = fields.Char('Channel Service lcode')