From d0d0372c6c92d9d9d118a8cac9961c74e6327a29 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Mon, 22 Jul 2019 17:47:45 +0200 Subject: [PATCH 01/33] [FIX] Unifying dates system --- .../models/inherited_hotel_checkin_partner.py | 36 +++++++++---------- .../models/inherited_hotel_reservation.py | 9 ++--- .../models/inherited_hotel_room_type.py | 6 ++-- .../models/inherited_res_partner.py | 23 ++++++++---- hotel_roommatik/models/roommatik.py | 6 ++-- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 2764dea55..6563f987d 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -9,6 +9,7 @@ from odoo.addons.hotel_roommatik.models.roommatik import ( from datetime import datetime import logging + class HotelFolio(models.Model): _inherit = 'hotel.checkin.partner' @@ -19,33 +20,32 @@ class HotelFolio(models.Model): if not stay.get('ReservationCode'): reservation_obj = self.env['hotel.reservation'] vals = { - checkin: datetime.strptime(stay["Arrival"], - DEFAULT_ROOMMATIK_DATE_FORMAT).date(), - checkout: datetime.strptime(stay["Departure"], - DEFAULT_ROOMMATIK_DATE_FORMAT).date(), - adults: stay['Adults'], - room_type_id: stay['RoomType'], - partner_id: stay["Customers"][0]["Id"] + 'checkin': datetime.strptime( + stay["Arrival"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), + 'checkout': datetime.strptime( + stay["Departure"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), + 'adults': stay['Adults'], + 'room_type_id': stay['RoomType'], + 'partner_id': stay["Customers"][0]["Id"] } reservation_rm = reservation_obj.create(vals) else: - reservation_rm = self.env['hotel.reservation'].browse(stay['ReservationCode']) + reservation_rm = self.env['hotel.reservation'].browse( + stay['ReservationCode']) total_chekins = reservation_rm.checkin_partner_pending_count if total_chekins > 0 and len(stay["Customers"]) <= total_chekins: _logger.info('ROOMMATIK checkin %s customer in %s Reservation.', total_chekins, reservation_rm.id) for room_partner in stay["Customers"]: - # ADD costumer ? - # costumer = self.env['res.partner'].rm_add_customer(room_partner["Customer"]) checkin_partner_val = { 'folio_id': reservation_rm.folio_id.id, 'reservation_id': reservation_rm.id, - 'enter_date': datetime.strptime(stay["Arrival"], - "%d%m%Y").date(), - 'exit_date': datetime.strptime(stay["Departure"], - "%d%m%Y").date(), + 'enter_date': datetime.strptime( + stay["Arrival"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), + 'exit_date': datetime.strptime( + stay["Departure"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), 'partner_id': room_partner["Customer"]["Id"], } try: @@ -84,10 +84,10 @@ class HotelFolio(models.Model): default_departure_hour = self.env['ir.default'].sudo().get( 'res.config.settings', 'default_departure_hour') if any(checkin_partner): - arrival = "%s %s" % (checkin_partner.enter_date, - default_arrival_hour) - departure = "%s %s" % (checkin_partner.exit_date, - default_departure_hour) + arrival = "%s %s:00" % (checkin_partner.enter_date.strftime( + DEFAULT_ROOMMATIK_DATE_FORMAT), default_arrival_hour) + departure = "%s %s:00" % (checkin_partner.exit_date.strftime( + DEFAULT_ROOMMATIK_DATE_FORMAT), default_departure_hour) stay = {'Code': checkin_partner.id} stay['Id'] = checkin_partner.id stay['Room'] = {} diff --git a/hotel_roommatik/models/inherited_hotel_reservation.py b/hotel_roommatik/models/inherited_hotel_reservation.py index 067d7402e..6ce38fcfe 100644 --- a/hotel_roommatik/models/inherited_hotel_reservation.py +++ b/hotel_roommatik/models/inherited_hotel_reservation.py @@ -1,16 +1,12 @@ # Copyright 2019 Jose Luis Algara (Alda hotels) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, models, fields -from odoo.addons.hotel_roommatik.models.roommatik import ( - DEFAULT_ROOMMATIK_DATE_FORMAT, - DEFAULT_ROOMMATIK_DATETIME_FORMAT) -from datetime import datetime, timedelta -from dateutil import tz +from odoo import api, models import json import logging _logger = logging.getLogger(__name__) + class HotelReservation(models.Model): _inherit = 'hotel.reservation' @@ -33,7 +29,6 @@ class HotelReservation(models.Model): return deposit return folio.invoices_paid - @api.model def rm_get_reservation(self, code): # Search by localizator diff --git a/hotel_roommatik/models/inherited_hotel_room_type.py b/hotel_roommatik/models/inherited_hotel_room_type.py index cfde69834..ea5de72ac 100644 --- a/hotel_roommatik/models/inherited_hotel_room_type.py +++ b/hotel_roommatik/models/inherited_hotel_room_type.py @@ -5,8 +5,7 @@ from odoo import api, models, fields from datetime import datetime, timedelta import json from odoo.addons.hotel_roommatik.models.roommatik import ( - DEFAULT_ROOMMATIK_DATE_FORMAT, - DEFAULT_ROOMMATIK_DATE_FORMAT) + DEFAULT_ROOMMATIK_DATE_FORMAT,) import logging _logger = logging.getLogger(__name__) @@ -51,7 +50,8 @@ class HotelRoomType(models.Model): return json_response @api.model - def rm_get_prices(self, start_date, number_intervals, room_type, guest_number): + def rm_get_prices(self, start_date, number_intervals, + room_type, guest_number): start_date = fields.Datetime.from_string(start_date) end_date = start_date + timedelta(days=number_intervals) dfrom = start_date.strftime( diff --git a/hotel_roommatik/models/inherited_res_partner.py b/hotel_roommatik/models/inherited_res_partner.py index 286583010..e8a48b0bf 100755 --- a/hotel_roommatik/models/inherited_res_partner.py +++ b/hotel_roommatik/models/inherited_res_partner.py @@ -5,6 +5,8 @@ import json from odoo import api, models from datetime import datetime import logging +from odoo.addons.hotel_roommatik.models.roommatik import ( + DEFAULT_ROOMMATIK_DATE_FORMAT) class ResPartner(models.Model): @@ -31,7 +33,10 @@ class ResPartner(models.Model): partner_res[0].document_number, partner_res[0].id,) except Exception as e: - error_name = e.name + if 'args' in e.__dir__(): + error_name = e.args + else: + error_name = e.name else: # Create new customer try: @@ -43,12 +48,17 @@ class ResPartner(models.Model): ('document_number', '=', customer['IdentityDocument']['Number'])]) except Exception as e: - error_name = e.name + if 'args' in e.__dir__(): + error_name = e.args + else: + error_name = e.name + partner_res = self.env['res.partner'].search([( 'document_number', '=', customer['IdentityDocument']['Number'])]) partner_res.unlink() + if write_customer: json_response = self.rm_get_a_customer(write_customer.id) json_response = json.dumps(json_response) @@ -74,8 +84,8 @@ class ResPartner(models.Model): 'firstname': customer['FirstName'], 'lastname': customer['LastName1'], 'lastname2': customer['LastName2'], - 'birthdate_date': datetime.strptime(customer['Birthday'], - "%d%m%Y").date(), + 'birthdate_date': datetime.strptime( + customer['Birthday'], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), 'gender': customer['Sex'], 'zip': customer['Address']['ZipCode'], 'city': customer['Address']['City'], @@ -88,8 +98,9 @@ class ResPartner(models.Model): 'email': customer['Contact']['Email'], 'document_number': customer['IdentityDocument']['Number'], 'document_type': customer['IdentityDocument']['Type'], - 'document_expedition_date': datetime.strptime(customer[ - 'IdentityDocument']['ExpeditionDate'], "%d%m%Y").date(), + 'document_expedition_date': datetime.strptime( + customer['IdentityDocument']['ExpeditionDate'], + DEFAULT_ROOMMATIK_DATE_FORMAT).date(), } return {k: v for k, v in metadata.items() if v != ""} diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index 557009a0a..bc4bf22f6 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -4,9 +4,9 @@ import json from datetime import datetime from odoo import api, models, fields -from odoo.tools import ( - DEFAULT_SERVER_DATE_FORMAT, - DEFAULT_SERVER_DATETIME_FORMAT) +# from odoo.tools import ( +# DEFAULT_SERVER_DATE_FORMAT, +# DEFAULT_SERVER_DATETIME_FORMAT) import logging _logger = logging.getLogger(__name__) From 0dea85d1cda1b9f351b859383f0c3e952be52108 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Thu, 25 Jul 2019 12:54:10 +0200 Subject: [PATCH 02/33] [FIX] Merchant, Expedia calculus --- hotel_data_bi/models/data_bi.py | 80 +++++++++++++++++---------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/hotel_data_bi/models/data_bi.py b/hotel_data_bi/models/data_bi.py index 41109015f..41b3eca36 100644 --- a/hotel_data_bi/models/data_bi.py +++ b/hotel_data_bi/models/data_bi.py @@ -28,10 +28,15 @@ _logger = logging.getLogger(__name__) def inv_percent_inc(amount, percent): - """Return the amount to which a percentage was applied.""" + """Return the amount to which a percentage was increment applied.""" return (amount - (amount*(100-percent))/100) +def inv_percent(amount, percent): + """Return the amount to which a percentage was applied.""" + return amount/((100-percent)/100) + + class Data_Bi(models.Model): """Management and export data for MopSolution MyDataBI.""" @@ -550,59 +555,56 @@ class Data_Bi(models.Model): # Expedia. expedia_rate = self.data_bi_rate_expedia(reserva) - # if reserva.reservation_id.folio_id.name == 'F/08211': - # # Debug Stop ------------------- - # import wdb; wdb.set_trace() - # # Debug Stop ------------------- + # Odoo IVA discount precio_iva = precio_neto-(precio_neto/1.1) precio_neto -= precio_iva - precio_comision = inv_percent_inc(precio_neto, expedia_rate[1]) - precio_neto -= precio_comision + if (expedia_rate[3] == 'MERCHANT'): + # EXPEDIA COLECT + precio_comision = inv_percent( + precio_neto, expedia_rate[1]) - precio_neto + precio_calculo = precio_neto + precio_comision + # iva "interno" de expedia..... + precio_iva2 = (precio_calculo*1.1) - precio_calculo + precio_calculo += precio_iva2 + if expedia_rate[2] != 'NONE': + # FENCED MOD + # De enero a marzo: 7% + # De abril a 15 octubre: 5% + # De 16 octubre a 31 diciembre: 7% + fence_dto = 7 + fence_dia = int(reserva.date[8:10]) + fence_mes = int(reserva.date[5:7]) + if (fence_mes >= 4) and (fence_mes <= 10): + fence_dto = 5 + if (fence_dia > 15) and (fence_mes == 10): + fence_dto = 7 + precio_dto += inv_percent( + precio_calculo, fence_dto) - precio_calculo + # Corrector segundo iva... + precio_dto += (precio_iva2 - precio_iva) - # if (expedia_rate[3] == 'MERCHANT'): - # # iva "interno" de expedia..... - # precio_iva2 = precio_neto-(precio_neto/1.1) - # precio_neto -= precio_iva2 - # precio_comision += precio_iva2 - # else: - # precio_comision = inv_percent_inc(precio_neto, expedia_rate[1]) - # precio_neto += precio_comision + else: + precio_comision = inv_percent_inc(precio_neto, expedia_rate[1]) + precio_neto -= precio_comision - if expedia_rate[2] != 'NONE': - # Es Promocion (Fence, Packet, etc.) - # "iva" "interno" de expedia..... es una comision extra - precio_iva2 = precio_neto-(precio_neto/1.1) - precio_neto -= precio_iva2 - precio_comision += precio_iva2 - # De enero a marzo: 7% - # De abril a 15 octubre: 5% - # De 16 octubre a 31 diciembre: 7% - fence_dto = 7 - fence_dia = int(reserva.date[8:10]) - fence_mes = int(reserva.date[5:7]) - if (fence_mes >= 4) and (fence_mes <= 10): - fence_dto = 5 - if (fence_dia > 15) and (fence_mes == 10): - fence_dto = 7 - precio_dto += inv_percent_inc(precio_neto, fence_dto) - - if expedia_rate[0] == 'NON-REFUNDABLE': - precio_dto += inv_percent_inc(precio_neto, 3) - - # _logger.info("%s - %s - %s - %s - En Odoo:%s - Neto a MOP:%s", + # precio_neto = round(precio_neto, 2) + # precio_comision = round(precio_comision, 2) + # precio_iva = round(precio_iva, 2) + # precio_dto = round(precio_dto, 2) + # _logger.info("%s - %s - %s - %s - En Odoo:%s", # reserva.reservation_id.folio_id.name, # expedia_rate[0], # expedia_rate[2], # expedia_rate[3], - # reserva.price, - # precio_neto + # reserva.price # ) # _logger.info('Neto: %s Comision: %s IVA: %s DTO: %s ', # precio_neto, # precio_comision, # precio_iva, # precio_dto) + precio_neto = round(precio_neto, 2) precio_comision = round(precio_comision, 2) precio_iva = round(precio_iva, 2) From d2af25dcc6e2230dd13bc333553d219ebf1e40a8 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Fri, 26 Jul 2019 09:50:10 +0200 Subject: [PATCH 03/33] [FIX] cash daily report wizard var --- cash_daily_report/wizard/cash_daily_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cash_daily_report/wizard/cash_daily_report.py b/cash_daily_report/wizard/cash_daily_report.py index 237dc9fc2..1b5a58f4a 100644 --- a/cash_daily_report/wizard/cash_daily_report.py +++ b/cash_daily_report/wizard/cash_daily_report.py @@ -136,7 +136,7 @@ class CashDailyReportWizard(models.TransientModel): if v_payment.journal_id.name not in return_journals: return_journals.update({v_payment.journal_id.name: -v_line.amount}) else: - return_journals[v_payment.journal_id.name] += -amount + return_journals[v_payment.journal_id.name] += -v_line.amount worksheet.write(k_line+offset, 0, v_payment.name) worksheet.write(k_line+offset, 1, v_line.reference) worksheet.write(k_line+offset, 2, v_line.partner_id.name) From 88d1e8c0107f8ddd57d39d1b0c8c8818daa21754 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Mon, 29 Jul 2019 11:59:52 +0200 Subject: [PATCH 04/33] [FIX] Arrival hour and create checkin --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 6563f987d..76f2eae3f 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -25,12 +25,13 @@ class HotelFolio(models.Model): 'checkout': datetime.strptime( stay["Departure"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), 'adults': stay['Adults'], + 'Arrival_hour': stay['arrival_hour'], 'room_type_id': stay['RoomType'], 'partner_id': stay["Customers"][0]["Id"] } reservation_rm = reservation_obj.create(vals) else: - reservation_rm = self.env['hotel.reservation'].browse( + reservation_rm = self.env['hotel.reservation'].sudo().browse( stay['ReservationCode']) total_chekins = reservation_rm.checkin_partner_pending_count if total_chekins > 0 and len(stay["Customers"]) <= total_chekins: @@ -49,7 +50,7 @@ class HotelFolio(models.Model): 'partner_id': room_partner["Customer"]["Id"], } try: - record = self.env['hotel.checkin.partner'].create( + record = self.env['hotel.checkin.partner'].sudo().create( checkin_partner_val) _logger.info('ROOMMATIK check-in partner: %s in \ (%s Reservation) ID:%s.', From 9de984fadfab565f1288409a6b0be95518c5cedd Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Tue, 30 Jul 2019 10:53:04 +0200 Subject: [PATCH 05/33] [FIX] Checkin/out, arrival, partner, etc. in new checkin --- .../models/inherited_hotel_checkin_partner.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 76f2eae3f..506d26be3 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -20,18 +20,16 @@ class HotelFolio(models.Model): if not stay.get('ReservationCode'): reservation_obj = self.env['hotel.reservation'] vals = { - 'checkin': datetime.strptime( - stay["Arrival"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), - 'checkout': datetime.strptime( - stay["Departure"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), + 'checkin': stay["Arrival"], + 'checkout': stay["Departure"], 'adults': stay['Adults'], - 'Arrival_hour': stay['arrival_hour'], - 'room_type_id': stay['RoomType'], + 'arrival_hour': stay['Arrival_hour'], + 'room_type_id': stay['RoomType']['Id'], 'partner_id': stay["Customers"][0]["Id"] } reservation_rm = reservation_obj.create(vals) else: - reservation_rm = self.env['hotel.reservation'].sudo().browse( + reservation_rm = self.env['hotel.reservation'].browse( stay['ReservationCode']) total_chekins = reservation_rm.checkin_partner_pending_count if total_chekins > 0 and len(stay["Customers"]) <= total_chekins: @@ -43,14 +41,12 @@ class HotelFolio(models.Model): checkin_partner_val = { 'folio_id': reservation_rm.folio_id.id, 'reservation_id': reservation_rm.id, - 'enter_date': datetime.strptime( - stay["Arrival"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), - 'exit_date': datetime.strptime( - stay["Departure"], DEFAULT_ROOMMATIK_DATE_FORMAT).date(), - 'partner_id': room_partner["Customer"]["Id"], + 'partner_id': room_partner["Id"], + 'enter_date': stay["Arrival"], + 'exit_date': stay["Departure"], } try: - record = self.env['hotel.checkin.partner'].sudo().create( + record = self.env['hotel.checkin.partner'].create( checkin_partner_val) _logger.info('ROOMMATIK check-in partner: %s in \ (%s Reservation) ID:%s.', From ca37f41bd9c221a32f90873b6d69681a77477dbb Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 30 Jul 2019 12:30:01 +0200 Subject: [PATCH 06/33] [FIX] Invalid XML: A `page` node must be below a `notebook` node --- .../views/inherited_hotel_room_type_restriction_views.xml | 4 +--- .../views/inherited_product_pricelist_views.xml | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml b/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml index e822a7328..730b622f3 100644 --- a/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml +++ b/hotel_channel_connector/views/inherited_hotel_room_type_restriction_views.xml @@ -6,9 +6,7 @@ - - - + diff --git a/hotel_channel_connector/views/inherited_product_pricelist_views.xml b/hotel_channel_connector/views/inherited_product_pricelist_views.xml index 09f8b7309..eb0d4f543 100644 --- a/hotel_channel_connector/views/inherited_product_pricelist_views.xml +++ b/hotel_channel_connector/views/inherited_product_pricelist_views.xml @@ -6,9 +6,7 @@ - - - + From 16b232e087704e2f8442602d5b383d69408a02a8 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Tue, 30 Jul 2019 19:21:03 +0200 Subject: [PATCH 07/33] [FIX] Neto in expedia colect calculus --- hotel_data_bi/models/data_bi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hotel_data_bi/models/data_bi.py b/hotel_data_bi/models/data_bi.py index 41b3eca36..ff49f71d8 100644 --- a/hotel_data_bi/models/data_bi.py +++ b/hotel_data_bi/models/data_bi.py @@ -564,6 +564,7 @@ class Data_Bi(models.Model): precio_comision = inv_percent( precio_neto, expedia_rate[1]) - precio_neto precio_calculo = precio_neto + precio_comision + precio_neto -= precio_comision # iva "interno" de expedia..... precio_iva2 = (precio_calculo*1.1) - precio_calculo precio_calculo += precio_iva2 From f48fd6eee24ac2937de068893e0485efee016de4 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Wed, 31 Jul 2019 20:00:31 +0200 Subject: [PATCH 08/33] [ADD] Segmentation and other fix --- .../models/inherited_hotel_checkin_partner.py | 18 +++++++++++++++--- hotel_roommatik/models/roommatik.py | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 506d26be3..df12d86cb 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -25,7 +25,9 @@ class HotelFolio(models.Model): 'adults': stay['Adults'], 'arrival_hour': stay['Arrival_hour'], 'room_type_id': stay['RoomType']['Id'], - 'partner_id': stay["Customers"][0]["Id"] + 'partner_id': stay["Customers"][0]["Id"], + 'segmentation_ids': stay['Segmentation'], + 'channel_type': 'virtualdoor', } reservation_rm = reservation_obj.create(vals) else: @@ -37,6 +39,13 @@ class HotelFolio(models.Model): total_chekins, reservation_rm.id) for room_partner in stay["Customers"]: + if room_partner['Address']['Nationality'] == 'ESP': + code_ine = room_partner['Address']['Province'] + else: + code_ine = room_partner['Address']['Nationality'] + province = self.env['code.ine'].search( + [('name', '=', code_ine)], limit=1) + code_ine = province.id checkin_partner_val = { 'folio_id': reservation_rm.folio_id.id, @@ -44,6 +53,7 @@ class HotelFolio(models.Model): 'partner_id': room_partner["Id"], 'enter_date': stay["Arrival"], 'exit_date': stay["Departure"], + 'code_ine_id': code_ine, } try: record = self.env['hotel.checkin.partner'].create( @@ -57,8 +67,10 @@ class HotelFolio(models.Model): stay['Id'] = record.id stay['Room'] = reservation_rm.room_id.id json_response = stay - except: - json_response = {'Estate': 'Error not create Checkin'} + except Exception as e: + error_name = 'Error not create Checkin ' + error_name += e.name + json_response = {'Estate': error_name} _logger.error('ROOMMATIK writing %s in reservation: %s).', checkin_partner_val['partner_id'], checkin_partner_val['reservation_id']) diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index bc4bf22f6..4bc380f7f 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -81,6 +81,23 @@ class RoomMatik(models.Model): apidata = self.env['hotel.room.type'] return apidata.sudo().rm_get_prices(start_date, number_intervals, room_type, guest_number) + @api.model + def rm_get_segmentation(self): + # Gets segmentation list + # return ArrayOfSegmentation + segmentations = self.env['res.partner.category'].sudo().search([]) + _logger.info('ROOMMATIK Get segmentation') + response = [] + for segmentation in segmentations: + response.append({ + "Segmentation": { + "Id": segmentation.id, + "Name": segmentation.display_name, + }, + }) + json_response = json.dumps(response) + return json_response + @api.model def _rm_add_payment(self, code, payment): apidata = self.env['account.payment'] From f4e1649f157e3aae60fe1e399d40048536077816 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Fri, 2 Aug 2019 11:19:18 +0200 Subject: [PATCH 09/33] [IMP] Cash Daily Report Internal Transfers --- cash_daily_report/data/menus.xml | 46 +++++++++-- cash_daily_report/i18n/es.po | 81 +++++++++++++------ cash_daily_report/wizard/cash_daily_report.py | 41 ++++++++-- 3 files changed, 135 insertions(+), 33 deletions(-) diff --git a/cash_daily_report/data/menus.xml b/cash_daily_report/data/menus.xml index f87b3fccd..547d2ee13 100644 --- a/cash_daily_report/data/menus.xml +++ b/cash_daily_report/data/menus.xml @@ -1,8 +1,44 @@ - - - + + + + + + + + + Internal Transfers + account.payment + form + tree,kanban,form,graph + {'default_payment_type': 'transfer', 'search_default_transfers_filter': 1} + [] + + +

+ Click to register a payment +

+ Payments are used to register liquidity movements (send, collect or transfer money). + You can then process those payments by your own means or by using installed facilities. +

+
+
+ + +
diff --git a/cash_daily_report/i18n/es.po b/cash_daily_report/i18n/es.po index 0f9b0fa66..3d23279a4 100644 --- a/cash_daily_report/i18n/es.po +++ b/cash_daily_report/i18n/es.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-20 07:33+0000\n" -"PO-Revision-Date: 2018-05-20 09:34+0200\n" +"POT-Creation-Date: 2019-08-02 08:24+0000\n" +"PO-Revision-Date: 2019-08-02 10:28+0200\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -36,11 +36,16 @@ msgstr "Informe de caja" msgid "Cash Daily Report Wizard" msgstr "Informe de caja diaria" +#. module: cash_daily_report +#: model:ir.actions.act_window,help:cash_daily_report.action_account_payments_internal +msgid "Click to register a payment" +msgstr "Pulse para registrar un pago" + #. module: cash_daily_report #: code:addons/cash_daily_report/wizard/cash_daily_report.py:82 #, python-format -msgid "Client" -msgstr "Cliente" +msgid "Client/Supplier" +msgstr "Client/Supplier" #. module: cash_daily_report #: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard @@ -66,12 +71,12 @@ msgstr "Fecha" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_display_name msgid "Display Name" -msgstr "Mostrar Nombre" +msgstr "Nombre mostrado" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_end msgid "End Date" -msgstr "Fecha finalización" +msgstr "Fecha de finalización" #. module: cash_daily_report #: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard @@ -81,7 +86,17 @@ msgstr "Generar XLS" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_id msgid "ID" -msgstr "ID" +msgstr "ID (identificación)" + +#. module: cash_daily_report +#: model:ir.ui.menu,name:cash_daily_report.hotel_transfer_menu +msgid "Internal Transfer" +msgstr "Internal Transfer" + +#. module: cash_daily_report +#: model:ir.actions.act_window,name:cash_daily_report.action_account_payments_internal +msgid "Internal Transfers" +msgstr "Internal Transfers" #. module: cash_daily_report #: code:addons/cash_daily_report/wizard/cash_daily_report.py:84 @@ -97,7 +112,7 @@ msgstr "Última modificación en" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_uid msgid "Last Updated by" -msgstr "Última actualización por" +msgstr "Última actualización de" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_date @@ -111,11 +126,25 @@ msgid "Name" msgstr "Nombre" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:128 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:157 #, python-format msgid "Not Any Payments" msgstr "No hay movimientos" +#. module: cash_daily_report +#: model:ir.ui.menu,name:cash_daily_report.hotel_payments_menu +msgid "Payments" +msgstr "Pagos" + +#. module: cash_daily_report +#: model:ir.actions.act_window,help:cash_daily_report.action_account_payments_internal +msgid "" +"Payments are used to register liquidity movements (send, collect or transfer money).\n" +" You can then process those payments by your own means or by using installed facilities." +msgstr "" +"Los pagos se utilizan para registrar movimientos de liquidez (enviar, recibir o transferir dinero).\n" +"Puede procesar esos pagos por sus propios medios o utilizando los servicios instalados." + #. module: cash_daily_report #: code:addons/cash_daily_report/wizard/cash_daily_report.py:81 #, python-format @@ -125,40 +154,46 @@ msgstr "Referencia" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_start msgid "Start Date" -msgstr "Fecha de inicio" +msgstr "Fecha de Inicio" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:143 +#: model:ir.ui.menu,name:cash_daily_report.hotel_supplier_payment_menu +msgid "Supplier Payments" +msgstr "Supplier Payments" + +#. module: cash_daily_report +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:197 #, python-format msgid "TOTAL" msgstr "TOTAL" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:139 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:188 +#, python-format +msgid "TOTAL EXPENSES" +msgstr "TOTAL EXPENSES" + +#. module: cash_daily_report +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:176 #, python-format msgid "TOTAL PAYMENT RETURNS" msgstr "TOTAL DEVOLUCIONES" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:134 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:164 #, python-format msgid "TOTAL PAYMENTS" msgstr "TOTAL PAGOS" -#. module: cash_daily_report -#: model:ir.ui.menu,name:cash_daily_report.menu_account_finance_xls_reports -msgid "XLS Reports" -msgstr "XLS Reports" - #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_binary -msgid "Xls binary" -msgstr "Xls archivo" +msgid "Xls Binary" +msgstr "Xls Binary" #. module: cash_daily_report #: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_filename -msgid "Xls filename" -msgstr "Xls nombre de archivo" +msgid "Xls Filename" +msgstr "Xls Filename" #. module: cash_daily_report #: model:ir.model,name:cash_daily_report.model_cash_daily_report_wizard diff --git a/cash_daily_report/wizard/cash_daily_report.py b/cash_daily_report/wizard/cash_daily_report.py index 1b5a58f4a..ca570e21c 100644 --- a/cash_daily_report/wizard/cash_daily_report.py +++ b/cash_daily_report/wizard/cash_daily_report.py @@ -99,14 +99,22 @@ class CashDailyReportWizard(models.TransientModel): payment_journals = {} expense_journals = {} for k_payment, v_payment in enumerate(account_payments): - amount = v_payment.amount if v_payment.payment_type == 'inbound' \ + where = v_payment.partner_id.name + amount = v_payment.amount if v_payment.payment_type in ('inbound') \ else -v_payment.amount + if v_payment.payment_type == 'transfer': + where = v_payment.destination_journal_id.name + total_account_payment += -amount + if v_payment.destination_journal_id.name not in payment_journals: + payment_journals.update({v_payment.destination_journal_id.name: -amount}) + else: + payment_journals[v_payment.destination_journal_id.name] += -amount if amount < 0: total_account_expenses += -amount if v_payment.journal_id.name not in expense_journals: - expense_journals.update({v_payment.journal_id.name: -amount}) + expense_journals.update({v_payment.journal_id.name: amount}) else: - expense_journals[v_payment.journal_id.name] += -amount + expense_journals[v_payment.journal_id.name] += amount else: total_account_payment += amount if v_payment.journal_id.name not in payment_journals: @@ -115,7 +123,7 @@ class CashDailyReportWizard(models.TransientModel): payment_journals[v_payment.journal_id.name] += amount worksheet.write(k_payment+offset, 0, v_payment.name) worksheet.write(k_payment+offset, 1, v_payment.communication) - worksheet.write(k_payment+offset, 2, v_payment.partner_id.name) + worksheet.write(k_payment+offset, 2, where) worksheet.write(k_payment+offset, 3, v_payment.payment_date, xls_cell_format_date) worksheet.write(k_payment+offset, 4, v_payment.journal_id.name) @@ -152,6 +160,9 @@ class CashDailyReportWizard(models.TransientModel): line = offset if k_line: line = k_line + offset + + + result_journals = {} # NORMAL PAYMENTS if total_account_payment != 0: line += 1 @@ -163,6 +174,10 @@ class CashDailyReportWizard(models.TransientModel): worksheet.write(line, 4, _(journal)) worksheet.write(line, 5, payment_journals[journal], xls_cell_format_money) + if journal not in result_journals: + result_journals.update({journal: payment_journals[journal]}) + else: + result_journals[journal] += payment_journals[journal] # RETURNS if total_payment_returns_amount != 0: @@ -175,6 +190,10 @@ class CashDailyReportWizard(models.TransientModel): worksheet.write(line, 4, _(journal)) worksheet.write(line, 5, return_journals[journal], xls_cell_format_money) + if journal not in result_journals: + result_journals.update({journal: return_journals[journal]}) + else: + result_journals[journal] += return_journals[journal] # EXPENSES if total_account_expenses != 0: @@ -187,13 +206,25 @@ class CashDailyReportWizard(models.TransientModel): worksheet.write(line, 4, _(journal)) worksheet.write(line, 5, -expense_journals[journal], xls_cell_format_money) + if journal not in result_journals: + result_journals.update({journal: expense_journals[journal]}) + else: + result_journals[journal] += expense_journals[journal] + + #TOTALS line += 1 worksheet.write(line, 4, _('TOTAL'), xls_cell_format_header) worksheet.write( line, 5, - total_account_payment_amount + total_payment_returns_amount, + total_account_payment + total_payment_returns_amount - total_account_expenses, xls_cell_format_header) + for journal in result_journals: + line += 1 + worksheet.write(line, 4, _(journal)) + worksheet.write(line, 5, result_journals[journal], + xls_cell_format_money) + workbook.close() file_data.seek(0) tnow = fields.Datetime.now().replace(' ', '_') From 0ea51007d0e795e3ee7044b2549118dfc1ce9869 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Fri, 2 Aug 2019 12:08:57 +0200 Subject: [PATCH 10/33] [IMP] Translate menus --- cash_daily_report/i18n/es.po | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/cash_daily_report/i18n/es.po b/cash_daily_report/i18n/es.po index 3d23279a4..9b4a07faa 100644 --- a/cash_daily_report/i18n/es.po +++ b/cash_daily_report/i18n/es.po @@ -1,21 +1,19 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * cash_daily_report +# * cash_daily_report # msgid "" msgstr "" "Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-08-02 08:24+0000\n" -"PO-Revision-Date: 2019-08-02 10:28+0200\n" +"POT-Creation-Date: 2019-08-02 10:07+0000\n" +"PO-Revision-Date: 2019-08-02 10:07+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" +"Content-Transfer-Encoding: \n" "Plural-Forms: \n" -"Language: es\n" -"X-Generator: Poedit 1.8.7.1\n" #. module: cash_daily_report #: code:addons/cash_daily_report/wizard/cash_daily_report.py:85 @@ -91,7 +89,7 @@ msgstr "ID (identificación)" #. module: cash_daily_report #: model:ir.ui.menu,name:cash_daily_report.hotel_transfer_menu msgid "Internal Transfer" -msgstr "Internal Transfer" +msgstr "Transferencias Internas" #. module: cash_daily_report #: model:ir.actions.act_window,name:cash_daily_report.action_account_payments_internal @@ -126,7 +124,7 @@ msgid "Name" msgstr "Nombre" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:157 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:159 #, python-format msgid "Not Any Payments" msgstr "No hay movimientos" @@ -138,11 +136,9 @@ msgstr "Pagos" #. module: cash_daily_report #: model:ir.actions.act_window,help:cash_daily_report.action_account_payments_internal -msgid "" -"Payments are used to register liquidity movements (send, collect or transfer money).\n" +msgid "Payments are used to register liquidity movements (send, collect or transfer money).\n" " You can then process those payments by your own means or by using installed facilities." -msgstr "" -"Los pagos se utilizan para registrar movimientos de liquidez (enviar, recibir o transferir dinero).\n" +msgstr "Los pagos se utilizan para registrar movimientos de liquidez (enviar, recibir o transferir dinero).\n" "Puede procesar esos pagos por sus propios medios o utilizando los servicios instalados." #. module: cash_daily_report @@ -159,28 +155,28 @@ msgstr "Fecha de Inicio" #. module: cash_daily_report #: model:ir.ui.menu,name:cash_daily_report.hotel_supplier_payment_menu msgid "Supplier Payments" -msgstr "Supplier Payments" +msgstr "Pagos a Proveedor" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:197 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:216 #, python-format msgid "TOTAL" msgstr "TOTAL" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:188 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:201 #, python-format msgid "TOTAL EXPENSES" msgstr "TOTAL EXPENSES" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:176 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:185 #, python-format msgid "TOTAL PAYMENT RETURNS" msgstr "TOTAL DEVOLUCIONES" #. module: cash_daily_report -#: code:addons/cash_daily_report/wizard/cash_daily_report.py:164 +#: code:addons/cash_daily_report/wizard/cash_daily_report.py:169 #, python-format msgid "TOTAL PAYMENTS" msgstr "TOTAL PAGOS" @@ -204,3 +200,4 @@ msgstr "cash.daily.report.wizard" #: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard msgid "or" msgstr "o" + From 838d28967fddfba7334dd1d41faf6b2b043ccbaf Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sun, 4 Aug 2019 09:36:49 +0200 Subject: [PATCH 11/33] [IMP] Day info summary --- cash_daily_report/wizard/cash_daily_report.py | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/cash_daily_report/wizard/cash_daily_report.py b/cash_daily_report/wizard/cash_daily_report.py index ca570e21c..cc514ddec 100644 --- a/cash_daily_report/wizard/cash_daily_report.py +++ b/cash_daily_report/wizard/cash_daily_report.py @@ -32,6 +32,7 @@ class CashDailyReportWizard(models.TransientModel): FILENAME = 'cash_daily_report.xls' _name = 'cash.daily.report.wizard' + @api.model @api.model def _get_default_date_start(self): return datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT) @@ -98,6 +99,7 @@ class CashDailyReportWizard(models.TransientModel): total_account_expenses = 0.0 payment_journals = {} expense_journals = {} + total_dates = {} for k_payment, v_payment in enumerate(account_payments): where = v_payment.partner_id.name amount = v_payment.amount if v_payment.payment_type in ('inbound') \ @@ -109,18 +111,40 @@ class CashDailyReportWizard(models.TransientModel): payment_journals.update({v_payment.destination_journal_id.name: -amount}) else: payment_journals[v_payment.destination_journal_id.name] += -amount + if v_payment.payment_date not in total_dates: + total_dates.update({v_payment.payment_date: {v_payment.destination_journal_id.name: -amount}}) + else: + if v_payment.destination_journal_id.name not in total_dates[v_payment.payment_date]: + total_dates[v_payment.payment_date].update({v_payment.destination_journal_id.name: -amount}) + else: + total_dates[v_payment.payment_date][v_payment.destination_journal_id.name] += -amount if amount < 0: total_account_expenses += -amount if v_payment.journal_id.name not in expense_journals: expense_journals.update({v_payment.journal_id.name: amount}) else: expense_journals[v_payment.journal_id.name] += amount + if v_payment.payment_date not in total_dates: + total_dates.update({v_payment.payment_date: {v_payment.journal_id.name: amount}}) + else: + if v_payment.journal_id.name not in total_dates[v_payment.payment_date]: + total_dates[v_payment.payment_date].update({v_payment.journal_id.name: amount}) + else: + total_dates[v_payment.payment_date][v_payment.journal_id.name] += amount else: total_account_payment += amount if v_payment.journal_id.name not in payment_journals: payment_journals.update({v_payment.journal_id.name: amount}) else: payment_journals[v_payment.journal_id.name] += amount + if v_payment.payment_date not in total_dates: + total_dates.update({v_payment.payment_date: {v_payment.journal_id.name: amount}}) + else: + if v_payment.journal_id.name not in total_dates[v_payment.payment_date]: + total_dates[v_payment.payment_date].update({v_payment.journal_id.name: amount}) + else: + total_dates[v_payment.payment_date][v_payment.journal_id.name] += amount + worksheet.write(k_payment+offset, 0, v_payment.name) worksheet.write(k_payment+offset, 1, v_payment.communication) worksheet.write(k_payment+offset, 2, where) @@ -145,6 +169,15 @@ class CashDailyReportWizard(models.TransientModel): return_journals.update({v_payment.journal_id.name: -v_line.amount}) else: return_journals[v_payment.journal_id.name] += -v_line.amount + + if v_payment.date not in total_dates: + total_dates.update({v_payment.date: {v_payment.journal_id.name: -amount}}) + else: + if v_payment.journal_id.name not in total_dates[v_payment.date]: + total_dates[v_payment.date].update({v_payment.journal_id.name: -v_line.amount}) + else: + total_dates[v_payment.date][v_payment.journal_id.name] += -v_line.amount + worksheet.write(k_line+offset, 0, v_payment.name) worksheet.write(k_line+offset, 1, v_line.reference) worksheet.write(k_line+offset, 2, v_line.partner_id.name) @@ -161,7 +194,7 @@ class CashDailyReportWizard(models.TransientModel): if k_line: line = k_line + offset - + result_journals = {} # NORMAL PAYMENTS if total_account_payment != 0: @@ -224,7 +257,27 @@ class CashDailyReportWizard(models.TransientModel): worksheet.write(line, 4, _(journal)) worksheet.write(line, 5, result_journals[journal], xls_cell_format_money) - + + worksheet = workbook.add_worksheet(_('Por dia')) + worksheet.write('A1', _('Date'), xls_cell_format_header) + columns = ('B1','C1','D1','E1','F1','G1','H1') + i = 0 + column_journal = {} + for journal in result_journals: + worksheet.write(columns[i], _(journal), xls_cell_format_header) + i += 1 + column_journal.update({journal: i}) + + worksheet.set_column('C:C', 50) + worksheet.set_column('D:D', 11) + + offset = 1 + total_dates = sorted(total_dates.items(), key=lambda x: x[0]) + for k_day, v_day in enumerate(total_dates): + worksheet.write(k_day+offset, 0, v_day[0]) + for journal in v_day[1]: + worksheet.write(k_day+offset, column_journal[journal], v_day[1][journal]) + workbook.close() file_data.seek(0) tnow = fields.Datetime.now().replace(' ', '_') From 5661601b62dab9e410607a613b37e52769e383d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dar=C3=ADo=20Lodeiros?= Date: Mon, 5 Aug 2019 13:22:04 +0200 Subject: [PATCH 12/33] [FIX] Vals ids segmentation --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index df12d86cb..2582f5fbe 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -26,7 +26,7 @@ class HotelFolio(models.Model): 'arrival_hour': stay['Arrival_hour'], 'room_type_id': stay['RoomType']['Id'], 'partner_id': stay["Customers"][0]["Id"], - 'segmentation_ids': stay['Segmentation'], + 'segmentation_ids': (6, 0, stay['Segmentation']), 'channel_type': 'virtualdoor', } reservation_rm = reservation_obj.create(vals) From d2af8446e430563f068686b651f4728a1cad98de Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 5 Aug 2019 17:05:04 +0200 Subject: [PATCH 13/33] [FIX] Class Name --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 2582f5fbe..18da37bae 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -10,7 +10,7 @@ from datetime import datetime import logging -class HotelFolio(models.Model): +class HotelCheckinPartner(models.Model): _inherit = 'hotel.checkin.partner' From 735ff081a3cf43e865941dd8ce78e3435e9be84b Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 5 Aug 2019 18:14:50 +0200 Subject: [PATCH 14/33] [FIX] m2m write segmentation --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 18da37bae..34777b625 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -26,7 +26,7 @@ class HotelCheckinPartner(models.Model): 'arrival_hour': stay['Arrival_hour'], 'room_type_id': stay['RoomType']['Id'], 'partner_id': stay["Customers"][0]["Id"], - 'segmentation_ids': (6, 0, stay['Segmentation']), + 'segmentation_ids': [(6, 0, [stay['Segmentation']])], 'channel_type': 'virtualdoor', } reservation_rm = reservation_obj.create(vals) From 8ba37941669952f234a4fc90dcf64d591ee4254f Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 6 Aug 2019 11:54:07 +0200 Subject: [PATCH 15/33] [FIX] availability in cancelled modifications --- .../models/hotel_reservation/importer.py | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 48230ee94..c1cd15d1e 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -252,6 +252,18 @@ class HotelReservationImporter(Component): return (checkin_utc_dt, checkout_utc_dt) + def _force_update_availability_wubook(self, binding): + # WuBook always add +1 in the channel manager for cancelled reservation + # However, the quota in Odoo has preference in the availability + cancelled_dates = binding.reservation_line_ids.mapped('date') + channel_availability = self.env['channel.hotel.room.type.availability'].search([ + ('backend_id', '=', binding.backend_id.id), + ('date', 'in', cancelled_dates) + ]) + channel_availability.write({'channel_pushed': False}) + # Force an update with the correct availability + channel_availability.push_availability(binding.backend_id) + def _update_reservation_binding(self, binding, book): is_cancellation = book['status'] in WUBOOK_STATUS_BAD binding.with_context({'connector_no_export': True}).write({ @@ -270,16 +282,7 @@ class HotelReservationImporter(Component): binding.odoo_id.with_context({ 'connector_no_export': True, 'ota_limits': False}).action_cancel() - # WuBook always add +1 in the channel manager for cancelled reservation - # However, the quota in Odoo has preference in the availability - cancelled_dates = binding.reservation_line_ids.mapped('date') - channel_availability = self.env['channel.hotel.room.type.availability'].search([ - ('backend_id', '=', binding.backend_id.id), - ('date', 'in', cancelled_dates) - ]) - channel_availability.write({'channel_pushed': False}) - # Force an update with the correct availability - channel_availability.push_availability(binding.backend_id) + self._force_update_availability_wubook(binding) elif binding.state == 'cancelled': binding.with_context({ 'connector_no_export': True, @@ -336,6 +339,8 @@ class HotelReservationImporter(Component): reservations -= reservation else: new_books.append(broom) + # Review quota if new reservation is a modification not recognized in this method + # because quota is __always__ decreased when creating reservation, even in the overlapped days return new_books, reservations @@ -410,6 +415,7 @@ class HotelReservationImporter(Component): 'connector_no_export': True, 'ota_limits': False, 'no_penalty': True}).action_cancel() + self._force_update_availability_wubook(res.odoo_id) if len(new_books) == 0: processed_rids.append(rcode) continue From 7dbc2ca735d04c313ddcfbee84eb0924ffa68e33 Mon Sep 17 00:00:00 2001 From: Pablo Date: Tue, 6 Aug 2019 11:54:07 +0200 Subject: [PATCH 16/33] [FIX] availability in cancelled modifications --- .../models/hotel_reservation/importer.py | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index 48230ee94..d24512ec5 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -252,6 +252,18 @@ class HotelReservationImporter(Component): return (checkin_utc_dt, checkout_utc_dt) + def _force_update_availability_wubook(self, binding): + # WuBook always add +1 in the channel manager for cancelled reservation + # However, the quota in Odoo has preference in the availability + cancelled_dates = binding.reservation_line_ids.mapped('date') + channel_availability = self.env['channel.hotel.room.type.availability'].search([ + ('backend_id', '=', binding.backend_id.id), + ('date', 'in', cancelled_dates) + ]) + channel_availability.write({'channel_pushed': False}) + # Force an update with the correct availability + channel_availability.push_availability(binding.backend_id) + def _update_reservation_binding(self, binding, book): is_cancellation = book['status'] in WUBOOK_STATUS_BAD binding.with_context({'connector_no_export': True}).write({ @@ -270,16 +282,7 @@ class HotelReservationImporter(Component): binding.odoo_id.with_context({ 'connector_no_export': True, 'ota_limits': False}).action_cancel() - # WuBook always add +1 in the channel manager for cancelled reservation - # However, the quota in Odoo has preference in the availability - cancelled_dates = binding.reservation_line_ids.mapped('date') - channel_availability = self.env['channel.hotel.room.type.availability'].search([ - ('backend_id', '=', binding.backend_id.id), - ('date', 'in', cancelled_dates) - ]) - channel_availability.write({'channel_pushed': False}) - # Force an update with the correct availability - channel_availability.push_availability(binding.backend_id) + self._force_update_availability_wubook(binding) elif binding.state == 'cancelled': binding.with_context({ 'connector_no_export': True, @@ -336,6 +339,8 @@ class HotelReservationImporter(Component): reservations -= reservation else: new_books.append(broom) + # Review quota if new reservation is a modification not recognized in this method + # because quota is __always__ decreased when creating reservation, even in the overlapped days return new_books, reservations @@ -410,6 +415,7 @@ class HotelReservationImporter(Component): 'connector_no_export': True, 'ota_limits': False, 'no_penalty': True}).action_cancel() + self._force_update_availability_wubook(res.channel_bind_ids[0]) if len(new_books) == 0: processed_rids.append(rcode) continue From 92920b3e3f2b80838442ad43bf4efc46e3551722 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 7 Aug 2019 10:13:06 +0200 Subject: [PATCH 17/33] [FIX] Adjust Board Services price with OTA capacity in WuBook --- .../models/hotel_room_type/exporter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 757a12380..c6eb2c00b 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type/exporter.py @@ -23,7 +23,7 @@ class HotelRoomTypeExporter(Component): boards.update( {board.channel_service: { 'dtype': 2 if board.price_type == 'fixed' else 1, - 'value': board.amount}} + 'value': board.amount * binding.ota_capacity}} ) and board.channel_service return self.backend_adapter.modify_room( binding.external_id, @@ -59,7 +59,7 @@ class HotelRoomTypeExporter(Component): boards.update( {board.channel_service: { 'dtype': 2 if board.price_type == 'fixed' else 1, - 'value': board.amount}} + 'value': board.amount * binding.ota_capacity}} ) and board.channel_service external_id = self.backend_adapter.create_room( short_code, From d107bcc2b4ae58fb253766b4d3b67290e0628880 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Wed, 7 Aug 2019 13:50:00 +0200 Subject: [PATCH 18/33] [FIX] Roommatik private method --- hotel_roommatik/models/roommatik.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index 4bc380f7f..d03680cc3 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -99,7 +99,7 @@ class RoomMatik(models.Model): return json_response @api.model - def _rm_add_payment(self, code, payment): + def rm_add_payment(self, code, payment): apidata = self.env['account.payment'] return apidata.sudo().rm_checkin_partner(code, payment) # Debug Stop ------------------- From aa4c9090c9e4b51c8fa8a60f60c6b053077b8658 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 8 Aug 2019 17:39:56 +0200 Subject: [PATCH 19/33] [FIX] A reservation can be moved from/to a room type without binding --- .../models/hotel_reservation/common.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hotel_channel_connector/models/hotel_reservation/common.py b/hotel_channel_connector/models/hotel_reservation/common.py index 15e665280..107617e78 100644 --- a/hotel_channel_connector/models/hotel_reservation/common.py +++ b/hotel_channel_connector/models/hotel_reservation/common.py @@ -223,19 +223,23 @@ class HotelReservation(models.Model): for record in self: if record.channel_bind_ids: from_channel = True - backend_id = self.env['channel.hotel.room.type'].search([ + old_backend_id = self.env['channel.hotel.room.type'].search([ ('odoo_id', '=', record.room_id.room_type_id.id) - ]).backend_id.id + ]).backend_id.id or None old_vals.append({ 'checkin': record.checkin, 'checkout': record.checkout, - 'backend_id': backend_id, + 'backend_id': old_backend_id, 'room_id': record.room_id.id, }) + # NOTE: A reservation can be moved into a room type not connected to any channel + new_backend_id = self.env['channel.hotel.room.type'].search([ + ('room_ids', 'in', vals.get('room_id', record.room_id.id)) + ]).backend_id.id or None new_vals.append({ 'checkin': vals.get('checkin', record.checkin), 'checkout': vals.get('checkout', record.checkout), - 'backend_id': backend_id, + 'backend_id': new_backend_id, 'room_id': vals.get('room_id', record.room_id.id), }) @@ -249,7 +253,6 @@ class HotelReservation(models.Model): backend_id=v_i['backend_id'], room_id=v_i['room_id'], from_channel=from_channel) - # NOTE: A reservation can be moved into a room type not connected to any channel channel_room_type_avail_obj.sudo().refresh_availability( checkin=new_vals[k_i]['checkin'], checkout=new_vals[k_i]['checkout'], From f06e80d2b22cdcc3c84421c26bbd823f111be931 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 8 Aug 2019 17:49:29 +0200 Subject: [PATCH 20/33] [FIX] Mark __all__ channel room_type avail ids as pushed Some availability may keep unpushed. The channel_room_type_avails references only to the availability of the last room type because of the for loop! Use channel_room_type_avail_ids instead. --- .../models/hotel_room_type_availability/exporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py index 355c7b4e7..a83acf2c6 100644 --- a/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py +++ b/hotel_channel_connector_wubook/models/hotel_room_type_availability/exporter.py @@ -63,7 +63,7 @@ class HotelRoomTypeAvailabilityExporter(Component): channel_message=err.data['message']) return False else: - channel_room_type_avails.with_context({ + channel_room_type_avail_ids.with_context({ 'connector_no_export': True, }).write({ 'channel_pushed': True, From 1b4e46150fff9fc10535870d98cbaf10ea9b2b3e Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sat, 10 Aug 2019 12:26:04 +0200 Subject: [PATCH 21/33] [FIX] to assign Wubook reservations --- .../models/hotel_reservation/importer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py index d24512ec5..a47f71143 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -607,6 +607,7 @@ class HotelReservationImporter(Component): folio_id = hotel_folio_obj.with_context({ 'connector_no_export': True}).create(vals) + # Update Reservation Spitted Parents sorted_rlines = folio_id.room_lines.sorted(key='id') for k_pid, v_pid in splitted_map.items(): @@ -619,6 +620,9 @@ class HotelReservationImporter(Component): for rline in rlines: for rline_bind in rline.channel_bind_ids: self.binder.bind(rline_bind.external_id, rline_bind) + # TODO: Imp refactoring method + # Force to_assign = true (fix the to_assign splitted reservations) + rline.update({'to_assign': True}) processed_rids.append(rcode) return (processed_rids, any(failed_reservations), From 99472e3f15daeab724857363c233fc801d1b9b90 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sat, 10 Aug 2019 12:41:19 +0200 Subject: [PATCH 22/33] [FIX] discount on splitted unify process --- hotel/models/hotel_reservation.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index efe4c7044..6873483c7 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -1256,23 +1256,22 @@ class HotelReservation(models.Model): ) # Days Price reservation_lines = [[], []] - tprice = [0.0, 0.0] for rline in record.reservation_line_ids: rline_dt = fields.Date.from_string(rline.date) if rline_dt >= new_start_date_dt: reservation_lines[1].append((0, False, { 'date': rline.date, - 'price': rline.price + 'price': rline.price, + 'cancel_discount': rline.cancel_discount, + 'discount': rline.discount, + 'invoice_line_ids': rline.invoice_line_ids, + 'state': rline.state, })) - tprice[1] += rline.price reservation_lines[0].append((2, rline.id, False)) - else: - tprice[0] += rline.price parent_res = record.parent_reservation or record vals.update({ 'splitted': True, - 'price_total': tprice[1], 'parent_reservation': parent_res.id, 'room_type_id': parent_res.room_type_id.id, 'state': parent_res.state, @@ -1286,7 +1285,6 @@ class HotelReservation(models.Model): Can't split reservation!")) record.write({ 'checkout': new_start_date_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT), - 'price_total': tprice[0], 'splitted': True, 'reservation_line_ids': reservation_lines[0], }) @@ -1343,13 +1341,15 @@ class HotelReservation(models.Model): reservation_line_ids = splitted_reservs.mapped('reservation_line_ids') reservation_line_ids.sorted(key=lambda r: r.date) rlines = [(5, False, False)] - tprice = 0.0 for rline in reservation_line_ids: rlines.append((0, False, { 'date': rline.date, 'price': rline.price, + 'cancel_discount': rline.cancel_discount, + 'discount': rline.discount, + 'invoice_line_ids': rline.invoice_line_ids, + 'state': rline.state, })) - tprice += rline.price # Unify osplitted_reservs = splitted_reservs - master_reservation @@ -1365,7 +1365,6 @@ class HotelReservation(models.Model): 'checkout': last_checkout, 'splitted': master_reservation.real_checkin != first_checkin or master_reservation.real_checkout != last_checkout, 'reservation_line_ids': rlines, - 'price_total': tprice, }) return True From 5ea00d5c07a671a9ee5e0feccc692f84145f488e Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sat, 10 Aug 2019 13:14:44 +0200 Subject: [PATCH 23/33] [IMP] Checkint and Checkout process on splitted reservations --- hotel/models/hotel_checkin_partner.py | 13 +++++++++++++ hotel/models/hotel_reservation.py | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/hotel/models/hotel_checkin_partner.py b/hotel/models/hotel_checkin_partner.py index 18797da05..fa03d943b 100644 --- a/hotel/models/hotel_checkin_partner.py +++ b/hotel/models/hotel_checkin_partner.py @@ -152,6 +152,19 @@ class HotelCheckinPartner(models.Model): record.update(vals) if record.reservation_id.state == 'confirm': record.reservation_id.state = 'booking' + if record.reservation_id.splitted: + master_reservation = record.reservation_id.parent_reservation or record.reservation_id + splitted_reservs = self.env['hotel.reservation'].search([ + ('splitted', '=', True), + '|', + ('parent_reservation', '=', master_reservation.id), + ('id', '=', master_reservation.id), + ('folio_id', '=', record.folio_id.id), + ('id', '!=', record.id), + ('state', '=', 'confirm') + ]) + if splitted_reservs: + splitted_reservs.update({'state': 'booking'}) return { "type": "ir.actions.do_nothing", } diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 6873483c7..e386e0e8f 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -1224,6 +1224,19 @@ class HotelReservation(models.Model): if record.checkin_partner_ids: record.checkin_partner_ids.filtered( lambda check: check.state == 'booking').action_done() + if record.splitted: + master_reservation = record.parent_reservation or record + splitted_reservs = self.env['hotel.reservation'].search([ + ('splitted', '=', True), + '|', + ('parent_reservation', '=', master_reservation.id), + ('id', '=', master_reservation.id), + ('folio_id', '=', record.folio_id.id), + ('id', '!=', record.id), + ('state', 'not in', ('cancelled', 'done')) + ]) + if splitted_reservs: + splitted_reservs.update({'state': 'done'}) return True @api.multi From c4e6fcb968d39067321d7194f13f20a8b1914f3f Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Sun, 11 Aug 2019 12:15:35 +0200 Subject: [PATCH 24/33] [IMP] Roommatik integration --- hotel_roommatik/models/__init__.py | 1 - .../models/inherited_hotel_checkin_partner.py | 22 +++++++++++-------- .../models/inherited_hotel_folio.py | 11 ---------- .../models/inherited_hotel_room_type.py | 6 ++--- hotel_roommatik/models/roommatik.py | 6 +++-- 5 files changed, 20 insertions(+), 26 deletions(-) delete mode 100755 hotel_roommatik/models/inherited_hotel_folio.py diff --git a/hotel_roommatik/models/__init__.py b/hotel_roommatik/models/__init__.py index 2a4fafbb1..6a96de1e6 100755 --- a/hotel_roommatik/models/__init__.py +++ b/hotel_roommatik/models/__init__.py @@ -1,4 +1,3 @@ -from . import inherited_hotel_folio from . import inherited_hotel_checkin_partner from . import inherited_res_partner from . import inherited_hotel_room_type diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 34777b625..aa8aceeed 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -30,10 +30,14 @@ class HotelCheckinPartner(models.Model): 'channel_type': 'virtualdoor', } reservation_rm = reservation_obj.create(vals) + stay['ReservationCode'] = reservation_rm.localizator else: - reservation_rm = self.env['hotel.reservation'].browse( - stay['ReservationCode']) + reservation_rm = self.env['hotel.reservation'].search([ + ('localizator', '=', stay['ReservationCode']) + ]) total_chekins = reservation_rm.checkin_partner_pending_count + stay['Total'] = reservation_rm.folio_pending_amount + stay['Paid'] = reservation_rm._computed_deposit_roommatik(stay['ReservationCode']) if total_chekins > 0 and len(stay["Customers"]) <= total_chekins: _logger.info('ROOMMATIK checkin %s customer in %s Reservation.', total_chekins, @@ -65,19 +69,21 @@ class HotelCheckinPartner(models.Model): record.id) record.action_on_board() stay['Id'] = record.id - stay['Room'] = reservation_rm.room_id.id + stay['Room'] = {} + stay['Room']['Id'] = reservation_rm.room_id.id + stay['Room']['Name'] = reservation_rm.room_id.name json_response = stay except Exception as e: error_name = 'Error not create Checkin ' error_name += e.name - json_response = {'Estate': error_name} + json_response = {'State': error_name} _logger.error('ROOMMATIK writing %s in reservation: %s).', checkin_partner_val['partner_id'], checkin_partner_val['reservation_id']) return json_response else: - json_response = {'Estate': 'Error checkin_partner_pending_count \ + json_response = {'State': 'Error checkin_partner_pending_count \ values do not match.'} _logger.error('ROOMMATIK checkin pending count do not match for \ Reservation ID %s.', reservation_rm.id) @@ -93,10 +99,8 @@ class HotelCheckinPartner(models.Model): default_departure_hour = self.env['ir.default'].sudo().get( 'res.config.settings', 'default_departure_hour') if any(checkin_partner): - arrival = "%s %s:00" % (checkin_partner.enter_date.strftime( - DEFAULT_ROOMMATIK_DATE_FORMAT), default_arrival_hour) - departure = "%s %s:00" % (checkin_partner.exit_date.strftime( - DEFAULT_ROOMMATIK_DATE_FORMAT), default_departure_hour) + arrival = checkin_partner.enter_date or default_arrival_hour + departure = checkin_partner.exit_date or default_departure_hour stay = {'Code': checkin_partner.id} stay['Id'] = checkin_partner.id stay['Room'] = {} diff --git a/hotel_roommatik/models/inherited_hotel_folio.py b/hotel_roommatik/models/inherited_hotel_folio.py deleted file mode 100755 index 4a1fb00fd..000000000 --- a/hotel_roommatik/models/inherited_hotel_folio.py +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright 2019 Jose Luis Algara (Alda hotels) -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import api, models -import logging -_logger = logging.getLogger(__name__) - - -class HotelFolio(models.Model): - - _inherit = 'hotel.folio' diff --git a/hotel_roommatik/models/inherited_hotel_room_type.py b/hotel_roommatik/models/inherited_hotel_room_type.py index ea5de72ac..89d844611 100644 --- a/hotel_roommatik/models/inherited_hotel_room_type.py +++ b/hotel_roommatik/models/inherited_hotel_room_type.py @@ -52,8 +52,8 @@ class HotelRoomType(models.Model): @api.model def rm_get_prices(self, start_date, number_intervals, room_type, guest_number): - start_date = fields.Datetime.from_string(start_date) - end_date = start_date + timedelta(days=number_intervals) + start_date = fields.Date.from_string(start_date) + end_date = start_date + timedelta(days=int(number_intervals)) dfrom = start_date.strftime( DEFAULT_ROOMMATIK_DATE_FORMAT) dto = end_date.strftime( @@ -64,7 +64,7 @@ class HotelRoomType(models.Model): rates = self.get_rate_room_types( room_type_ids=room_type.id, date_from=dfrom, - days=number_intervals, + days=int(number_intervals), partner_id=False) return [item['price'] for item in rates.get(room_type.id)] return [] diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index d03680cc3..ef37a19f4 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -76,9 +76,11 @@ class RoomMatik(models.Model): def rm_get_prices(self, start_date, number_intervals, room_type, guest_number): # Gets some prices related to different dates of the same stay. # return ArrayOfDecimal - room_type = self.env['hotel.room.type'].browse(room_type) - _logger.info('ROOMMATIK Get Prices') apidata = self.env['hotel.room.type'] + room_type = apidata.browse(int(room_type)) + _logger.info('ROOMMATIK Get Prices') + if not room_type: + return {'State': 'Error Room Type not Found'} return apidata.sudo().rm_get_prices(start_date, number_intervals, room_type, guest_number) @api.model From 141525de902e526f60a145ccb3061bacad962fd8 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 12 Aug 2019 12:02:27 +0200 Subject: [PATCH 25/33] [FIX] Call add payment method --- hotel_roommatik/models/inherited_account_payment.py | 2 +- hotel_roommatik/models/roommatik.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hotel_roommatik/models/inherited_account_payment.py b/hotel_roommatik/models/inherited_account_payment.py index 4d6a318ab..67168671f 100644 --- a/hotel_roommatik/models/inherited_account_payment.py +++ b/hotel_roommatik/models/inherited_account_payment.py @@ -7,7 +7,7 @@ class AccountPayment(models.Model): _inherit = 'account.payment' @api.model - def _rm_add_payment(self, code, payment): + def rm_add_payment(self, code, payment): reservation = self.env['hotel.reservation'].search([ '|', ('localizator', '=', code), ('folio_id.name', '=', code)]) diff --git a/hotel_roommatik/models/roommatik.py b/hotel_roommatik/models/roommatik.py index ef37a19f4..f7f521368 100755 --- a/hotel_roommatik/models/roommatik.py +++ b/hotel_roommatik/models/roommatik.py @@ -103,7 +103,7 @@ class RoomMatik(models.Model): @api.model def rm_add_payment(self, code, payment): apidata = self.env['account.payment'] - return apidata.sudo().rm_checkin_partner(code, payment) + return apidata.sudo().rm_add_payment(code, payment) # Debug Stop ------------------- # import wdb; wdb.set_trace() # Debug Stop ------------------- From 7ab2a5604b057023bdc85ccc802d2920d9168a35 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 12 Aug 2019 13:18:01 +0200 Subject: [PATCH 26/33] [IMP] Payment roommatik method --- hotel_roommatik/models/inherited_account_payment.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hotel_roommatik/models/inherited_account_payment.py b/hotel_roommatik/models/inherited_account_payment.py index 67168671f..e6c2ef37e 100644 --- a/hotel_roommatik/models/inherited_account_payment.py +++ b/hotel_roommatik/models/inherited_account_payment.py @@ -11,8 +11,10 @@ class AccountPayment(models.Model): reservation = self.env['hotel.reservation'].search([ '|', ('localizator', '=', code), ('folio_id.name', '=', code)]) + if not reservation: + return False if reservation: - for cashpay in payment['PaymentTransaction']['CashPayments']: + for cashpay in payment['CashPayments']: vals = { 'journal_id': 7, # TODO:config setting 'partner_id': reservation.partner_invoice_id.id, @@ -25,8 +27,8 @@ class AccountPayment(models.Model): 'partner_type': 'customer', 'state': 'draft', } - self.update(vals) - for cashpay in payment['PaymentTransaction']['CreditCardPayments']: + pay = self.create(vals) + for cashpay in payment['CreditCardPayments']: vals = { 'journal_id': 15, # TODO:config setting 'partner_id': reservation.partner_invoice_id.id, @@ -39,5 +41,6 @@ class AccountPayment(models.Model): 'partner_type': 'customer', 'state': 'draft', } - self.update(vals) - self.with_context({'ignore_notification_post': True}).post() + pay = self.create(vals) + pay.post() + return True From 6d37aed4c84b46b227426bbfcc989c8e0fa922cd Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 13 Aug 2019 11:55:00 +0200 Subject: [PATCH 27/33] [FIX] add segmentation on checkin --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index aa8aceeed..a9d1d5c0f 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -58,6 +58,7 @@ class HotelCheckinPartner(models.Model): 'enter_date': stay["Arrival"], 'exit_date': stay["Departure"], 'code_ine_id': code_ine, + 'segmentation_ids': [(6, 0, [stay['Segmentation']])], } try: record = self.env['hotel.checkin.partner'].create( From 86c42bb20954e4ecf344185b579d1b292af16d14 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 13 Aug 2019 12:48:12 +0200 Subject: [PATCH 28/33] [FIX] Payment roommatik method --- .../models/inherited_hotel_checkin_partner.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index a9d1d5c0f..daecd9020 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -57,8 +57,7 @@ class HotelCheckinPartner(models.Model): 'partner_id': room_partner["Id"], 'enter_date': stay["Arrival"], 'exit_date': stay["Departure"], - 'code_ine_id': code_ine, - 'segmentation_ids': [(6, 0, [stay['Segmentation']])], + 'code_ine_id': code_ine,, } try: record = self.env['hotel.checkin.partner'].create( @@ -68,6 +67,10 @@ class HotelCheckinPartner(models.Model): checkin_partner_val['partner_id'], checkin_partner_val['reservation_id'], record.id) + if not record.reservation_id.segmentation_ids: + record.reservation_id.update({ + 'segmentation_ids': [(6, 0, [stay['Segmentation']])] + }) record.action_on_board() stay['Id'] = record.id stay['Room'] = {} @@ -76,7 +79,7 @@ class HotelCheckinPartner(models.Model): json_response = stay except Exception as e: error_name = 'Error not create Checkin ' - error_name += e.name + error_name += str(e) json_response = {'State': error_name} _logger.error('ROOMMATIK writing %s in reservation: %s).', checkin_partner_val['partner_id'], From 0910ff8725af9db1060d9791f9a6aa9946157a7c Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 13 Aug 2019 12:56:45 +0200 Subject: [PATCH 29/33] [FIX] Payment roommatik method --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index daecd9020..848698c58 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -57,7 +57,7 @@ class HotelCheckinPartner(models.Model): 'partner_id': room_partner["Id"], 'enter_date': stay["Arrival"], 'exit_date': stay["Departure"], - 'code_ine_id': code_ine,, + 'code_ine_id': code_ine, } try: record = self.env['hotel.checkin.partner'].create( From 7bec3ee15113bd6e3616280fb0320af825fed7c5 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 13 Aug 2019 15:22:36 +0200 Subject: [PATCH 30/33] [FIX] Force update avail on splitted sections imported --- .../models/hotel_reservation/importer.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 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 a47f71143..d95b13f09 100644 --- a/hotel_channel_connector_wubook/models/hotel_reservation/importer.py +++ b/hotel_channel_connector_wubook/models/hotel_reservation/importer.py @@ -620,9 +620,21 @@ class HotelReservationImporter(Component): for rline in rlines: for rline_bind in rline.channel_bind_ids: self.binder.bind(rline_bind.external_id, rline_bind) - # TODO: Imp refactoring method + # TODO: Imp importer, refactoring method # Force to_assign = true (fix the to_assign splitted reservations) rline.update({'to_assign': True}) + # Force to update avail on splitteds sections + if rline.parent_reservation: + # This break with multi channels by room type + backend_id = self.env['channel.hotel.room.type'].search([ + ('odoo_id', '=', rline.room_type_id.id) + ]).backend_id + self.env['channel.hotel.room.type.availability'].sudo().refresh_availability( + checkin=rline.real_checkin, + checkout=rline.real_checkout, + backend_id=backend_id.id, + room_type_id=rline.room_type_id.id, + from_channel=True,) processed_rids.append(rcode) return (processed_rids, any(failed_reservations), From f9dee6393f02d4a81db1ee0bc70ba791893f7359 Mon Sep 17 00:00:00 2001 From: Pablo Date: Fri, 16 Aug 2019 11:22:08 +0200 Subject: [PATCH 31/33] [FIX] deprecated max availability constraint --- .../models/hotel_room_type_availability/common.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hotel_channel_connector/models/hotel_room_type_availability/common.py b/hotel_channel_connector/models/hotel_room_type_availability/common.py index 888862bec..267db630e 100644 --- a/hotel_channel_connector/models/hotel_room_type_availability/common.py +++ b/hotel_channel_connector/models/hotel_room_type_availability/common.py @@ -68,16 +68,6 @@ class HotelRoomTypeAvailability(models.Model): type!') ] - @api.constrains('max_avail', 'quota') - def _check_max_avail_quota(self): - for record in self: - if record.quota > record.room_type_id.total_rooms_count: - raise ValidationError(_("The quota assigned to the channel manager can't be greater " - "than the total rooms count!")) - if record.max_avail > record.room_type_id.total_rooms_count: - raise ValidationError(_("The maximum simultaneous availability can't be greater " - "than the total rooms count!")) - @api.onchange('room_type_id') def onchange_room_type_id(self): channel_room_type = self.env['channel.hotel.room.type'].search([ From a54e0ca3d08dded6ba6856b2821639c4535e17fb Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 19 Aug 2019 13:55:22 +0200 Subject: [PATCH 32/33] [FIX] amount var cash daily report --- cash_daily_report/wizard/cash_daily_report.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cash_daily_report/wizard/cash_daily_report.py b/cash_daily_report/wizard/cash_daily_report.py index cc514ddec..dfde82544 100644 --- a/cash_daily_report/wizard/cash_daily_report.py +++ b/cash_daily_report/wizard/cash_daily_report.py @@ -171,7 +171,7 @@ class CashDailyReportWizard(models.TransientModel): return_journals[v_payment.journal_id.name] += -v_line.amount if v_payment.date not in total_dates: - total_dates.update({v_payment.date: {v_payment.journal_id.name: -amount}}) + total_dates.update({v_payment.date: {v_payment.journal_id.name: -v_line.amount}}) else: if v_payment.journal_id.name not in total_dates[v_payment.date]: total_dates[v_payment.date].update({v_payment.journal_id.name: -v_line.amount}) From b4753278660ca3a6e3014ea25e223d5ff654843d Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Tue, 20 Aug 2019 08:59:14 +0200 Subject: [PATCH 33/33] [ADD] Localizator on gitStay Roommatik --- hotel_roommatik/models/inherited_hotel_checkin_partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_roommatik/models/inherited_hotel_checkin_partner.py b/hotel_roommatik/models/inherited_hotel_checkin_partner.py index 848698c58..f2240328a 100644 --- a/hotel_roommatik/models/inherited_hotel_checkin_partner.py +++ b/hotel_roommatik/models/inherited_hotel_checkin_partner.py @@ -125,7 +125,7 @@ class HotelCheckinPartner(models.Model): stay['TimeInterval']['Name'] = {} stay['TimeInterval']['Minutes'] = {} stay['Adults'] = checkin_partner.reservation_id.adults - stay['ReservationCode'] = {} + stay['ReservationCode'] = checkin_partner.reservation_id.localizator stay['Total'] = checkin_partner.reservation_id.price_total stay['Paid'] = checkin_partner.reservation_id.folio_id.invoices_paid stay['Outstanding'] = checkin_partner.reservation_id.folio_id.pending_amount