From 647add666c86402fc4930603107136d19004ca3f Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 11 Feb 2019 17:31:07 +0100 Subject: [PATCH 01/49] [FIX] notify calendar with channel connector information --- .../models/inherited_bus_hotel_calendar.py | 21 +++++++++++++++++++ .../models/inherited_hotel_reservation.py | 15 +++++++++++++ 2 files changed, 36 insertions(+) diff --git a/hotel_calendar_channel_connector/models/inherited_bus_hotel_calendar.py b/hotel_calendar_channel_connector/models/inherited_bus_hotel_calendar.py index dce4784a5..3f17225ec 100644 --- a/hotel_calendar_channel_connector/models/inherited_bus_hotel_calendar.py +++ b/hotel_calendar_channel_connector/models/inherited_bus_hotel_calendar.py @@ -1,14 +1,35 @@ # Copyright 2018-2019 Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +import logging from datetime import datetime from odoo.tools import DEFAULT_SERVER_DATE_FORMAT from odoo import models, api from odoo.addons.hotel_calendar.controllers.bus import HOTEL_BUS_CHANNEL_ID +_logger = logging.getLogger(__name__) class BusHotelCalendar(models.TransientModel): _inherit = 'bus.hotel.calendar' + @api.model + def _generate_reservation_notif(self, vals): + notif = super(BusHotelCalendar, self)._generate_reservation_notif(vals) + reserv = self.env['hotel.reservation'].browse(vals['reserv_id']) + if any(reserv.channel_bind_ids): + notif['tooltip'].update({ + 'ota_name': reserv.channel_bind_ids[0].ota_id.name, + 'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id, + 'external_id': reserv.channel_bind_ids[0].external_id, + }) + elif reserv.splitted and reserv.parent_reservation.channel_bind_ids: + # chunks in splitted reservation has not channel_bind_ids + notif['tooltip'].update({ + 'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name, + 'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id, + 'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id, + }) + return notif + @api.model def _generate_availability_notification(self, vals): date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT) diff --git a/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py b/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py index 9ded708a7..c3ce0d635 100644 --- a/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py +++ b/hotel_calendar_channel_connector/models/inherited_hotel_reservation.py @@ -25,14 +25,29 @@ class HotelReservation(models.Model): 'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id, 'external_id': reserv.channel_bind_ids[0].external_id, }) + elif reserv.splitted and reserv.parent_reservation.channel_bind_ids: + # chunks in splitted reservation has not channel_bind_ids + vals[1][reserv.id].update({ + 'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name, + 'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id, + 'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id, + }) + # REVIEW: What happens if the reservation is splitted and no parent with channel_bind_ids ¿? return vals @api.multi def generate_bus_values(self, naction, ntype, ntitle=''): + self.ensure_one() vals = super(HotelReservation, self).generate_bus_values(naction, ntype, ntitle) vals.update({ 'fix_days': self.splitted or self.is_from_ota, }) + if any(self.channel_bind_ids): + vals.update({ + 'ota_name': self.channel_bind_ids[0].ota_id.name, + 'ota_reservation_id': self.channel_bind_ids[0].ota_reservation_id, + 'external_id': self.channel_bind_ids[0].external_id, + }) return vals @api.multi From a6c6bcd795e852ef19ec0cec9942b15a4938073f Mon Sep 17 00:00:00 2001 From: Pablo Date: Mon, 11 Feb 2019 17:56:33 +0100 Subject: [PATCH 02/49] [UPD] Minor cleanup --- hotel_calendar/models/inherited_hotel_folio.py | 2 +- .../static/src/xml/hotel_calendar_templates.xml | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hotel_calendar/models/inherited_hotel_folio.py b/hotel_calendar/models/inherited_hotel_folio.py index c42a055a4..e5aee878b 100644 --- a/hotel_calendar/models/inherited_hotel_folio.py +++ b/hotel_calendar/models/inherited_hotel_folio.py @@ -21,7 +21,7 @@ class HotelFolio(models.Model): for record in self: record.room_lines.send_bus_notification('unlink', 'warn', - _("Reservation Deleted")) + _("Folio Deleted")) return super(HotelFolio, self).unlink() @api.multi diff --git a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml index 203e4b3aa..88c0bf928 100644 --- a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml +++ b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml @@ -123,7 +123,14 @@

- + + + € + + + + +

Adults:

Children:

@@ -223,7 +230,7 @@ -

This reservation is part of splitted reservation.

+

This reservation is part of splitted reservation.

From 759da2c97892b085c1c194294b2e2e9d013bec20 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sun, 3 Feb 2019 11:24:25 +0100 Subject: [PATCH 03/49] [FIX] inhetired wubook views --- .../views/inherited_hotel_reservation_views.xml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml index de7500e14..051eb5c8b 100644 --- a/hotel_channel_connector/views/inherited_hotel_reservation_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_reservation_views.xml @@ -13,7 +13,6 @@ - - @@ -33,13 +31,11 @@ - {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} - {'readonly': [('is_from_ota','=',True),('able_to_modify_channel','=',False)]} @@ -66,6 +62,15 @@ + + + + + {'readonly': [('is_from_ota', '!=', False)]} + + + {'readonly': [('is_from_ota', '!=', False)]} + From 3981c050af6cff38b9eed4ab89fc8b8d7bd432ce Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 12 Feb 2019 10:46:50 +0100 Subject: [PATCH 04/49] [WIP] Launch wixard deduplicated on write partner --- hotel/models/inherited_res_partner.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hotel/models/inherited_res_partner.py b/hotel/models/inherited_res_partner.py index 39b4080c9..eaebd2b1d 100644 --- a/hotel/models/inherited_res_partner.py +++ b/hotel/models/inherited_res_partner.py @@ -60,10 +60,10 @@ class ResPartner(models.Model): @api.multi def write(self, vals): + res = super(ResPartner, self).write(vals) for i, record in enumerate(self): if record.unconfirmed is True: - partner_dst = self.env['res.partner']._check_duplicated_partner(record) - res = super(ResPartner, self).write(vals) + res = self.env['res.partner']._check_duplicated_partner(record) return res @api.model @@ -117,7 +117,16 @@ class ResPartner(models.Model): duplicated_ids = self.env['res.partner']._get_duplicated_ids(partner) if len(duplicated_ids) > 1: partners = self.env['res.partner'].browse(duplicated_ids) - return partner._merge(partners._ids) + action = self.env.ref('crm.action_partner_deduplicate').read()[0] + if partners: + action['context'] = { + 'default_partner_ids': partners.ids, + 'default_dst_partner_id': partner.id, + } + else: + action = {'type': 'ir.actions.act_window_close'} + return action + # return partner._merge(partners._ids) return partner def _merge_fields(self): From 16f709491e8268f679ebc2a2b1c9d897ae82baea Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Tue, 12 Feb 2019 11:59:19 +0100 Subject: [PATCH 05/49] [FIX] Update security for Model that no longer exists. --- hotel/security/ir.model.access.csv | 1 - 1 file changed, 1 deletion(-) diff --git a/hotel/security/ir.model.access.csv b/hotel/security/ir.model.access.csv index 3d41900d3..44ba7c23b 100644 --- a/hotel/security/ir.model.access.csv +++ b/hotel/security/ir.model.access.csv @@ -8,7 +8,6 @@ access_hotel_reservation_line,access_hotel_reservation_line,model_hotel_reservat access_room_closure_reason,access_room_closure_reason,model_room_closure_reason,base.group_user,1,0,0,0 access_hotel_service_line,access_hotel_service_line,model_hotel_service_line,base.group_user,1,0,0,0 access_hotel_board_service,access_hotel_board_service,model_hotel_board_service,base.group_user,1,0,0,0 -access_hotel_room_type_availability,access_hotel_room_type_availability,model_hotel_room_type_availability,base.group_user,1,0,0,0 access_hotel_checkin_partner,access_hotel_checkin_partner,model_hotel_checkin_partner,base.group_user,1,0,0,0 access_hotel_room_type_class,access_hotel_room_type_class,model_hotel_room_type_class,base.group_user,1,0,0,0 access_hotel_room,access_hotel_room,model_hotel_room,base.group_user,1,0,0,0 From 3caeaad3790c6f1dec4d1b936a68f4e740b51984 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 12 Feb 2019 20:53:48 +0100 Subject: [PATCH 06/49] [UPD] Minor popover adjustment --- hotel_calendar/static/src/css/view.css | 6 ++++++ hotel_calendar/static/src/xml/hotel_calendar_templates.xml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hotel_calendar/static/src/css/view.css b/hotel_calendar/static/src/css/view.css index 534bb5520..3546bf6bf 100644 --- a/hotel_calendar/static/src/css/view.css +++ b/hotel_calendar/static/src/css/view.css @@ -245,6 +245,9 @@ input#bookings_search { font-size: 1.2em; } +.fa-1_5x { + font-size: 1.5em; +} .fa-2_5x { font-size: 2.5em; } @@ -314,6 +317,9 @@ input#bookings_search { padding-top: 5px; padding-bottom: 5px; } +.pt-9 { + padding-top: 9px; +} .pb-3 { padding-bottom: 3px; } diff --git a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml index 88c0bf928..0d6d10704 100644 --- a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml +++ b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml @@ -128,7 +128,7 @@ - +

Adults:

From ba37dd8d135091b07caba8ab82ecdaf0faebd9be Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 13 Feb 2019 09:19:56 +0100 Subject: [PATCH 07/49] [ADD] Manage board services in WuBook rooms --- .../models/hotel_room_type/common.py | 7 ++++++- .../views/channel_hotel_room_type_views.xml | 4 ++++ .../components/backend_adapter.py | 13 +++++++++++-- .../models/hotel_room_type/common.py | 6 ++++-- .../models/hotel_room_type/exporter.py | 16 +++++++++++++++- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 8c500d877..50e76c605 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -3,6 +3,7 @@ from odoo import api, models, fields, _ from odoo.exceptions import ValidationError +from odoo.addons import decimal_precision as dp from odoo.addons.queue_job.job import job from odoo.addons.component.core import Component from odoo.addons.component_event import skip_if @@ -18,8 +19,12 @@ class ChannelHotelRoomType(models.Model): string='Room Type', required=True, ondelete='cascade') - channel_short_code = fields.Char("Channel Short Code", readonly=True, old_name='wscode') + channel_short_code = fields.Char("Channel Short Code", old_name='wscode') ota_capacity = fields.Integer("OTA's Capacity", default=1, old_name='wcapacity') + min_price = fields.Float('Min. Price', default=5.0, digits=dp.get_precision('Product Price'), + help="Setup the min price to prevent incidents while editing your prices.") + max_price = fields.Float('Max. Price', default=200.0, digits=dp.get_precision('Product Price'), + help="Setup the max price to prevent incidents while editing your prices.") @api.onchange('room_ids') def _get_capacity(self): diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml index 8fdd1cffb..82acb2a32 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -15,6 +15,10 @@ + + + + diff --git a/hotel_channel_connector_wubook/components/backend_adapter.py b/hotel_channel_connector_wubook/components/backend_adapter.py index 4ff5bba63..f822fb2d9 100644 --- a/hotel_channel_connector_wubook/components/backend_adapter.py +++ b/hotel_channel_connector_wubook/components/backend_adapter.py @@ -122,6 +122,8 @@ class WuBookAdapter(AbstractComponent): # === ROOMS def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype): + import wdb; + wdb.set_trace() rcode, results = self._server.new_room( self._session_info[0], self._session_info[1], @@ -140,7 +142,8 @@ class WuBookAdapter(AbstractComponent): }) return results - def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, rtype): + def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, + names, descriptions, boards, min_price, max_price, rtype): rcode, results = self._server.mod_room( self._session_info[0], self._session_info[1], @@ -151,7 +154,13 @@ class WuBookAdapter(AbstractComponent): availability, scode, defboard, - rtype + names, + descriptions, + boards, + min_price, + max_price, + int(rtype), + False, ) if rcode != 0: raise ChannelConnectorError(_("Can't modify room in WuBook"), { diff --git a/hotel_channel_connector_wubook/models/hotel_room_type/common.py b/hotel_channel_connector_wubook/models/hotel_room_type/common.py index 85813bb05..8540d6eb6 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type/common.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type/common.py @@ -16,9 +16,11 @@ class HotelRoomTypeAdapter(Component): def fetch_rooms(self): return super(HotelRoomTypeAdapter, self).fetch_rooms() - def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, rtype): + def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, + names, descriptions, boards, min_price, max_price, rtype): return super(HotelRoomTypeAdapter, self).modify_room( - channel_room_id, name, capacity, price, availability, scode, defboard, rtype) + channel_room_id, name, capacity, price, availability, scode, defboard, + names, descriptions, boards, min_price, max_price, rtype) def delete_room(self, channel_room_id): return super(HotelRoomTypeAdapter, self).delete_room(channel_room_id) diff --git a/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py b/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py index 325e1406e..12328a36a 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py @@ -15,6 +15,14 @@ class HotelRoomTypeExporter(Component): binding.with_context({ 'connector_no_export': True, }).write({'sync_date': fields.Datetime.now()}) + # TODO: do not write if backend_adapter.modify_room through an error + boards = {} + for board in binding.board_service_room_type_ids: + boards.update( + {board.channel_service: { + 'dtype': 2 if board.price_type == 'fixed' else 1, + 'value': board.amount}} + ) return self.backend_adapter.modify_room( binding.external_id, binding.name, @@ -23,7 +31,13 @@ class HotelRoomTypeExporter(Component): binding.total_rooms_count, binding.channel_short_code, 'nb', - binding.class_id and binding.class_id.code_class or False) + {}, + {}, + boards, + binding.min_price, + binding.max_price, + binding.class_id and binding.class_id.code_class or False, + ) except ChannelConnectorError as err: self.create_issue( section='room', From d81ba9ac353006adb108d351cd1a28d5285de00b Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 13 Feb 2019 13:31:19 +0100 Subject: [PATCH 08/49] [ADD][WIP] Manage board services in Reservation from WuBook --- .../models/hotel_reservation/importer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 70f41e01e..bca4c711b 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -141,6 +141,8 @@ class HotelReservationImporter(Component): 'room_type_id': room_type_bind.odoo_id.id, 'splitted': split_booking, 'name': room_type_bind and room_type_bind.name, + 'board_service_room_id': room_type_bind.board_service_room_type_ids.filtered( + lambda r: r.channel_service == book['boards'][room_type_bind.external_id]).id or None, 'channel_bind_ids': [(0, False, binding_vals)], } return vals From 33084de78249a54e613a75a61b1d67852cd0dbf3 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 13 Feb 2019 16:28:22 +0100 Subject: [PATCH 09/49] [ADD] sql constrain for channel board service and room type --- .../models/inherited_hotel_board_service_room_type.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hotel_channel_connector/models/inherited_hotel_board_service_room_type.py b/hotel_channel_connector/models/inherited_hotel_board_service_room_type.py index b9e40b0da..9d6394c6c 100644 --- a/hotel_channel_connector/models/inherited_hotel_board_service_room_type.py +++ b/hotel_channel_connector/models/inherited_hotel_board_service_room_type.py @@ -9,3 +9,8 @@ class HotelBoardServiceRoomType(models.Model): _inherit = 'hotel.board.service.room.type' channel_service = fields.Selection([], string='Channel Board Service') + + _sql_constraints = [ + ('room_type_channel_service_id_uniq', 'unique(hotel_room_type_id, channel_service)', + 'The channel board service must be unique for room type.'), + ] \ No newline at end of file From b7ed6af55973b1eade862677d68abf8570ea7838 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 14 Feb 2019 12:49:42 +0100 Subject: [PATCH 10/49] [ADD] button for channel binding management --- .../models/hotel_room_type/common.py | 22 ++++++++++++++++++ .../views/channel_hotel_room_type_views.xml | 11 ++++++++- .../views/inherited_hotel_room_type_views.xml | 23 +++++++------------ 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type/common.py b/hotel_channel_connector/models/hotel_room_type/common.py index 50e76c605..ff5b3da4f 100644 --- a/hotel_channel_connector/models/hotel_room_type/common.py +++ b/hotel_channel_connector/models/hotel_room_type/common.py @@ -2,6 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, models, fields, _ +from odoo.exceptions import UserError from odoo.exceptions import ValidationError from odoo.addons import decimal_precision as dp from odoo.addons.queue_job.job import job @@ -111,6 +112,27 @@ class HotelRoomType(models.Model): ], limit=1) return restriction + @api.multi + def open_channel_bind_ids(self): + channel_bind_ids = self.mapped('channel_bind_ids') + action = self.env.ref('hotel_channel_connector.channel_hotel_room_type_action').read()[0] + action['views'] = [(self.env.ref('hotel_channel_connector.channel_hotel_room_type_view_form').id, 'form')] + if len(channel_bind_ids) == 1: + action['res_id'] = channel_bind_ids.ids[0] + elif len(channel_bind_ids) > 1: + # WARNING: more than one binding is currently not expected + action['domain'] = [('id', 'in', channel_bind_ids.ids)] + else: + action['target'] = 'new' + return action + + @api.multi + def sync_from_channel(self): + channel_bind_ids = self.mapped('channel_bind_ids') + msg = _("Synchronize room types from the channel manager is not yet implementet.") + raise UserError(msg) + + class BindingHotelRoomTypeListener(Component): _name = 'binding.hotel.room.type.listener' _inherit = 'base.connector.listener' diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml index 82acb2a32..ef5e43c9d 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -8,9 +8,10 @@
- + + @@ -33,4 +34,12 @@ + + Hotel Channel Connector Bindings + channel.hotel.room.type + form + tree,form + form + [] + diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml index ee768dbe5..1721a1731 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml @@ -5,23 +5,16 @@ hotel.room.type - - + + + +
+
diff --git a/hotel/views/hotel_room_type_views.xml b/hotel/views/hotel_room_type_views.xml index ff197ad83..08c0ab097 100644 --- a/hotel/views/hotel_room_type_views.xml +++ b/hotel/views/hotel_room_type_views.xml @@ -26,9 +26,9 @@ - - + + diff --git a/hotel_channel_connector/views/channel_hotel_room_type_views.xml b/hotel_channel_connector/views/channel_hotel_room_type_views.xml index 9ec38e060..3eb8e5f97 100644 --- a/hotel_channel_connector/views/channel_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/channel_hotel_room_type_views.xml @@ -20,6 +20,7 @@ + @@ -29,7 +30,7 @@ channel.hotel.room.type.tree channel.hotel.room.type - + diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml index 6014b5073..2a1e20ca8 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_views.xml @@ -13,7 +13,7 @@ confirm="Synchronizing a room type automatically updates its values in Odoo. Do you want to proceed?"/> - + From 82c4bc3c46c10fa4e18a8c24ee792c88dfc0e411 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 19 Feb 2019 20:12:32 +0100 Subject: [PATCH 33/49] [FIX] 'channel.hotel.reservation' object has no attribute 'action_cancel' --- .../models/hotel_reservation/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index bca4c711b..7868f9c19 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -211,7 +211,7 @@ class HotelReservationImporter(Component): self._generate_partner_vals(book) ) if is_cancellation: - binding.with_context({ + binding.odoo_id.with_context({ 'connector_no_export': True}).action_cancel() elif binding.state == 'cancelled': binding.with_context({ From 6f682074eb3b23ea5357912aaebf66a39f8bb911 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 11:42:46 +0100 Subject: [PATCH 34/49] [FIX] var on service _get_display_price --- hotel/models/hotel_service.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hotel/models/hotel_service.py b/hotel/models/hotel_service.py index e472f3bad..e81aa5396 100644 --- a/hotel/models/hotel_service.py +++ b/hotel/models/hotel_service.py @@ -169,7 +169,7 @@ class HotelService(models.Model): if self.compute_lines_out_vals(vals): reservation = self.env['hotel.reservation'].browse(vals['ser_room_line']) product = self.env['product.product'].browse(vals['product_id']) - + vals.update(self.prepare_service_lines( dfrom=reservation.checkin, days=reservation.nights, @@ -251,7 +251,7 @@ class HotelService(models.Model): return product.with_context(pricelist=origin.pricelist_id.id).price product_context = dict(self.env.context, partner_id=origin.partner_id.id, date=folio.date_order if folio else fields.Date.today(), uom=self.product_id.uom_id.id) final_price, rule_id = origin.pricelist_id.with_context(product_context).get_product_price_rule(self.product_id, self.product_qty or 1.0, origin.partner_id) - base_price, currency_id = self.with_context(product_context)._get_real_price_currency(product, rule_id, self.product_qty, product_id.uom_id, origin.pricelist_id.id) + base_price, currency_id = self.with_context(product_context)._get_real_price_currency(product, rule_id, self.product_qty, self.product_id.uom_id, origin.pricelist_id.id) if currency_id != origin.pricelist_id.currency_id.id: base_price = self.env['res.currency'].browse(currency_id).with_context(product_context).compute(base_price, origin.pricelist_id.currency_id) # negative discounts (= surcharge) are included in the display price @@ -326,11 +326,11 @@ class HotelService(models.Model): if board_room_type.price_type == 'fixed': return self.env['hotel.board.service.room.type.line'].search([ ('hotel_board_service_room_type_id', '=', board_room_type.id), - ('product_id','=',self.product_id.id)]).amount + ('product_id', '=', self.product_id.id)]).amount else: return (reservation.price_total * self.env['hotel.board.service.room.type.line'].search([ ('hotel_board_service_room_type_id', '=', board_room_type.id), - ('product_id','=',self.product_id.id)]).amount) / 100 + ('product_id', '=', self.product_id.id)]).amount) / 100 else: product = self.product_id.with_context( lang=partner.lang, @@ -408,7 +408,7 @@ class HotelService(models.Model): action['res_id'] = self.id action['target'] = 'new' return action - + #~ @api.constrains('product_qty') #~ def constrains_qty_per_day(self): #~ for record in self: From bf3e75c24b8ce3af9049f8fcc999361ff8bd86b4 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 13:23:56 +0100 Subject: [PATCH 35/49] [WIP] report parte viajero --- hotel_l10n_es/report/report_parte_viajero.xml | 10 +++++----- .../inherit_hotel_checkin_partner_views.xml | 4 ++-- hotel_l10n_es/views/report_viajero.xml | 2 +- .../views/report_viajero_document.xml | 20 +++++++++---------- .../wizard/inherit_checkin_wizard.py | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/hotel_l10n_es/report/report_parte_viajero.xml b/hotel_l10n_es/report/report_parte_viajero.xml index 05d42a824..02d2a99d2 100644 --- a/hotel_l10n_es/report/report_parte_viajero.xml +++ b/hotel_l10n_es/report/report_parte_viajero.xml @@ -1,12 +1,12 @@ - - + + diff --git a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml index ab369ca55..5ab2c0fd5 100644 --- a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml +++ b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml @@ -1,6 +1,6 @@ - + hotel.checkin.partner.view.form hotel.checkin.partner @@ -62,5 +62,5 @@ - + diff --git a/hotel_l10n_es/views/report_viajero.xml b/hotel_l10n_es/views/report_viajero.xml index cd1c00917..db46715f8 100644 --- a/hotel_l10n_es/views/report_viajero.xml +++ b/hotel_l10n_es/views/report_viajero.xml @@ -24,7 +24,7 @@ .titulo {font-size:0.93em;} .titulo2 {font-size:1.93em;} - + diff --git a/hotel_l10n_es/views/report_viajero_document.xml b/hotel_l10n_es/views/report_viajero_document.xml index 681ce498a..5d3c71d2d 100644 --- a/hotel_l10n_es/views/report_viajero_document.xml +++ b/hotel_l10n_es/views/report_viajero_document.xml @@ -11,8 +11,8 @@ style="width:100%; max-heigth:50px; margin:0 0 1em 0;"/>

PART OF TRAVELERS ENTRY

Document number: / - ( ) - + ( ) +

Total amount (Reservation Card):

CIF:
@@ -30,21 +30,21 @@ Document number - + Type - + Expedition date - +

@@ -86,7 +86,7 @@ Origin - +
@@ -148,21 +148,21 @@ Document number - + Type - + Expedition date - +
@@ -204,7 +204,7 @@ Origin - +
diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.py b/hotel_l10n_es/wizard/inherit_checkin_wizard.py index 438c04685..f768a92ca 100644 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.py +++ b/hotel_l10n_es/wizard/inherit_checkin_wizard.py @@ -107,7 +107,7 @@ class CheckinWizard(models.TransientModel): @api.multi def pdf_viajero(self, cardex_id): cardex = self.env['cardex'].search([('id', '=', cardex_id)]) - return self.env['report'].get_action(cardex, 'report.viajero') + return self.env['report'].get_action(cardex, 'action.report.viajero') @api.multi def action_save_check(self): From 069db75f3182cc62faed1372c1b645f7f882a19d Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 17:10:49 +0100 Subject: [PATCH 36/49] [WIP] police report --- hotel/models/inherited_res_partner.py | 1 - hotel_l10n_es/models/inherit_hotel_checkin_partner.py | 1 + hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml | 2 ++ hotel_l10n_es/wizard/police_wizard.py | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hotel/models/inherited_res_partner.py b/hotel/models/inherited_res_partner.py index d803e9a74..39b4080c9 100644 --- a/hotel/models/inherited_res_partner.py +++ b/hotel/models/inherited_res_partner.py @@ -63,7 +63,6 @@ class ResPartner(models.Model): for i, record in enumerate(self): if record.unconfirmed is True: partner_dst = self.env['res.partner']._check_duplicated_partner(record) - return res = super(ResPartner, self).write(vals) return res diff --git a/hotel_l10n_es/models/inherit_hotel_checkin_partner.py b/hotel_l10n_es/models/inherit_hotel_checkin_partner.py index 5314d50ee..b14608d89 100644 --- a/hotel_l10n_es/models/inherit_hotel_checkin_partner.py +++ b/hotel_l10n_es/models/inherit_hotel_checkin_partner.py @@ -30,6 +30,7 @@ class HotelCheckinPartner(models.Model): document_number = fields.Char(related='partner_id.document_number') document_expedition_date = fields.Date(related='partner_id.document_expedition_date') gender = fields.Selection('Gender', related='partner_id.gender') + birthdate_date = fields.Date('Birhdate', related='partner_id.birthdate_date') code_ine_id = fields.Many2one(related="partner_id.code_ine_id") #TMP_FIX VAT Validation diff --git a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml index 5ab2c0fd5..dee25f35c 100644 --- a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml +++ b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml @@ -35,6 +35,7 @@ +
@@ -58,6 +59,7 @@ +
diff --git a/hotel_l10n_es/wizard/police_wizard.py b/hotel_l10n_es/wizard/police_wizard.py index a9b9462b4..c31cca439 100644 --- a/hotel_l10n_es/wizard/police_wizard.py +++ b/hotel_l10n_es/wizard/police_wizard.py @@ -41,9 +41,9 @@ class PoliceWizard(models.TransientModel): def generate_file(self): company = self.env.user.company_id if company.police_number is not False and company.property_name is not False: - lines = self.env['cardex'].search([('enter_date', '=', + lines = self.env['hotel.checkin.partner'].search([('enter_date', '=', self.download_date)]) - content = "1|"+company.police_number+"|"+compa.property_name.upper()[0:40] + content = "1|"+company.police_number+"|"+company.property_name.upper()[0:40] content += "|" content += datetime.datetime.now().strftime("%Y%m%d|%H%M") content += "|"+str(len(lines)) + """ From bdddc73f197a9b75152aae1d68b77cab696f74dd Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 18:03:11 +0100 Subject: [PATCH 37/49] [WIP] INE Wizard --- hotel/models/hotel_reservation.py | 2 +- hotel_l10n_es/wizard/ine_wizard.py | 26 ++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 8f4590cb9..dca880991 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -214,9 +214,9 @@ class HotelReservation(models.Model): partner_invoice_country_id = fields.Many2one(related="partner_invoice_id.country_id") partner_invoice_email = fields.Char(related="partner_invoice_id.email") partner_invoice_lang = fields.Selection(related="partner_invoice_id.lang") - closure_reason_id = fields.Many2one(related='folio_id.closure_reason_id') partner_invoice_type = fields.Selection(related="partner_invoice_id.type") partner_invoice_parent_id = fields.Many2one(related="partner_invoice_id.parent_id") + closure_reason_id = fields.Many2one(related='folio_id.closure_reason_id') partner_diff_invoicing = fields.Boolean('Bill to another Address', default='_default_diff_invoicing') company_id = fields.Many2one(related='folio_id.company_id', string='Company', store=True, readonly=True) reservation_line_ids = fields.One2many('hotel.reservation.line', diff --git a/hotel_l10n_es/wizard/ine_wizard.py b/hotel_l10n_es/wizard/ine_wizard.py index fd8009cda..46a1fb29f 100644 --- a/hotel_l10n_es/wizard/ine_wizard.py +++ b/hotel_l10n_es/wizard/ine_wizard.py @@ -28,7 +28,6 @@ import xml.etree.cElementTree as ET from openerp.exceptions import UserError - def get_years(): year_list = [] for i in range(2017, get_year()+1): @@ -120,7 +119,7 @@ class IneWizard(models.TransientModel): [('capacity', '>', 0)]) ET.SubElement(cabezera, "HABITACIONES").text = str(active_room) ET.SubElement(cabezera, "PLAZAS_DISPONIBLES_SIN_SUPLETORIAS" - ).text = str(company.seats) + ).text = str(company.ine_seats) ET.SubElement(cabezera, "URL").text = company.website alojamiento = ET.SubElement(encuesta, "ALOJAMIENTO") # Bucle de RESIDENCIA @@ -140,8 +139,6 @@ class IneWizard(models.TransientModel): code_control = lines[0].partner_id.code_ine_id.code if code_control is False: - _logger.error('Usuario sin codigo de INE: ' + - lines[0].partner_id.name) raise UserError(_('ERROR: Usuario sin codigo de INE: ' + lines[0].partner_id.name)) @@ -232,12 +229,10 @@ class IneWizard(models.TransientModel): ('checkin', '<=', str(m_f_d_search)), ('checkout', '>=', str(m_e_d_search))], order="checkin") for line_res in lines_res: - room = self.env['hotel.room'].search([( - 'product_id', '=', line_res.product_id.id)]) + room = line_res.room_id # No es Staff o Out y esta booking if (line_res.reservation_type == 'normal') and ( - (line_res.state == 'booking') or ( - line_res.state == 'done')): + (line_res.state == 'booking') or (line_res.state == 'done')): # calculamos capacidad de habitacion # !!!!! ATENCION !!!! @@ -250,8 +245,8 @@ class IneWizard(models.TransientModel): capacidad = room.capacity + suple_room # Cuadramos adultos con los checkin realizados. - if line_res.adults > line_res.cardex_count: - adultos = line_res.cardex_count + if line_res.adults > line_res.checkin_partner_count: + adultos = line_res.checkin_partner_count else: adultos = line_res.adults @@ -259,7 +254,6 @@ class IneWizard(models.TransientModel): f_salida = line_res.checkout.split('-') f_entrada[2] = f_entrada[2].split()[0] f_salida[2] = f_salida[2].split()[0] - # Ha entrado este mes if int(f_entrada[1]) == self.ine_month: ine_entrada[int(f_entrada[2])] += 1 @@ -306,7 +300,7 @@ class IneWizard(models.TransientModel): # Otras Habitaciones movimientos[dia_x-1][3] += 1 else: - _logger.info(str(dia_x) + + raise UserError(str(dia_x) + 'Exceso de habitaciones ' + str(line_res) + ' ' + line_res.name + ' ' + line_res.partner_id.name + @@ -355,13 +349,10 @@ class IneWizard(models.TransientModel): "HABITACIONES_MOVIMIENTO") ET.SubElement(habitaciones_m, "HABITACIONES_N_DIA").text = "%02d" % (dia_x) - if ine_pernoct_total[dia_x] > company.seats: + if ine_pernoct_total[dia_x] > company.ine_seats: # Añadimos Supletorias por si excedemos plazas movimientos[dia_x][0] = (ine_pernoct_total[dia_x] - - company.seats) - _logger.info(' Dia: ' + str(dia_x) + - ' [ADD] Supletorias a : ' + - str(movimientos[dia_x][0])) + - company.ine_seats) ET.SubElement(habitaciones_m, "PLAZAS_SUPLETORIAS").text = str( movimientos[dia_x][0]) @@ -448,4 +439,3 @@ class IneWizard(models.TransientModel): return self.write({ 'rev_screen': _('No data in this month') }) - From c236817f6a772327926e587ddf73eeb0c72b1aa0 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 18:10:44 +0100 Subject: [PATCH 38/49] [DEL] l10n_es Wizard checkin --- hotel/__manifest__.py | 1 - hotel/wizard/__init__.py | 1 - hotel/wizard/checkinwizard.py | 221 ------------------ hotel/wizard/checkinwizard.xml | 104 --------- hotel_l10n_es/__manifest__.py | 1 - hotel_l10n_es/wizard/__init__.py | 1 - .../wizard/inherit_checkin_wizard.py | 172 -------------- .../wizard/inherit_checkin_wizard.xml | 37 --- 8 files changed, 538 deletions(-) delete mode 100644 hotel/wizard/checkinwizard.py delete mode 100644 hotel/wizard/checkinwizard.xml delete mode 100644 hotel_l10n_es/wizard/inherit_checkin_wizard.py delete mode 100644 hotel_l10n_es/wizard/inherit_checkin_wizard.xml diff --git a/hotel/__manifest__.py b/hotel/__manifest__.py index ff768ccc2..c5f3201a2 100644 --- a/hotel/__manifest__.py +++ b/hotel/__manifest__.py @@ -29,7 +29,6 @@ 'data/menus.xml', 'views/inherited_account_payment_views.xml', 'views/inherited_account_invoice_views.xml', - 'wizard/checkinwizard.xml', 'wizard/massive_price_reservation_days.xml', 'wizard/folio_make_invoice_advance_views.xml', 'data/hotel_sequence.xml', diff --git a/hotel/wizard/__init__.py b/hotel/wizard/__init__.py index 9fbcd6f9e..2717e90d1 100644 --- a/hotel/wizard/__init__.py +++ b/hotel/wizard/__init__.py @@ -22,7 +22,6 @@ # ############################################################################## from . import folio_make_invoice_advance -from . import checkinwizard from . import massive_changes from . import split_reservation from . import duplicate_reservation diff --git a/hotel/wizard/checkinwizard.py b/hotel/wizard/checkinwizard.py deleted file mode 100644 index 8bb5b669e..000000000 --- a/hotel/wizard/checkinwizard.py +++ /dev/null @@ -1,221 +0,0 @@ -import logging -from openerp import models, fields, api -_logger = logging.getLogger(__name__) - - -class Wizard(models.TransientModel): - _name = 'checkin.wizard' - - def default_enter_date(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin - if 'enter_date' in self.env.context: - return self.env.context['enter_date'] - return False - - def default_exit_date(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkout - if 'exit_date' in self.env.context: - return self.env.context['exit_date'] - return False - - def default_reservation_id(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - if len(reservations) == 1: - # return current room line (onlyone in this case) - return reservations - for res in reservations: - # return the first room line with free space for a checkin - # TODO: add 'done' to res.state condition... Maybe too restrictive right now - if res.checkin_partner_count < (res.adults + res.children) and \ - res.state not in ["cancelled"]: - return res - elif 'reservation_id' in self.env.context: - return self.env['hotel.reservation'].browse( - self.env.context['reservation_id']) - - _logger.info('default_reservation_id is FALSE') - return False - - def default_partner_id(self): - # no partner by default. User must search and choose one - return False - - def default_checkin_partner_ids(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin_partner_ids - - def default_checkin_partner_ids(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.segmentation_id - - ''' TODO: clean-up - def default_count_checkin_partner(self): - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin_partner_count - ''' - ''' TODO: clean-up - def default_pending_checkin_partner(self): - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.adults + res.children - res.checkin_partner_count - ''' - ''' TODO: clean-up - list of checkins on smart button clean is not used anymore - def comp_checkin_list_visible(self): - if 'partner_id' in self.env.context: - self.list_checkin_checkin_partner = False - return - ''' - def comp_checkin_edit(self): - if 'edit_checkin_partner' in self.env.context: - return True - return False - - checkin_partner_ids = fields.Many2many('hotel.checkin.partner', 'reservation_id', - default=default_checkin_partner_ids) - # count_checkin_partner = fields.Integer('Checkin counter', - # default=default_count_checkin_partner) - # pending_checkin_partner = fields.Integer('Checkin pending', - # default=default_pending_checkin_partner) - partner_id = fields.Many2one('res.partner', - default=default_partner_id) - reservation_id = fields.Many2one('hotel.reservation', - default=default_reservation_id) - enter_date = fields.Date(default=default_enter_date, - required=True) - exit_date = fields.Date(default=default_exit_date, - required=True) - - firstname_checkin_partner = fields.Char('Firstname', - required=True) - lastname_checkin_partner = fields.Char('Lastname', - required=True) - - email_checkin_partner = fields.Char('E-mail') - - mobile_checkin_partner = fields.Char('Mobile') - - segmentation_ids = fields.Many2many( - related='reservation_id.segmentation_ids') - - - ''' TODO: clean-up - list of checkins on smart button clean is not used anymore - list_checkin_checkin_partner = fields.Boolean(compute=comp_checkin_list_visible, - default=True, store=True) - ''' - # edit_checkin_checkin_partner = fields.Boolean(default=comp_checkin_edit, - # store=True) - - op_select_partner = fields.Selection([ - ('S', 'Select a partner for checkin'), - ('C', 'Create a new partner for checkin') - ], default='S', string='Partner for checkin') - # checkin mode: - # 0 - no selection made by the user, so hide the client fields - # 1 - select a client for update his values and do the checkin - # 2 - create a new client with the values and do the checkin - checkin_mode = fields.Integer(default=0) - - @api.multi - def action_save_check(self): - # prepare partner values - if self.op_select_partner == 'S': - partner_vals = { - 'id': self.partner_id.id, - 'firstname': self.firstname_checkin_partner, - 'lastname': self.lastname_checkin_partner, - 'email': self.email_checkin_partner, - 'mobile': self.mobile_checkin_partner, - } - self.partner_id.sudo().write(partner_vals) - elif self.op_select_partner == 'C': - partner_vals = { - 'firstname': self.firstname_checkin_partner, - 'lastname': self.lastname_checkin_partner, - 'email': self.email_checkin_partner, - 'mobile': self.mobile_checkin_partner, - } - new_partner = self.env['res.partner'].create(partner_vals) - self.partner_id = self.env['res.partner'].browse(new_partner.id) - - # prepare checkin values - checkin_partner_val = { - 'partner_id': self.partner_id.id, - 'enter_date': self.enter_date, - 'exit_date': self.exit_date - } - record_id = self.env['hotel.reservation'].browse( - self.reservation_id.id) - # save the checkin for this reservation - record_id.write({ - 'checkin_partner_ids': [(0, False, checkin_partner_val)], - 'segmentation_id': self.segmentation_id, - }) - - # update the state of the current reservation - if record_id.checkin_partner_count > 0: - record_id.state = 'booking' - - @api.onchange('reservation_id') - def change_enter_exit_date(self): - record_id = self.env['hotel.reservation'].browse( - self.reservation_id.id) - - self.enter_date = record_id.checkin - self.exit_date = record_id.checkout - - ''' trying to filter the reservations only to pending checkins ... - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - _logger.info('reservation checkin_partner_count %d', res.checkin_partner_count) - - # return { - # 'domain': {'reservation_id': [('folio_id','=', self.env.context['folio']), 'count_checkin_partner','=','2']}, - # 'warning': {'title': "Warning", 'message': self.env.context['checkin_partner_count']}, - # } - ''' - - @api.onchange('partner_id') - def onchange_partner_id(self): - # update partner fields - write_vals = { - 'firstname_checkin_partner': self.partner_id.firstname, - 'lastname_checkin_partner': self.partner_id.lastname, - 'email_checkin_partner': self.partner_id.email, - 'mobile_checkin_partner': self.partner_id.mobile, - } - # show the checkin fields if a partner is selected - if self.op_select_partner == 'S' and self.partner_id.id != False: - write_vals.update({'checkin_mode': 1}) - self.update(write_vals) - - @api.onchange('op_select_partner') - def onchange_op_select_partner(self): - # field one2many return false is record does not exist - if self.op_select_partner == 'S' and self.partner_id.id: - self.checkin_mode = 1 - # field one2many return 0 on empty record (nothing typed) - elif self.op_select_partner == 'C' and self.partner_id.id == 0: - self.checkin_mode = 2 diff --git a/hotel/wizard/checkinwizard.xml b/hotel/wizard/checkinwizard.xml deleted file mode 100644 index 6b582c9c9..000000000 --- a/hotel/wizard/checkinwizard.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - wizard.form2 - checkin.wizard - -
- - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
- - - Add Check - checkin.wizard - - new - - - - - - - -
diff --git a/hotel_l10n_es/__manifest__.py b/hotel_l10n_es/__manifest__.py index 39e66b520..34086fe90 100644 --- a/hotel_l10n_es/__manifest__.py +++ b/hotel_l10n_es/__manifest__.py @@ -43,7 +43,6 @@ 'views/report_viajero.xml', 'wizard/police_wizard.xml', 'wizard/ine_wizard.xml', - 'wizard/inherit_checkin_wizard.xml', 'views/category_tourism.xml', 'views/code_ine.xml', 'views/inherit_res_company.xml', diff --git a/hotel_l10n_es/wizard/__init__.py b/hotel_l10n_es/wizard/__init__.py index 0bd21cdd8..9da10d1bc 100644 --- a/hotel_l10n_es/wizard/__init__.py +++ b/hotel_l10n_es/wizard/__init__.py @@ -21,5 +21,4 @@ ############################################################################## from . import police_wizard -from . import inherit_checkin_wizard from . import ine_wizard diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.py b/hotel_l10n_es/wizard/inherit_checkin_wizard.py deleted file mode 100644 index f768a92ca..000000000 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.py +++ /dev/null @@ -1,172 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2018 Alda Hotels -# Jose Luis Algara -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp import models, fields, api -from openerp.exceptions import UserError -from openerp.tools.translate import _ -from datetime import datetime, timedelta - -class CheckinWizard(models.TransientModel): - _inherit = 'checkin.wizard' - - def validation_under_age(self): - if self.birthdate_date_cardex != False: - years = str(datetime.now().date() - timedelta(days=365*16+4)) - limit_date = datetime.strptime(years, "%Y-%m-%d") - birth_date = datetime.strptime(self.birthdate_date_cardex, '%Y-%m-%d') - limit = str(limit_date.day)+ ' de ' + str(limit_date.month)+ ' de ' + str(limit_date.year) - if limit_date < birth_date: - return {'warning': {'title': _('Error in Birthdate'), 'message': _('Does the client have less than 16 years?. Data collection is not performed for those born before %s.' % (limit)),},} - if self.polexpedition_cardex != False: - if self.birthdate_date_cardex > self.polexpedition_cardex: - raise ValidationError(_('Date of document shipment, prior to birth date')) - - @api.onchange('polexpedition_cardex') - def validation_polexpedition(self): - if self.birthdate_date_cardex != False and self.polexpedition_cardex != False: - if self.birthdate_date_cardex > self.polexpedition_cardex: - return {'warning': {'title': _('Error in Birthdate or Expedition date'), 'message': _('Date of document shipment, prior to birth date'),},} - - # Validation for DNI/Permiso conducir erroneo - @api.onchange('poldocument_cardex', 'documenttype_cardex') - def validation_poldocument_dni(self): - if self.poldocument_cardex != False: - if self.documenttype_cardex in ['D','C']: - validcaracter = "TRWAGMYFPDXBNJZSQVHLCKE" - dig_ext = "XYZ" - reemp_dig_ext = {'X':'0', 'Y':'1', 'Z':'2'} - numeros = "1234567890" - dni = self.poldocument_cardex.upper() - if len(dni) == 9: - dig_control = dni[8] - dni = dni[:8] - # 'extranjero empieza por XYZ' - if dni[0] in dig_ext: - dni = dni.replace(dni[0], reemp_dig_ext[dni[0]]) - if not ((len(dni) == len([n for n in dni if n in numeros])) and (validcaracter[int(dni)%23] == dig_control)): - return {'warning': {'title': _('Error in DNI/NIE/DRIVE LICENSE'), 'message': _('Wrong DNI/NIE/DRIVE LICENSE, check it.'),},} - else: - return {'warning': {'title': _('Error in DNI/NIE/DRIVE LICENSE'), 'message': _('DNI/NIE/DRIVE LICENSE erroneous length, the correct format is: (12345678A or X1234567A)'),},} - - # Validation for Tipo de documento no valido para Extranjero - # @api.onchange('x') - # Pendiente - - # Validation for Nacionalidad erronea - # @api.onchange('x') - # Pendiente - - # NOTE: All the fields are required but they are set required=True in the .xml - # The reason is found in the bt_select_partner and bt_create_partner buttons to bypass the ORM null constraint - # when the buttons are clicked to show the hidden fields - - documenttype_cardex = fields.Selection([ - ('D', 'DNI'), - ('P', 'Pasaporte'), - ('C', 'Permiso de Conducir'), - ('I', 'Carta o Doc. de Identidad'), - ('N', 'Permiso Residencia Español'), - ('X', 'Permiso Residencia Europeo')], - help='Select a valid document type', - default='D', - string='Doc. type') - - poldocument_cardex = fields.Char('Doc. number') - - polexpedition_cardex = fields.Date('Expedition date') - - gender_cardex = fields.Selection([('male', 'Male'), ('female', 'Female')]) - - birthdate_date_cardex = fields.Date("Birthdate") - - code_ine_cardex = fields.Many2one('code.ine', - help='Country or province of origin. Used for INE statistics.') - - # TODO: Add tags in the cardex not in the partner anb move this field to out of localization - #category_id_cardex = fields.Many2many('res.partner.category', 'id', required=True) - - @api.multi - def pdf_viajero(self, cardex_id): - cardex = self.env['cardex'].search([('id', '=', cardex_id)]) - return self.env['report'].get_action(cardex, 'action.report.viajero') - - @api.multi - def action_save_check(self): - # Check dates - self.validation_under_age() - # take a 'snapshot' of the current cardexes in this reservation - record_id = self.env['hotel.reservation'].browse(self.reservation_id.id) - old_cardex = self.env['cardex'].search([('reservation_id', '=', record_id.id)]) - - # the above lines must be executed before call the super().action_save_check() - - # call the super action_save_check() for checkin - super(Wizard, self).action_save_check() - - # prepare category in partner from category_id - the_list = self.segmentation_id - self.partner_id.category_id - the_list = self.partner_id.category_id + the_list - - # prepare localization partner values - partner_vals = { - 'documenttype': self.documenttype_cardex, - 'poldocument': self.poldocument_cardex, - 'polexpedition': self.polexpedition_cardex, - 'gender': self.gender_cardex, - 'birthdate_date': self.birthdate_date_cardex, - # (4, ID) link to existing record with id = ID (adds a relationship) ... - 'code_ine': self.code_ine_cardex.id, - # (6, 0, [IDs]) replace the list of linked IDs ... - 'category_id': [(6, False, [x.id for x in the_list])], - } - - # Update Accounting VAT number on customer - if self.documenttype_cardex in ('D','C'): - partner_vat = 'ES' + self.poldocument_cardex - partner_vals.update({ - 'vat': partner_vat - }) - - # Are you templed to merge the following write with the super() ? - # Be warned: Premature optimization is the root of all evil -- DonaldKnuth - # This TransientModel inherit from checkin.wizard and it is intended for localization - # So, if you need to write something here must be _after_ the super() - - # update the localization partner values for this reservation - self.partner_id.sudo().write(partner_vals); - - # get the last cardex in this reservation (set difference theory) - cardex = self.env['cardex'].search([('reservation_id', '=', record_id.id)]) - old_cardex - return self.pdf_viajero(cardex.id) - - @api.onchange('partner_id') - def onchange_partner_id(self): - # call the super update_partner_fields - super(Wizard, self).onchange_partner_id() - # update local fields - self.documenttype_cardex = self.partner_id.documenttype; - self.poldocument_cardex = self.partner_id.poldocument; - self.polexpedition_cardex = self.partner_id.polexpedition; - self.gender_cardex = self.partner_id.gender; - self.birthdate_date_cardex = self.partner_id.birthdate_date; - self.code_ine_cardex = self.partner_id.code_ine; - #self.category_id_cardex = self.partner_id.category_id; diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.xml b/hotel_l10n_es/wizard/inherit_checkin_wizard.xml deleted file mode 100644 index ed1e8c69f..000000000 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - wizard.form2 - checkin.wizard - - - - - - - - - - - - - - - - - - - - - -