diff --git a/bross.py b/bross.py index 806c19c..a8f3ed5 100755 --- a/bross.py +++ b/bross.py @@ -45,7 +45,7 @@ headers = { # response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/guests/9007199255607320/room-stays", headers=headers) # ALL ROOMS -# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms", headers=headers) +response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms", headers=headers) # response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms?roomTypeId=5020078", headers=headers) diff --git a/bross_bank_management/cron/crons.xml b/bross_bank_management/cron/crons.xml index 197840e..d827deb 100644 --- a/bross_bank_management/cron/crons.xml +++ b/bross_bank_management/cron/crons.xml @@ -11,5 +11,16 @@ 100 + + + Process Movements Data + + code + model.process_movements() + + 1 + + 100 + \ No newline at end of file diff --git a/bross_bank_management/models/bank_account.py b/bross_bank_management/models/bank_account.py index 0f0b8bd..6a1509a 100644 --- a/bross_bank_management/models/bank_account.py +++ b/bross_bank_management/models/bank_account.py @@ -4,6 +4,7 @@ from odoo import models, fields, _ class BrosseBankAccount(models.Model): _name = 'brosse.bank.account' _description = 'Bank Account' + _rec_name = 'account_number' account_number = fields.Char(string='Account Number', required=True) holder_name = fields.Char(string='Holder Name') diff --git a/bross_bank_management/models/bank_deposits.py b/bross_bank_management/models/bank_deposits.py index 8c8f49d..b5ab9d9 100644 --- a/bross_bank_management/models/bank_deposits.py +++ b/bross_bank_management/models/bank_deposits.py @@ -7,3 +7,5 @@ class BrosseBankDeposits(models.Model): amount = fields.Monetary(string="Amount", currency_field='currency_id') currency_id = fields.Many2one('res.currency', string='Account Currency') + + bank_account_id = fields.Many2one('brosse.bank.account', string="Bank Account") diff --git a/bross_bank_management/models/bank_models.py b/bross_bank_management/models/bank_models.py index 11dd0fa..6121582 100644 --- a/bross_bank_management/models/bank_models.py +++ b/bross_bank_management/models/bank_models.py @@ -2,12 +2,36 @@ import base64 import tempfile import hashlib import json +import math import os from odoo import models, fields, _ from tbc_bank_integration_service_lib.client import TBCBankClient from odoo.exceptions import UserError +BANKS = { + "NB": {"name": "National Bank of Georgia", "code": "BNLNGE22"}, + "TR": {"name": "State Treasury", "code": "TRESGE22"}, + "BG": {"name": 'JSC "Bank of Georgia"', "code": "BAGAGE22"}, + "BS": {"name": 'JSC "BasisBank"', "code": "CBASGE22"}, + "BT": {"name": 'JSC "Silk Bank"', "code": "DISNGE22"}, + "CR": {"name": 'JSC "Cartu Bank"', "code": "CRTUGE22"}, + "HB": {"name": 'JSC "Halyk Bank Georgia"', "code": "HABGGE22"}, + "KS": {"name": 'JSC "Terabank"', "code": "TEBAGE22"}, + "LB": {"name": 'JSC "Liberty Bank"', "code": "LBRTGE22"}, + "PC": {"name": 'JSC "ProCredit Bank"', "code": "MIBGGE22"}, + "TB": {"name": 'JSC "TBC Bank"', "code": "TBCBGE22"}, + "VT": {"name": 'JSC "VTB Bank Georgia "', "code": "UGEBGE22"}, + "ZB": {"name": 'JSC "Ziraat Bank Georgia"', "code": "TCZBGE22"}, + "PB": {"name": 'JSC “Pasha Bank Georgia”', "code": "PAHAGE22"}, + "IS": {"name": 'JSC "Isbank Georgia"', "code": "ISBKGE22"}, + "CD": {"name": 'JSC "Credo Bank"', "code": "JSCRGE22"}, + "PS": {"name": 'JSC "Paysera Bank Georgia"', "code": "PSRAGE22"}, + "HS": {"name": 'JSC "HASH Bank"', "code": "HAJSGE22"}, + "PV": {"name": 'JSC "Pave Bank Georgia"', "code": "PAVEGE22"}, +} + + class BankMovements(models.Model): _name = 'bank.raw.movements' _description = 'Bank Movements' @@ -46,12 +70,62 @@ class BankMovements(models.Model): 'json_hash_code': hash_hex, 'bid': bid }) - + def get_movements(self): client = self.env['bank.settings'].get_request_object() - try: - movement_id = '013762510743.2' - movements_by_id = client.get_account_movements_by_id('111111', movement_id) - self.create_or_update_raw_data(movements_by_id, 'bank.raw.movements', movements_by_id['data'].get('movementId')) - except Exception as e: - _logger.error(e) \ No newline at end of file + res = client.get_account_movements_by_date_range('111111', '2024-01-01T00:00:00.000', '2024-10-01T00:00:00.000') + self.create_or_update_raw_data(res, 'bank.raw.movements', res['data']) + pages = math.ceil(int(res['data']['pager']['totalcount']) / int(res['data']['pager']['pagesize'])) + if pages > 1: + for page in range(1, pages): + res = client.get_account_movements_by_date_range_next_page('111111', page, 700, '2024-01-01T00:00:00.000', '2024-10-01T00:00:00.000') + self.create_or_update_raw_data(res, 'bank.raw.movements', res['data']) + + def process_movements(self): + to_process_movements = self.env['bank.raw.movements'].search([]) + for info in to_process_movements: + data = json.loads(info.json_data) + + for movement in data['data']['movements']: + account_number = movement['accountNumber'] + account_name = movement['accountName'] + amount = movement['amount']['amount'] + currency = movement['amount']['currency'] + iban_code = account_number[4:6] + + found_bank = self.env['brosse.bank'].search([('iban_code', '=', iban_code)]) + + if found_bank: + bank_id = found_bank.id + else: + bank_id = self.env['brosse.bank'].create({ + 'name': BANKS[iban_code]['name'], + 'bank_code': BANKS[iban_code]['code'], + 'iban_code': iban_code + }).id + + found_bank_account = self.env['brosse.bank.account'].search([('account_number', '=', account_number)]) + + if found_bank_account: + bank_account_id = found_bank_account.id + else: + bank_account_id = self.env['brosse.bank.account'].create({ + 'bank_ids': [(4, bank_id)], + 'holder_name': account_name, + 'account_number': account_number, + }).id + + self.env['brosse.bank.deposits'].create({ + 'bank_account_id': bank_account_id, + 'amount': amount, + 'currency_id': self.env['res.currency'].search([('name', '=', currency)]).id + }) + + + + + +# movement_id = '013762510743.2' +# movements_by_id = client.get_account_movements_by_id('111111', movement_id) +# self.create_or_update_raw_data(movements_by_id, 'bank.raw.movements', movements_by_id['data'].get('movementId')) + \ No newline at end of file diff --git a/bross_bank_management/views/bank_deposits_views.xml b/bross_bank_management/views/bank_deposits_views.xml index 024ba21..2d81351 100644 --- a/bross_bank_management/views/bank_deposits_views.xml +++ b/bross_bank_management/views/bank_deposits_views.xml @@ -5,6 +5,7 @@ brosse.bank.deposits + diff --git a/bross_hms/__manifest__.py b/bross_hms/__manifest__.py index 48149a9..f7a63d5 100644 --- a/bross_hms/__manifest__.py +++ b/bross_hms/__manifest__.py @@ -12,15 +12,20 @@ 'data': [ 'security/ir.model.access.csv', # 'cron/crons.xml', + 'data/service_kinds.xml', 'views/misc_menus.xml', 'views/main_menus.xml', 'views/emails.xml', 'views/phones.xml', 'views/customers.xml', 'views/rooms.xml', + 'views/room_types.xml', + 'views/floor.xml', + 'views/services.xml', 'views/guests.xml', 'views/amenities.xml', 'views/roomstays.xml', + 'views/agents.xml', 'views/bookings.xml', 'views/status.xml', ], diff --git a/bross_hms/data/service_kinds.xml b/bross_hms/data/service_kinds.xml new file mode 100644 index 0000000..73477d7 --- /dev/null +++ b/bross_hms/data/service_kinds.xml @@ -0,0 +1,62 @@ + + + + + accommodation + 0 + + + extra service + 1 + + + transfer + 2 + + + early check-in + 3 + + + late check-out + 4 + + + + not subject to VAT + 0 + + + subject to 0% VAT + 1 + + + subject to 10% VAT + 2 + + + subject to 18% VAT + 3 + + + subject to 10/110 VAT + 4 + + + subject to 18/118 VAT + 5 + + + subject to 20/120 VAT + 6 + + + subject to 20% VAT + 7 + + + subject to 12% VAT + 8 + + + diff --git a/bross_hms/models/__init__.py b/bross_hms/models/__init__.py index 6ae3921..fe2d928 100644 --- a/bross_hms/models/__init__.py +++ b/bross_hms/models/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from . import hms_data +from . import hms_models diff --git a/bross_hms/models/hms_data.py b/bross_hms/models/hms_models.py similarity index 59% rename from bross_hms/models/hms_data.py rename to bross_hms/models/hms_models.py index dd38aac..63e4a85 100644 --- a/bross_hms/models/hms_data.py +++ b/bross_hms/models/hms_models.py @@ -51,8 +51,26 @@ class HmsRooms(models.Model): bid = fields.Char(string="Room ID", index=True) name = fields.Char(string="Name") - roomTypeId = fields.Char(string="Room Type ID") - floorId = fields.Char(string="Floor ID") + roomTypeId = fields.Many2one(comodel_name="hms.room.types", string="Room Type") + floorId = fields.Many2one(comodel_name="hms.floors", string="Floor") + + +class HmsRoomTypes(models.Model): + _name = 'hms.room.types' + _description = 'Hms Room Types' + _rec_name = 'name' + + bid = fields.Char(string="Room Type ID", index=True) + name = fields.Char(string="Name") + + +class HmsFloors(models.Model): + _name = 'hms.floors' + _description = 'Hms Floors' + _rec_name = 'name' + + bid = fields.Char(string="Floor ID", index=True) + name = fields.Char(string="Name") class HmsGuests(models.Model): @@ -88,14 +106,14 @@ class HmsRoomStays(models.Model): bid = fields.Char(string="Room raw ID", index=True) bookingId = fields.Char(string="Booking ID", index=True) roomId = fields.Many2one(comodel_name="hms.rooms", string="Room ID") - roomTypeId = fields.Char(string="Room Type ID") + roomTypeId = fields.Many2one(comodel_name="hms.room.types", string="Room Type ID") guestsIds = fields.Many2many(comodel_name="hms.guests", string="Guests Ids") checkInDateTime = fields.Char(string="Check In Date Time") checkOutDateTime = fields.Char(string="Check Out Date Time") actualCheckInDateTime = fields.Char(string="Actual Check In Date Time") actualCheckOutDateTime = fields.Char(string="Actual Check Out Date Time") - status = fields.Char(string="Status") - bookingStatus = fields.Char(string="Booking Status") + status = fields.Many2one(comodel_name="hms.status", string="Status") + bookingStatus = fields.Many2one(comodel_name="hms.booking.status", string="Booking Status") guestCountInfo = fields.Json(string="Guest Count Info") totalPrice = fields.Json(string="Total Price") amenities = fields.Many2many(comodel_name="hms.amenities", string="Amenities") @@ -103,6 +121,12 @@ class HmsRoomStays(models.Model): bookings_id = fields.Many2one(comodel_name="hms.bookings", string="Room Stay Id") +class HmsSourceChannel(models.Model): + _name = 'hms.source.channel' + _description = 'Hms Source Channel' + _rec_name = 'name' + + name = fields.Char(string="Name") class HmsBookings(models.Model): @@ -122,7 +146,7 @@ class HmsBookings(models.Model): roomStays = fields.One2many(comodel_name="hms.roomstays", inverse_name="bookings_id", string="RoomStays") customerCompany = fields.Json(string="Customer Company") source = fields.Json(string="RoomStays (Json)") - sourceChannelName = fields.Char(string="Source Channel Name") + sourceChannelName = fields.Many2one(comodel_name="hms.source.channel", string="Source Channel Name") class HmsStatus(models.Model): @@ -136,4 +160,57 @@ class HmsBookingStatus(models.Model): _name = 'hms.booking.status' _description = 'Hms Booking Status' - name = fields.Char(string="Booking Status", required=True) \ No newline at end of file + name = fields.Char(string="Booking Status", required=True) + + +class HmsAgents(models.Model): + _name = 'hms.agents' + _description = 'Hms Agents' + _rec_name = 'name' + + index = fields.Integer(string="Index") + bid = fields.Char(string="Agent ID", index=True) + name = fields.Char(string="Name") + inn = fields.Char(string="Tax ID") + kpp = fields.Char(string="Tax Registration Reason Code") + phone = fields.Many2one(comodel_name="hms.phones", string="Phone") + email = fields.Many2one(comodel_name="hms.email", string="Email") + legalAddress = fields.Char(string="Registered Address") + mailingAddress = fields.Char(string="Postal Address") + + +class HmsServiceKinds(models.Model): + _name = 'hms.service.kinds' + _description = 'Hms Service Kinds' + _rec_name = 'name' + + name = fields.Char(string="Name") + hms_id = fields.Integer(string="ID") + + +class HmsServiceVatKinds(models.Model): + _name = 'hms.service.vat.kinds' + _description = 'Hms Service Vat Kinds' + _rec_name = 'name' + + name = fields.Char(string="Name") + hms_id = fields.Integer(string="ID") + + +class HmsServices(models.Model): + _name = 'hms.services' + _description = 'Hms Services' + _rec_name = 'bid' + + bid = fields.Char(string="ID") + kind = fields.Many2one(comodel_name="hms.service.kinds", string="Kind") + name = fields.Char(string="Name") + amount = fields.Float(string="Amount") + discount = fields.Float(string="Discount") + vat_kind = fields.Many2one(comodel_name="hms.service.vat.kinds", string="VAT Kind") + vat = fields.Float(string="VAT") + quantity = fields.Integer(string="Quantity") + service_date = fields.Datetime(string="Date") + reservationId = fields.Char(string="Reservation") + optionCategory = fields.Char(string="Option Category") + isIncluded = fields.Boolean(string="Is Included") \ No newline at end of file diff --git a/bross_hms/security/ir.model.access.csv b/bross_hms/security/ir.model.access.csv index 647f342..3275794 100644 --- a/bross_hms/security/ir.model.access.csv +++ b/bross_hms/security/ir.model.access.csv @@ -6,8 +6,16 @@ bross_hms.access_hms_email,access_hms_email,bross_hms.model_hms_email,base.group bross_hms.access_hms_phones,access_hms_phones,bross_hms.model_hms_phones,base.group_user,1,1,1,1 bross_hms.access_hms_customer,access_hms_customer,bross_hms.model_hms_customer,base.group_user,1,1,1,1 bross_hms.access_hms_rooms,access_hms_rooms,bross_hms.model_hms_rooms,base.group_user,1,1,1,1 +bross_hms.access_hms_room_types,access_hms_room_types,bross_hms.model_hms_room_types,base.group_user,1,1,1,1 +bross_hms.access_hms_floors,access_hms_floors,bross_hms.model_hms_floors,base.group_user,1,1,1,1 bross_hms.access_hms_guests,access_hms_guests,bross_hms.model_hms_guests,base.group_user,1,1,1,1 bross_hms.access_hms_amenities,access_hms_amenities,bross_hms.model_hms_amenities,base.group_user,1,1,1,1 bross_hms.access_hms_roomstays,access_hms_roomstays,bross_hms.model_hms_roomstays,base.group_user,1,1,1,1 +bross_hms.access_hms_source_channel,access_hms_source_channel,bross_hms.model_hms_source_channel,base.group_user,1,1,1,1 +bross_hms.access_hms_agents,access_hms_agents,bross_hms.model_hms_agents,base.group_user,1,1,1,1 bross_hms.access_hms_status,access_hms_status,bross_hms.model_hms_status,base.group_user,1,1,1,1 -bross_hms.access_hms_booking_status,access_hms_booking_status,bross_hms.model_hms_booking_status,base.group_user,1,1,1,1 \ No newline at end of file +bross_hms.access_hms_booking_status,access_hms_booking_status,bross_hms.model_hms_booking_status,base.group_user,1,1,1,1 + +bross_hms.access_hms_service_kinds,access_hms_service_kinds,bross_hms.model_hms_service_kinds,base.group_user,1,1,1,1 +bross_hms.access_hms_service_vat_kinds,access_hms_service_vat_kinds,bross_hms.model_hms_service_vat_kinds,base.group_user,1,1,1,1 +bross_hms.access_hms_services,access_hms_services,bross_hms.model_hms_services,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/bross_hms/views/agents.xml b/bross_hms/views/agents.xml new file mode 100644 index 0000000..7374268 --- /dev/null +++ b/bross_hms/views/agents.xml @@ -0,0 +1,27 @@ + + + + + Agents + hms.agents + + + + + + + + + Agents + hms.agents + list + +

+ Create your first amenity record. +

+
+
+ + +
+
diff --git a/bross_hms/views/amenities.xml b/bross_hms/views/amenities.xml index 737b66b..c5eeb33 100644 --- a/bross_hms/views/amenities.xml +++ b/bross_hms/views/amenities.xml @@ -22,6 +22,6 @@
- + diff --git a/bross_hms/views/floor.xml b/bross_hms/views/floor.xml new file mode 100644 index 0000000..93cf88e --- /dev/null +++ b/bross_hms/views/floor.xml @@ -0,0 +1,28 @@ + + + + + Floor + hms.floors + + + + + + + + + + Floor + hms.floors + list + +

+ Create your first floor record. +

+
+
+ + +
+
diff --git a/bross_hms/views/room_types.xml b/bross_hms/views/room_types.xml new file mode 100644 index 0000000..fab7e78 --- /dev/null +++ b/bross_hms/views/room_types.xml @@ -0,0 +1,28 @@ + + + + + Room Types + hms.room.types + + + + + + + + + + Room Types + hms.room.types + list + +

+ Create your first room type record. +

+
+
+ + +
+
diff --git a/bross_hms/views/roomstays.xml b/bross_hms/views/roomstays.xml index db3364a..9af34b4 100644 --- a/bross_hms/views/roomstays.xml +++ b/bross_hms/views/roomstays.xml @@ -57,6 +57,6 @@
- + diff --git a/bross_hms/views/services.xml b/bross_hms/views/services.xml new file mode 100644 index 0000000..1036b16 --- /dev/null +++ b/bross_hms/views/services.xml @@ -0,0 +1,28 @@ + + + + + Floor + hms.services + + + + + + + + + + Floor + hms.services + list + +

+ Create your first service record. +

+
+
+ + +
+
diff --git a/bross_hms/views/status.xml b/bross_hms/views/status.xml index 1e418d4..e618243 100644 --- a/bross_hms/views/status.xml +++ b/bross_hms/views/status.xml @@ -22,7 +22,7 @@ - + @@ -47,6 +47,6 @@ - + diff --git a/exely_integration/cron/crons.xml b/exely_integration/cron/crons.xml index a702bce..051261d 100644 --- a/exely_integration/cron/crons.xml +++ b/exely_integration/cron/crons.xml @@ -33,5 +33,16 @@ 100 + + + Process Exely Payments + + code + model.process_exely_payments() + + 1 + + 100 + \ No newline at end of file diff --git a/exely_integration/models/exely_raw_data.py b/exely_integration/models/exely_raw_data.py index 7d6b75e..123ceb7 100644 --- a/exely_integration/models/exely_raw_data.py +++ b/exely_integration/models/exely_raw_data.py @@ -190,6 +190,68 @@ class ExelyModifiedData(models.Model): if payments: self.create_or_update_raw_data(payments, 'exely.raw.payments', f"{start}{end}") + def process_exely_payments(self): + found_payment_record = self.env['hms.bookings'].search([], order="write_date desc", limit=1) + if False: + max_date = found_payment_record.write_date + else: + max_date = datetime.strptime('1970-01-01', "%Y-%m-%d").date() + + to_process_payments = self.env['exely.raw.payments'].search([('write_date', '>', max_date), ('parent_id', '=', False)]) + + to_create = [] + for payment in to_process_payments: + data = json.loads(payment.json_data) + + payment_data = data.pop('data', None) + + if payment_data: + all_agents = payment_data.pop('agents', None) + if all_agents: + for agent in all_agents: + agent['bid'] = agent.pop('id') + + email = agent.get('email', None) + if email: + agent['email'] = self.env['hms.email'].search([('email', '=', email)], limit=1).id or self.env['hms.email'].create({'email': email}).id + phone = agent.get('phone', None) + if phone: + agent['phone'] = self.env['hms.phones'].search([('phone', '=', phone)], limit=1).id or self.env['hms.phones'].create({'phone': phone}).id + + if all_agents: + for agent in all_agents: + found_agent = self.env['hms.agents'].search([('bid', '=', agent['bid'])]) + if not found_agent: + self.env['hms.agents'].create(agent) + + all_roomtypes = payment_data.pop('roomTypes', None) + if all_roomtypes: + for roomtype in all_roomtypes: + roomtype['bid'] = roomtype.pop('id') + found_roomtype = self.env['hms.room.types'].search([('bid', '=', roomtype['bid'])]) + if not found_roomtype: + self.env['hms.room.types'].create(roomtype) + else: + found_roomtype.write(roomtype) + + all_services = payment_data.pop('services', None) + if all_services: + for service in all_services: + service['bid'] = service.pop('id') + + kind = service.pop('kind', None) + if kind: + service['kind'] = self.env['hms.service.kinds'].search([('hms_id', '=', kind)]).id + + vat_kind = service.pop('vatKind', None) + if vat_kind: + service['vat_kind'] = self.env['hms.service.vat.kinds'].search([('hms_id', '=', vat_kind)]).id + + service['service_date'] = datetime.strptime(service.pop('date', None), "%Y%m%d").strftime("%Y-%m-%d") + + found_service = self.env['hms.services'].search([('bid', '=', service['bid'])]) + if not found_service: + self.env['hms.services'].create(service) def get_exely_data(self): exely_api_conf = self.env['exely.api.conf'].search([], limit=1) @@ -257,7 +319,6 @@ class ExelyModifiedData(models.Model): guest = self.get_exely_data_api(f"https://connect.hopenapi.com/api/exelypms/v1/guests/{bid}", headers) self.create_or_update_raw_data(guest, 'exely.raw.guests', bid) - ## break def process_exely_data(self): found_booking_record = self.env['hms.bookings'].search([], order="write_date desc", limit=1) @@ -303,9 +364,58 @@ class ExelyModifiedData(models.Model): for roomstay in roomstays: roomstay['bid'] = roomstay.pop('id') - if roomstay.get('roomId', None): - roomstay['roomId'] = self.env['hms.rooms'].search([('bid', '=', roomstay['roomId'])]).id + status = roomstay.pop('status', None) + if status: + found_status_id = self.env['hms.status'].search([('name', '=', status)]) + if found_status_id: + status_id = found_status_id.id + else: + status_id = self.env['hms.status'].create({'name': status}).id + roomstay['status'] = status_id + + bookingstatus = roomstay.pop('bookingStatus', None) + if bookingstatus: + found_bookingstatus_id = self.env['hms.booking.status'].search([('name', '=', bookingstatus)]) + if found_bookingstatus_id: + bookingstatus_id = found_bookingstatus_id.id + else: + bookingstatus_id = self.env['hms.booking.status'].create({'name': bookingstatus}).id + roomstay['bookingStatus'] = bookingstatus_id + + roomTypeId = roomstay.get('roomTypeId', None) + if roomTypeId: + found_roomtype = self.env['hms.room.types'].search([('bid', '=', roomTypeId)]) + if found_roomtype: + roomtype_id = found_roomtype.id + else: + roomtype_id = self.env['hms.room.types'].create({'bid': roomTypeId}).id + roomstay['roomTypeId'] = roomtype_id + + roomId = roomstay.get('roomId', None) + if roomId: + found_raw_room = self.env['exely.raw.rooms'].search([('bid', '=', roomId)]) + if found_raw_room: + room_data = json.loads(found_raw_room.json_data) + room_data['bid'] = room_data.pop('id') + roomTypeId = room_data.get('roomTypeId', None) + if roomTypeId: + found_roomtype = self.env['hms.room.types'].search([('bid', '=', roomTypeId)]) + if found_roomtype: + roomtype_id = found_roomtype.id + else: + roomtype_id = self.env['hms.room.types'].create({'bid': roomTypeId}).id + room_data['roomTypeId'] = roomtype_id + found_room = self.env['hms.rooms'].search([('bid', '=', roomId)]) + if found_room: + room_id = found_room.id + else: + room_id = self.env['hms.rooms'].create(room_data).id + + roomstay['roomId'] = room_id + + + guests = roomstay.pop('guestsIds', None) if guests: @@ -363,6 +473,15 @@ class ExelyModifiedData(models.Model): if roomstays_ids: data['roomStays'] = [(6, 0, roomstays_ids)] + sourceChannelName = data.pop('sourceChannelName', None) + if sourceChannelName: + found_source_channel = self.env['hms.source.channel'].search([('name', '=', sourceChannelName)]) + if found_source_channel: + source_channel_id = found_source_channel.id + else: + source_channel_id = self.env['hms.source.channel'].create({'name': sourceChannelName}).id + data['sourceChannelName'] = source_channel_id + to_create.append(data) if to_create: