Add new models, views, new logic on some data processing
Some checks failed
Update odoo 18 / update (push) Failing after 1m25s
Some checks failed
Update odoo 18 / update (push) Failing after 1m25s
This commit is contained in:
parent
49c2dc48d0
commit
a127096711
4
bross.py
4
bross.py
@ -18,7 +18,7 @@ headers = {
|
|||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/analytics/services/cancelled?startDate=20241008&endDate=20241008&dateKind=0", headers=headers)
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/analytics/services/cancelled?startDate=20241008&endDate=20241008&dateKind=0", headers=headers)
|
||||||
|
|
||||||
# PAYMENTS TIME PERIOD
|
# PAYMENTS TIME PERIOD
|
||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/analytics/payments?startDateTime=202408010000&endDateTime=202408072359&includeServices=true", headers=headers)
|
response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/analytics/payments?startDateTime=202408010000&endDateTime=202408072359&includeServices=true", headers=headers)
|
||||||
|
|
||||||
# BOOKINGS TIME PERIOD
|
# BOOKINGS TIME PERIOD
|
||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings?modifiedFrom=2024-01-01T00:00&modifiedTo=2024-01-30T23:59&state=Active", headers=headers)
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings?modifiedFrom=2024-01-01T00:00&modifiedTo=2024-01-30T23:59&state=Active", headers=headers)
|
||||||
@ -26,7 +26,7 @@ headers = {
|
|||||||
|
|
||||||
# BOOKING
|
# BOOKING
|
||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241009-503875-1220777184", headers=headers) # Room move
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241009-503875-1220777184", headers=headers) # Room move
|
||||||
response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241106-503875-1217522037", headers=headers) # Cancelled booking
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20241106-503875-1217522037", headers=headers) # Cancelled booking
|
||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20240727-503875-1216958604", headers=headers)
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/bookings/20240727-503875-1216958604", headers=headers)
|
||||||
|
|
||||||
# INVOICES
|
# INVOICES
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
'views/raw_movements.xml',
|
'views/raw_movements.xml',
|
||||||
'views/bank_deposits_views.xml',
|
'views/bank_deposits_views.xml',
|
||||||
'views/service_payments_views.xml',
|
'views/service_payments_views.xml',
|
||||||
|
'views/bank_payments_views.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'application': True,
|
'application': True,
|
||||||
|
|||||||
@ -3,4 +3,5 @@ from . import bank_account
|
|||||||
from . import bank_settings
|
from . import bank_settings
|
||||||
from . import bank_models
|
from . import bank_models
|
||||||
from . import bank_deposits
|
from . import bank_deposits
|
||||||
|
from . import bank_payments
|
||||||
from . import service_payments
|
from . import service_payments
|
||||||
|
|||||||
@ -13,3 +13,7 @@ class BrosseBankDeposits(models.Model):
|
|||||||
taxpayer_name = fields.Char(string="Taxpayer Name")
|
taxpayer_name = fields.Char(string="Taxpayer Name")
|
||||||
|
|
||||||
bank_account_id = fields.Many2one('brosse.bank.account', string="Bank Account")
|
bank_account_id = fields.Many2one('brosse.bank.account', string="Bank Account")
|
||||||
|
|
||||||
|
def action_process_selected_records(self):
|
||||||
|
print(self)
|
||||||
|
print(self.env.context)
|
||||||
22
bross_bank_management/models/bank_payments.py
Normal file
22
bross_bank_management/models/bank_payments.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from odoo import models, fields, _
|
||||||
|
|
||||||
|
|
||||||
|
class HmsBankPayments(models.Model):
|
||||||
|
_name = 'hms.bank.payments'
|
||||||
|
_description = 'Hms Bank Payments'
|
||||||
|
_rec_name = 'booking_id'
|
||||||
|
|
||||||
|
bank_payment_id = fields.Many2one(comodel_name="brosse.bank.deposits", string="Bank Payment ID")
|
||||||
|
booking_id = fields.Many2one(comodel_name="hms.bookings", string="Booking ID")
|
||||||
|
|
||||||
|
currency_id = fields.Many2one(comodel_name="res.currency", string="Currency")
|
||||||
|
amount = fields.Monetary(string="Amount", currency_field='currency_id')
|
||||||
|
amount_left = fields.Monetary(string="Left Amount", currency_field='currency_id')
|
||||||
|
exchange_rate = fields.Float(string="Exchange Rate")
|
||||||
|
notes = fields.Text(string="Notes")
|
||||||
|
|
||||||
|
|
||||||
|
class HmsBookings(models.Model):
|
||||||
|
_inherit = 'hms.bookings'
|
||||||
|
|
||||||
|
bank_payment_ids = fields.One2many(comodel_name="hms.bank.payments", inverse_name="booking_id", string="Booking Payments")
|
||||||
@ -5,3 +5,5 @@ access_bank_settings_admin,access_bank_settings,model_bank_settings,base.group_s
|
|||||||
bross_bank_management.access_bank_raw_movements,access_bank_raw_movements,bross_bank_management.model_bank_raw_movements,base.group_user,1,1,1,1
|
bross_bank_management.access_bank_raw_movements,access_bank_raw_movements,bross_bank_management.model_bank_raw_movements,base.group_user,1,1,1,1
|
||||||
bross_bank_management.access_brosse_bank_deposits,access_brosse_bank_deposits,bross_bank_management.model_brosse_bank_deposits,base.group_user,1,1,1,1
|
bross_bank_management.access_brosse_bank_deposits,access_brosse_bank_deposits,bross_bank_management.model_brosse_bank_deposits,base.group_user,1,1,1,1
|
||||||
bross_bank_management.access_brosse_service_payments,access_brosse_service_payments,bross_bank_management.model_brosse_service_payments,base.group_user,1,1,1,1
|
bross_bank_management.access_brosse_service_payments,access_brosse_service_payments,bross_bank_management.model_brosse_service_payments,base.group_user,1,1,1,1
|
||||||
|
|
||||||
|
bross_bank_management.access_hms_bank_payments,access_hms_bank_payments,bross_bank_management.model_hms_bank_payments,base.group_user,1,1,1,1
|
||||||
|
|||||||
|
@ -1,5 +1,35 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
<record id="action_process_selected_brosse_bank_deposits" model="ir.actions.server">
|
||||||
|
<field name="name">Brosse Bank</field>
|
||||||
|
<field name="model_id" ref="model_brosse_bank_deposits"/>
|
||||||
|
<field name="binding_model_id" ref="model_brosse_bank_deposits"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">
|
||||||
|
action = records.action_process_selected_records()
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_brosse_bank_deposits_list" model="ir.ui.view">
|
||||||
|
<field name="name">Deposits</field>
|
||||||
|
<field name="model">brosse.bank.deposits</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list string="Bank Deposits" editable="bottom">
|
||||||
|
<header>
|
||||||
|
<button name="%(action_process_selected_brosse_bank_deposits)d" type="action" string="Add bank deposits" class="btn-primary"/>
|
||||||
|
</header>
|
||||||
|
<field name="bank_account_id"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
<field name="description" optional="show"/>
|
||||||
|
<field name="comment" optional="show"/>
|
||||||
|
<field name="partner_name" optional="show"/>
|
||||||
|
<field name="taxpayer_name" optional="show"/>
|
||||||
|
<field name="currency_id" column_invisible='1'/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
<record id="view_brosse_bank_deposits_tree" model="ir.ui.view">
|
<record id="view_brosse_bank_deposits_tree" model="ir.ui.view">
|
||||||
<field name="name">Deposits</field>
|
<field name="name">Deposits</field>
|
||||||
<field name="model">brosse.bank.deposits</field>
|
<field name="model">brosse.bank.deposits</field>
|
||||||
|
|||||||
27
bross_bank_management/views/bank_payments_views.xml
Normal file
27
bross_bank_management/views/bank_payments_views.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_bookings_form_inherit" model="ir.ui.view">
|
||||||
|
<field name="name">Reservations</field>
|
||||||
|
<field name="model">hms.bookings</field>
|
||||||
|
<field name="inherit_id" ref="bross_hms.view_hms_bookings_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<data>
|
||||||
|
<xpath expr="//notebook/page[@name='room_stays']" position="before">
|
||||||
|
<page name="bank_deposits" string="Bank Payments">
|
||||||
|
<separator string="Bank Payments"/>
|
||||||
|
<field name="bank_payment_ids">
|
||||||
|
<list>
|
||||||
|
<field name="bank_payment_id" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
<field name="amount_left" readonly="1" force_save="1"/>
|
||||||
|
<field name="exchange_rate" readonly="1" force_save="1"/>
|
||||||
|
<field name="notes"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
# 'cron/crons.xml',
|
# 'cron/crons.xml',
|
||||||
|
'data/payment_methods.xml',
|
||||||
'data/service_kinds.xml',
|
'data/service_kinds.xml',
|
||||||
'views/misc_menus.xml',
|
'views/misc_menus.xml',
|
||||||
'views/main_menus.xml',
|
'views/main_menus.xml',
|
||||||
@ -22,10 +23,13 @@
|
|||||||
'views/room_types.xml',
|
'views/room_types.xml',
|
||||||
'views/floor.xml',
|
'views/floor.xml',
|
||||||
'views/services.xml',
|
'views/services.xml',
|
||||||
|
'views/reservations.xml',
|
||||||
'views/guests.xml',
|
'views/guests.xml',
|
||||||
'views/amenities.xml',
|
'views/amenities.xml',
|
||||||
'views/roomstays.xml',
|
'views/roomstays.xml',
|
||||||
'views/agents.xml',
|
'views/agents.xml',
|
||||||
|
'views/source_channels.xml',
|
||||||
|
'views/booking_source.xml',
|
||||||
'views/bookings.xml',
|
'views/bookings.xml',
|
||||||
'views/status.xml',
|
'views/status.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
45
bross_hms/data/payment_methods.xml
Normal file
45
bross_hms/data/payment_methods.xml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="payment_method_0" model="hms.payment.methods">
|
||||||
|
<field name="name">unknown</field>
|
||||||
|
<field name="hms_id">0</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_1" model="hms.payment.methods">
|
||||||
|
<field name="name">bank card</field>
|
||||||
|
<field name="hms_id">1</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_2" model="hms.payment.methods">
|
||||||
|
<field name="name">e-payment</field>
|
||||||
|
<field name="hms_id">2</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_3" model="hms.payment.methods">
|
||||||
|
<field name="name">bank transfer for legal entities</field>
|
||||||
|
<field name="hms_id">3</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_4" model="hms.payment.methods">
|
||||||
|
<field name="name">payment at check-in</field>
|
||||||
|
<field name="hms_id">4</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_5" model="hms.payment.methods">
|
||||||
|
<field name="name">bank transfer for individuals</field>
|
||||||
|
<field name="hms_id">5</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_6" model="hms.payment.methods">
|
||||||
|
<field name="name">external payment system</field>
|
||||||
|
<field name="hms_id">6</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_7" model="hms.payment.methods">
|
||||||
|
<field name="name">bank card guarantee</field>
|
||||||
|
<field name="hms_id">7</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_8" model="hms.payment.methods">
|
||||||
|
<field name="name">installment payment</field>
|
||||||
|
<field name="hms_id">8</field>
|
||||||
|
</record>
|
||||||
|
<record id="payment_method_9" model="hms.payment.methods">
|
||||||
|
<field name="name">Faster payments system</field>
|
||||||
|
<field name="hms_id">9</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
@ -43,6 +44,19 @@ class HmsCustomer(models.Model):
|
|||||||
phones = fields.Many2many(comodel_name="hms.phones", string="Phones")
|
phones = fields.Many2many(comodel_name="hms.phones", string="Phones")
|
||||||
gender = fields.Char(string="Gender")
|
gender = fields.Char(string="Gender")
|
||||||
|
|
||||||
|
customerIndex = fields.Integer(string="customerIndex", index=True)
|
||||||
|
name = fields.Char(string="Name")
|
||||||
|
customerKind = fields.Selection([('0', 'Company'), ('1', 'individual')], string="CustomerType")
|
||||||
|
inn = fields.Char(string="Tax ID")
|
||||||
|
kpp = fields.Char(string="Tax Registration Reason Code")
|
||||||
|
legalAddress = fields.Char(string="Legal Address")
|
||||||
|
mailingAddress = fields.Char(string="Mailing Address")
|
||||||
|
|
||||||
|
@api.depends('firstName', 'lastName')
|
||||||
|
def _compute_display_name(self):
|
||||||
|
for customer in self:
|
||||||
|
customer.display_name = f"{customer.firstName} {customer.lastName}" if customer.firstName and customer.lastName else ""
|
||||||
|
|
||||||
|
|
||||||
class HmsRooms(models.Model):
|
class HmsRooms(models.Model):
|
||||||
_name = 'hms.rooms'
|
_name = 'hms.rooms'
|
||||||
@ -148,6 +162,55 @@ class HmsBookings(models.Model):
|
|||||||
source = fields.Json(string="RoomStays (Json)")
|
source = fields.Json(string="RoomStays (Json)")
|
||||||
sourceChannelName = fields.Many2one(comodel_name="hms.source.channel", string="Source Channel Name")
|
sourceChannelName = fields.Many2one(comodel_name="hms.source.channel", string="Source Channel Name")
|
||||||
|
|
||||||
|
checkin_date = fields.Datetime(string="Checkin Date", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
checkout_date = fields.Datetime(string="Checkout Date", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
booking_date = fields.Datetime(string="Booking Date")
|
||||||
|
night = fields.Integer(string="Night", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
roomstays_count = fields.Integer(string="Roomstays Count", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
total_amount = fields.Float(string="Total Amount", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
to_be_paid = fields.Float(string="To Pay Amount", compute="_compute_checkin_checkout_date", store=True)
|
||||||
|
|
||||||
|
@api.depends('roomStays')
|
||||||
|
def _compute_checkin_checkout_date(self):
|
||||||
|
for booking in self:
|
||||||
|
checkin_dates = booking.roomStays.mapped('checkInDateTime')
|
||||||
|
checkout_dates = booking.roomStays.mapped('checkOutDateTime')
|
||||||
|
|
||||||
|
if checkin_dates:
|
||||||
|
checkin_date = min(datetime.fromisoformat(date) for date in checkin_dates) - timedelta(hours=4)
|
||||||
|
else:
|
||||||
|
checkin_date = False
|
||||||
|
|
||||||
|
if checkout_dates:
|
||||||
|
checkout_date = max(datetime.fromisoformat(date) for date in checkout_dates) - timedelta(hours=4)
|
||||||
|
else:
|
||||||
|
checkout_date = False
|
||||||
|
|
||||||
|
booking.checkin_date = checkin_date
|
||||||
|
booking.checkout_date = checkout_date
|
||||||
|
if checkin_date and checkout_date:
|
||||||
|
booking.night = (checkout_date - checkin_date).days if checkout_date.time() > checkin_date.time() else (checkout_date - checkin_date).days + 1
|
||||||
|
booking.roomstays_count = len(booking.roomStays)
|
||||||
|
booking.total_amount = sum(stay.totalPrice.get('amount', 0) for stay in booking.roomStays if stay.totalPrice)
|
||||||
|
booking.to_be_paid = sum(stay.totalPrice.get('toPayAmount', 0) for stay in booking.roomStays if stay.totalPrice)
|
||||||
|
|
||||||
|
|
||||||
|
def add_bank_deposits(self):
|
||||||
|
return {
|
||||||
|
'name': 'Add bank deposit',
|
||||||
|
'type': 'ir.actions.act_window',
|
||||||
|
'view_mode': 'list',
|
||||||
|
'view_type': 'form',
|
||||||
|
'res_model': 'brosse.bank.deposits',
|
||||||
|
# 'res_id': self.id,
|
||||||
|
'view_id': self.env.ref('bross_bank_management.view_brosse_bank_deposits_list').id,
|
||||||
|
'target': 'new',
|
||||||
|
'context': {
|
||||||
|
'booking_id': self.id,
|
||||||
|
'create': False,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class HmsStatus(models.Model):
|
class HmsStatus(models.Model):
|
||||||
_name = 'hms.status'
|
_name = 'hms.status'
|
||||||
@ -185,7 +248,7 @@ class HmsServiceKinds(models.Model):
|
|||||||
_rec_name = 'name'
|
_rec_name = 'name'
|
||||||
|
|
||||||
name = fields.Char(string="Name")
|
name = fields.Char(string="Name")
|
||||||
hms_id = fields.Integer(string="ID")
|
hms_id = fields.Integer(string="HMS ID")
|
||||||
|
|
||||||
|
|
||||||
class HmsServiceVatKinds(models.Model):
|
class HmsServiceVatKinds(models.Model):
|
||||||
@ -194,7 +257,7 @@ class HmsServiceVatKinds(models.Model):
|
|||||||
_rec_name = 'name'
|
_rec_name = 'name'
|
||||||
|
|
||||||
name = fields.Char(string="Name")
|
name = fields.Char(string="Name")
|
||||||
hms_id = fields.Integer(string="ID")
|
hms_id = fields.Integer(string="HMS ID")
|
||||||
|
|
||||||
|
|
||||||
class HmsServices(models.Model):
|
class HmsServices(models.Model):
|
||||||
@ -202,7 +265,7 @@ class HmsServices(models.Model):
|
|||||||
_description = 'Hms Services'
|
_description = 'Hms Services'
|
||||||
_rec_name = 'bid'
|
_rec_name = 'bid'
|
||||||
|
|
||||||
bid = fields.Char(string="ID")
|
bid = fields.Char(string="Service ID")
|
||||||
kind = fields.Many2one(comodel_name="hms.service.kinds", string="Kind")
|
kind = fields.Many2one(comodel_name="hms.service.kinds", string="Kind")
|
||||||
name = fields.Char(string="Name")
|
name = fields.Char(string="Name")
|
||||||
amount = fields.Float(string="Amount")
|
amount = fields.Float(string="Amount")
|
||||||
@ -211,6 +274,59 @@ class HmsServices(models.Model):
|
|||||||
vat = fields.Float(string="VAT")
|
vat = fields.Float(string="VAT")
|
||||||
quantity = fields.Integer(string="Quantity")
|
quantity = fields.Integer(string="Quantity")
|
||||||
service_date = fields.Datetime(string="Date")
|
service_date = fields.Datetime(string="Date")
|
||||||
reservationId = fields.Char(string="Reservation")
|
reservationId = fields.Many2one(comodel_name="hms.reservations", string="Reservation ID")
|
||||||
optionCategory = fields.Char(string="Option Category")
|
optionCategory = fields.Char(string="Option Category")
|
||||||
isIncluded = fields.Boolean(string="Is Included")
|
isIncluded = fields.Boolean(string="Is Included")
|
||||||
|
|
||||||
|
|
||||||
|
class HmsPaymentMethods(models.Model):
|
||||||
|
_name = 'hms.payment.methods'
|
||||||
|
_description = 'Hms Payment Methods'
|
||||||
|
_rec_name = 'name'
|
||||||
|
|
||||||
|
name = fields.Char(string="Name")
|
||||||
|
hms_id = fields.Integer(string="HMS ID")
|
||||||
|
|
||||||
|
|
||||||
|
class HmsBookingSource(models.Model):
|
||||||
|
_name = 'hms.booking.source'
|
||||||
|
_description = 'Hms Booking Source'
|
||||||
|
_rec_name = 'name'
|
||||||
|
|
||||||
|
name = fields.Char(string="Name")
|
||||||
|
|
||||||
|
|
||||||
|
class HmsReservations(models.Model):
|
||||||
|
_name = 'hms.reservations'
|
||||||
|
_description = 'Hms Reservations'
|
||||||
|
|
||||||
|
bid = fields.Char(string="Reservation ID")
|
||||||
|
customerIndex = fields.Many2one(comodel_name="hms.customer", string="Customer")
|
||||||
|
agentIndex = fields.Many2one(comodel_name="hms.agents", string="Agent")
|
||||||
|
currency = fields.Many2one(comodel_name="res.currency", string="Currency")
|
||||||
|
currencyRate = fields.Float(string="Currency Rate", digits=(16, 4))
|
||||||
|
bookingNumber = fields.Many2one(comodel_name="hms.bookings", string="Booking Number")
|
||||||
|
roomNumber = fields.Many2one(comodel_name="hms.rooms", string="Room Number")
|
||||||
|
guestId = fields.Many2one(comodel_name="hms.guests", string="Guest ID")
|
||||||
|
guestName = fields.Char(string="Guest Name")
|
||||||
|
guestCount = fields.Integer(string="Guest Count")
|
||||||
|
checkInDateTime = fields.Char(string="Check-In Char")
|
||||||
|
checkOutDateTime = fields.Char(string="Check-Out Char")
|
||||||
|
checkInDateTime_date = fields.Datetime(string="Check-In")
|
||||||
|
checkOutDateTime_date = fields.Datetime(string="Check-Out")
|
||||||
|
permitNumber = fields.Char(string="Permit Number")
|
||||||
|
isDeparted = fields.Boolean(string="Is Departed", default=False)
|
||||||
|
isArrived = fields.Boolean(string="Is Arrived", default=False)
|
||||||
|
paymentMethod = fields.Integer(string="Payment Method")
|
||||||
|
roomTypeId = fields.Many2one(comodel_name="hms.room.types", string="Room Type ID")
|
||||||
|
customerCompany = fields.Char(string="Customer Company")
|
||||||
|
payerCompany = fields.Char(string="Payer Company")
|
||||||
|
total = fields.Monetary(string="Total", currency_field='currency')
|
||||||
|
tax = fields.Monetary(string="Tax", currency_field='currency')
|
||||||
|
paid = fields.Monetary(string="Paid", currency_field='currency')
|
||||||
|
balance = fields.Monetary(string="Balance", currency_field='currency')
|
||||||
|
creationDateTime = fields.Char(string="Creation Char")
|
||||||
|
creationDateTime_date = fields.Datetime(string="Creation")
|
||||||
|
folioNumber = fields.Char(string="Folio Number")
|
||||||
|
marketCode = fields.Json(string="Market Code")
|
||||||
|
bookingSource = fields.Many2one(comodel_name="hms.booking.source", string="Booking Source")
|
||||||
@ -19,3 +19,6 @@ bross_hms.access_hms_booking_status,access_hms_booking_status,bross_hms.model_hm
|
|||||||
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_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_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
|
bross_hms.access_hms_services,access_hms_services,bross_hms.model_hms_services,base.group_user,1,1,1,1
|
||||||
|
bross_hms.access_hms_payment_methods,access_hms_payment_methods,bross_hms.model_hms_payment_methods,base.group_user,1,1,1,1
|
||||||
|
bross_hms.access_hms_booking_source,access_hms_booking_source,bross_hms.model_hms_booking_source,base.group_user,1,1,1,1
|
||||||
|
bross_hms.access_hms_reservations,access_hms_reservations,bross_hms.model_hms_reservations,base.group_user,1,1,1,1
|
||||||
|
@ -22,6 +22,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_agents" name="Agents" parent="customers_and_partners_root_menu" sequence="50" action="action_hms_agents_action"/>
|
<menuitem id="menu_hms_agents" name="Agents" parent="customers_and_partners_root_menu" sequence="40" action="action_hms_agents_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@ -22,6 +22,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_amenities" name="Amenities" parent="property_management_root_menu" sequence="60" action="action_hms_amenities_action"/>
|
<menuitem id="menu_hms_amenities" name="Amenities" parent="property_management_root_menu" sequence="70" action="action_hms_amenities_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
27
bross_hms/views/booking_source.xml
Normal file
27
bross_hms/views/booking_source.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_booking_source_list" model="ir.ui.view">
|
||||||
|
<field name="name">Booking Source</field>
|
||||||
|
<field name="model">hms.booking.source</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_booking_source_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Booking Source</field>
|
||||||
|
<field name="res_model">hms.booking.source</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first booking source record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_booking_source" name="Booking Source" parent="customers_and_partners_root_menu" sequence="80" action="action_hms_booking_source_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -12,6 +12,7 @@
|
|||||||
<field name="lastModified"/>
|
<field name="lastModified"/>
|
||||||
<field name="currencyId"/>
|
<field name="currencyId"/>
|
||||||
<field name="sourceChannelName"/>
|
<field name="sourceChannelName"/>
|
||||||
|
<button name="add_bank_deposits" type="object" string="Add bank deposits" class="btn btn-primary"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@ -22,12 +23,13 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form edit="0">
|
<form edit="0">
|
||||||
<header>
|
<header>
|
||||||
|
<button name="add_bank_deposits" type="object" string="Add bank deposits" class="btn btn-primary"/>
|
||||||
</header>
|
</header>
|
||||||
<sheet>
|
<sheet>
|
||||||
<group class="oe_title">
|
<div class="oe_title">
|
||||||
<h1><field name="bid"/></h1>
|
<h1><field name="bid"/></h1>
|
||||||
</group>
|
</div>
|
||||||
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="customerLanguage"/>
|
<field name="customerLanguage"/>
|
||||||
@ -42,9 +44,40 @@
|
|||||||
<field name="source"/>
|
<field name="source"/>
|
||||||
<field name="sourceChannelName"/>
|
<field name="sourceChannelName"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="checkin_date"/>
|
||||||
|
<field name="checkout_date"/>
|
||||||
|
<field name="booking_date"/>
|
||||||
|
<field name="night"/>
|
||||||
|
<field name="roomstays_count"/>
|
||||||
|
<field name="total_amount"/>
|
||||||
|
<field name="to_be_paid"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="roomStays" widget="many2many_tags"/>
|
<field name="roomStays" widget="many2many_tags"/>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<notebook>
|
||||||
|
<page name="room_stays" string="Room Stays">
|
||||||
|
<separator string="Room Stays"/>
|
||||||
|
<field name="roomStays">
|
||||||
|
<list>
|
||||||
|
<field name="roomId" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="roomTypeId" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="guestsIds" optional="hide" widget="many2many_tags" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="checkInDateTime"/>
|
||||||
|
<field name="checkOutDateTime"/>
|
||||||
|
<field name="actualCheckInDateTime"/>
|
||||||
|
<field name="actualCheckOutDateTime"/>
|
||||||
|
<field name="status" optional="hide" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="bookingStatus" optional="hide" options="{'no_open': True, 'no_create': True, 'no_create_edit': True, 'no_quick_create': True}"/>
|
||||||
|
<field name="totalPrice" optional="hide"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</group>
|
||||||
</sheet>
|
</sheet>
|
||||||
</form>
|
</form>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<list>
|
<list>
|
||||||
<field name="bid"/>
|
<field name="bid"/>
|
||||||
<field name="lastName"/>
|
|
||||||
<field name="firstName"/>
|
<field name="firstName"/>
|
||||||
|
<field name="lastName"/>
|
||||||
<field name="middleName"/>
|
<field name="middleName"/>
|
||||||
<field name="birthDate"/>
|
<field name="birthDate"/>
|
||||||
<field name="citizenshipCode"/>
|
<field name="citizenshipCode"/>
|
||||||
|
|||||||
@ -63,6 +63,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_guests" name="Guests" parent="customers_and_partners_root_menu" sequence="50" action="action_hms_guests_action"/>
|
<menuitem id="menu_hms_guests" name="Guests" parent="customers_and_partners_root_menu" sequence="60" action="action_hms_guests_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
80
bross_hms/views/reservations.xml
Normal file
80
bross_hms/views/reservations.xml
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_reservations_list" model="ir.ui.view">
|
||||||
|
<field name="name">Reservations</field>
|
||||||
|
<field name="model">hms.reservations</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="bid"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_hms_reservations_form" model="ir.ui.view">
|
||||||
|
<field name="name">Reservations</field>
|
||||||
|
<field name="model">hms.reservations</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Hms Reservations">
|
||||||
|
<header>
|
||||||
|
|
||||||
|
</header>
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="bid"/>
|
||||||
|
<field name="customerIndex"/>
|
||||||
|
<field name="agentIndex"/>
|
||||||
|
<field name="currency"/>
|
||||||
|
<field name="currencyRate"/>
|
||||||
|
<field name="bookingNumber"/>
|
||||||
|
<field name="roomNumber"/>
|
||||||
|
<field name="guestId"/>
|
||||||
|
<field name="guestName"/>
|
||||||
|
<field name="guestCount"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="checkInDateTime_date"/>
|
||||||
|
<field name="checkOutDateTime_date"/>
|
||||||
|
<field name="permitNumber"/>
|
||||||
|
<field name="isDeparted"/>
|
||||||
|
<field name="isArrived"/>
|
||||||
|
<field name="paymentMethod"/>
|
||||||
|
<field name="roomTypeId"/>
|
||||||
|
<field name="customerCompany"/>
|
||||||
|
<field name="payerCompany"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<group>
|
||||||
|
<field name="total"/>
|
||||||
|
<field name="tax"/>
|
||||||
|
<field name="paid"/>
|
||||||
|
<field name="balance"/>
|
||||||
|
<field name="creationDateTime_date"/>
|
||||||
|
</group>
|
||||||
|
<group>
|
||||||
|
<field name="folioNumber"/>
|
||||||
|
<field name="marketCode" widget="json"/>
|
||||||
|
<field name="bookingSource"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_reservations_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Reservations</field>
|
||||||
|
<field name="res_model">hms.reservations</field>
|
||||||
|
<field name="view_mode">list,form</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first reservation record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_reservations" name="Reservations" parent="property_management_root_menu" sequence="60" action="action_hms_reservations_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -57,6 +57,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_roomstays" name="Room Stays" parent="customers_and_partners_root_menu" groups="base.group_no_one" sequence="40" action="action_hms_roomstays_action"/>
|
<menuitem id="menu_hms_roomstays" name="Room Stays" parent="customers_and_partners_root_menu" groups="base.group_no_one" sequence="50" action="action_hms_roomstays_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
27
bross_hms/views/source_channels.xml
Normal file
27
bross_hms/views/source_channels.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_source_channel_list" model="ir.ui.view">
|
||||||
|
<field name="name">Channel</field>
|
||||||
|
<field name="model">hms.source.channel</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_source_channel_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Channel</field>
|
||||||
|
<field name="res_model">hms.source.channel</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first source channel record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_source_channel" name="Source Channel" parent="customers_and_partners_root_menu" sequence="70" action="action_hms_source_channel_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_status" name="Status" parent="property_management_root_menu" sequence="70" action="action_hms_status_action"/>
|
<menuitem id="menu_hms_status" name="Status" parent="property_management_root_menu" sequence="80" action="action_hms_status_action"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -47,6 +47,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_booking_status" name="Booking Status" parent="property_management_root_menu" sequence="80" action="action_hms_booking_status_action"/>
|
<menuitem id="menu_hms_booking_status" name="Booking Status" parent="property_management_root_menu" sequence="90" action="action_hms_booking_status_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@ -206,6 +206,31 @@ class ExelyModifiedData(models.Model):
|
|||||||
payment_data = data.pop('data', None)
|
payment_data = data.pop('data', None)
|
||||||
|
|
||||||
if payment_data:
|
if payment_data:
|
||||||
|
customers_dict = {}
|
||||||
|
all_customers = payment_data.pop('customers', None)
|
||||||
|
if all_customers:
|
||||||
|
for customer in all_customers:
|
||||||
|
customer['bid'] = customer.pop('id')
|
||||||
|
customer['customerIndex'] = customer.pop('index')
|
||||||
|
customer['customerKind'] = str(customer.pop('customerKind'))
|
||||||
|
|
||||||
|
email = customer.pop('email', None)
|
||||||
|
if email:
|
||||||
|
customer['emails'] = [(4, self.env['hms.email'].search([('email', '=', email)], limit=1).id or self.env['hms.email'].create({'email': email}).id)]
|
||||||
|
|
||||||
|
phone = customer.pop('phone', None)
|
||||||
|
if customer:
|
||||||
|
customer['phones'] = [(4, self.env['hms.phones'].search([('phone', '=', phone)], limit=1).id or self.env['hms.phones'].create({'phone': phone}).id)]
|
||||||
|
|
||||||
|
found_customer = self.env['hms.customer'].search([('bid', '=', customer['bid'])])
|
||||||
|
if not found_customer:
|
||||||
|
customer_obj = self.env['hms.customer'].create(customer)
|
||||||
|
customers_dict[customer_obj.customerIndex] = customer_obj.id
|
||||||
|
else:
|
||||||
|
found_customer.write(customer)
|
||||||
|
customers_dict[customer.get('customerIndex')] = found_customer.id
|
||||||
|
|
||||||
|
agents_dict = {}
|
||||||
all_agents = payment_data.pop('agents', None)
|
all_agents = payment_data.pop('agents', None)
|
||||||
if all_agents:
|
if all_agents:
|
||||||
for agent in all_agents:
|
for agent in all_agents:
|
||||||
@ -218,11 +243,13 @@ class ExelyModifiedData(models.Model):
|
|||||||
if phone:
|
if phone:
|
||||||
agent['phone'] = self.env['hms.phones'].search([('phone', '=', phone)], limit=1).id or self.env['hms.phones'].create({'phone': phone}).id
|
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'])])
|
found_agent = self.env['hms.agents'].search([('bid', '=', agent['bid'])])
|
||||||
if not found_agent:
|
if not found_agent:
|
||||||
self.env['hms.agents'].create(agent)
|
customer_obj = self.env['hms.agents'].create(agent)
|
||||||
|
agents_dict[customer_obj.index] = customer_obj.id
|
||||||
|
else:
|
||||||
|
found_agent.write(agent)
|
||||||
|
agents_dict[agent.get('index')] = found_agent.id
|
||||||
|
|
||||||
all_roomtypes = payment_data.pop('roomTypes', None)
|
all_roomtypes = payment_data.pop('roomTypes', None)
|
||||||
if all_roomtypes:
|
if all_roomtypes:
|
||||||
@ -234,6 +261,74 @@ class ExelyModifiedData(models.Model):
|
|||||||
else:
|
else:
|
||||||
found_roomtype.write(roomtype)
|
found_roomtype.write(roomtype)
|
||||||
|
|
||||||
|
reservations_dict = {reservation.bid: reservation.id for reservation in self.env['hms.reservations'].search([])}
|
||||||
|
all_reservations = payment_data.pop('reservations', None)
|
||||||
|
if all_reservations:
|
||||||
|
for reservation in all_reservations:
|
||||||
|
reservation['bid'] = reservation.pop('id')
|
||||||
|
|
||||||
|
customerindex = reservation.pop('customerIndex', None)
|
||||||
|
if customerindex:
|
||||||
|
reservation['customerIndex'] = customers_dict[customerindex]
|
||||||
|
|
||||||
|
agentindex = reservation.pop('agentIndex', None)
|
||||||
|
if agentindex:
|
||||||
|
reservation['agentIndex'] = agents_dict[agentindex]
|
||||||
|
|
||||||
|
currency = reservation.pop('currency', None)
|
||||||
|
if currency:
|
||||||
|
reservation['currency'] = self.env['res.currency'].search([('name', '=', currency)]).id
|
||||||
|
|
||||||
|
bookingnumber = reservation.pop('bookingNumber', None)
|
||||||
|
if bookingnumber:
|
||||||
|
reservation['bookingNumber'] = self.env['hms.bookings'].search([('number', '=', bookingnumber)]).id
|
||||||
|
|
||||||
|
roomnumber = reservation.pop('roomNumber', None)
|
||||||
|
if roomnumber:
|
||||||
|
reservation['roomNumber'] = self.env['hms.rooms'].search([('name', '=', roomnumber)]).id
|
||||||
|
|
||||||
|
guestid = reservation.pop('guestId', None)
|
||||||
|
if guestid:
|
||||||
|
guestid = guestid.split('_')[1]
|
||||||
|
reservation['guestId'] = self.env['hms.guests'].search([('bid', '=', guestid)]).id
|
||||||
|
|
||||||
|
checkindatetime = reservation.pop('checkInDateTime', None)
|
||||||
|
if checkindatetime:
|
||||||
|
reservation['checkInDateTime_date'] = datetime.strptime(checkindatetime, "%Y%m%d%H%M").strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
checkoutdatetime = reservation.pop('checkOutDateTime', None)
|
||||||
|
if checkoutdatetime:
|
||||||
|
reservation['checkOutDateTime_date'] = datetime.strptime(checkoutdatetime, "%Y%m%d%H%M").strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
paymentmethod = reservation.pop('paymentMethod', None)
|
||||||
|
if paymentmethod:
|
||||||
|
reservation['paymentMethod'] = self.env['hms.payment.methods'].search([('hms_id', '=', paymentmethod)]).id
|
||||||
|
|
||||||
|
roomtypeid = reservation.pop('roomTypeId', None)
|
||||||
|
if roomtypeid:
|
||||||
|
reservation['roomTypeId'] = self.env['hms.room.types'].search([('bid', '=', roomtypeid)]).id
|
||||||
|
|
||||||
|
creationdatetime = reservation.pop('creationDateTime', None)
|
||||||
|
if creationdatetime:
|
||||||
|
reservation['creationDateTime_date'] = datetime.strptime(creationdatetime, "%Y%m%d%H%M").strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
bookingsource = reservation.pop('bookingSource', None)
|
||||||
|
if bookingsource:
|
||||||
|
found_bookingsource = self.env['hms.booking.source'].search([('name', '=', bookingsource)])
|
||||||
|
if found_bookingsource:
|
||||||
|
reservation['bookingSource'] = found_bookingsource.id
|
||||||
|
else:
|
||||||
|
reservation['bookingSource'] = self.env['hms.booking.source'].create({'name': bookingsource}).id
|
||||||
|
|
||||||
|
found_reservation = self.env['hms.reservations'].search([('bid', '=', reservation['bid'])])
|
||||||
|
if not found_reservation:
|
||||||
|
reservation_obj =self.env['hms.reservations'].create(reservation)
|
||||||
|
else:
|
||||||
|
reservation_obj = found_reservation
|
||||||
|
|
||||||
|
if not reservation_obj.bid in reservations_dict:
|
||||||
|
reservations_dict[reservation_obj.bid] = reservation_obj.id
|
||||||
|
|
||||||
all_services = payment_data.pop('services', None)
|
all_services = payment_data.pop('services', None)
|
||||||
if all_services:
|
if all_services:
|
||||||
for service in all_services:
|
for service in all_services:
|
||||||
@ -249,6 +344,10 @@ class ExelyModifiedData(models.Model):
|
|||||||
|
|
||||||
service['service_date'] = datetime.strptime(service.pop('date', None), "%Y%m%d").strftime("%Y-%m-%d")
|
service['service_date'] = datetime.strptime(service.pop('date', None), "%Y%m%d").strftime("%Y-%m-%d")
|
||||||
|
|
||||||
|
reservationid = service.pop('reservationId', None)
|
||||||
|
if reservationid:
|
||||||
|
service['reservationId'] = reservations_dict[str(reservationid)]
|
||||||
|
|
||||||
found_service = self.env['hms.services'].search([('bid', '=', service['bid'])])
|
found_service = self.env['hms.services'].search([('bid', '=', service['bid'])])
|
||||||
if not found_service:
|
if not found_service:
|
||||||
self.env['hms.services'].create(service)
|
self.env['hms.services'].create(service)
|
||||||
@ -492,154 +591,6 @@ class ExelyModifiedData(models.Model):
|
|||||||
_logger.warning(f"##############################: {i}")
|
_logger.warning(f"##############################: {i}")
|
||||||
|
|
||||||
|
|
||||||
# DIRECTLY FROM EXELY
|
|
||||||
# def process_exely_data(self):
|
|
||||||
# self.sync_room_numbers()
|
|
||||||
|
|
||||||
# start_date = datetime(2024, 1, 1)
|
|
||||||
# end_date = datetime.now()
|
|
||||||
|
|
||||||
# date_ranges = self.generate_date_ranges(start_date, end_date)
|
|
||||||
|
|
||||||
# to_create = []
|
|
||||||
# for status in STATES:
|
|
||||||
# for start, end in date_ranges:
|
|
||||||
# print(f"{start} to {end}")
|
|
||||||
|
|
||||||
# data = self.get_modified_bookings(start, end, status)
|
|
||||||
# if data:
|
|
||||||
# for booking_number in data['bookingNumbers']:
|
|
||||||
# start_write = datetime.strptime(start, "%Y-%m-%dT%H:%M") - timedelta(hours=4)
|
|
||||||
# end_write = datetime.strptime(end, "%Y-%m-%dT%H:%M") - timedelta(hours=4)
|
|
||||||
# found_modified_booking = self.env['exely.modified.bookings'].search([
|
|
||||||
# ('mod_period_start', '=', start_write),
|
|
||||||
# ('mod_period_end', '=', end_write),
|
|
||||||
# ('booking_number', '=', booking_number),
|
|
||||||
# ('status', '=', status)]
|
|
||||||
# )
|
|
||||||
# if not found_modified_booking:
|
|
||||||
# self.env['exely.modified.bookings'].create({
|
|
||||||
# 'mod_period_start': start_write,
|
|
||||||
# 'mod_period_end': end_write,
|
|
||||||
# 'booking_number': booking_number,
|
|
||||||
# 'status': status
|
|
||||||
# })
|
|
||||||
|
|
||||||
# data = self.get_booking_info(booking_number)
|
|
||||||
# if data:
|
|
||||||
# data['bid'] = data.pop('id')
|
|
||||||
# customer = data.pop('customer', None)
|
|
||||||
|
|
||||||
# if customer:
|
|
||||||
# customer['bid'] = customer.pop('id')
|
|
||||||
|
|
||||||
# if customer.get('emails', None):
|
|
||||||
# customer['emails'] = [(6, 0, [
|
|
||||||
# self.env['exely.email'].search([('email', '=', email)], limit=1).id or
|
|
||||||
# self.env['exely.email'].create({'email': email}).id
|
|
||||||
# for email in customer['emails']
|
|
||||||
# ])]
|
|
||||||
|
|
||||||
# if customer.get('phones', None):
|
|
||||||
# customer['phones'] = [(6, 0, [
|
|
||||||
# self.env['exely.phones'].search([('phone', '=', phone)], limit=1).id or
|
|
||||||
# self.env['exely.phones'].create({'phone': phone}).id
|
|
||||||
# for phone in customer['phones']
|
|
||||||
# ])]
|
|
||||||
|
|
||||||
# found_customer = self.env['exely.customer'].search([('bid', '=', customer['bid'])])
|
|
||||||
# if found_customer:
|
|
||||||
# customer_id = found_customer.id
|
|
||||||
# else:
|
|
||||||
# customer_id = self.env['exely.customer'].create(customer).id
|
|
||||||
# data['customer'] = customer_id
|
|
||||||
|
|
||||||
# roomstays = data.pop('roomStays', None)
|
|
||||||
# if roomstays:
|
|
||||||
# roomstays_ids = []
|
|
||||||
# for roomstay in roomstays:
|
|
||||||
# roomstay['bid'] = roomstay.pop('id')
|
|
||||||
|
|
||||||
# if roomstay.get('roomId', None):
|
|
||||||
# roomstay['roomId'] = self.env['exely.rooms'].search([('bid', '=', roomstay['roomId'])]).id
|
|
||||||
|
|
||||||
# guests = roomstay.pop('guestsIds', None)
|
|
||||||
|
|
||||||
# if guests:
|
|
||||||
# guest_ids = []
|
|
||||||
# for guest in guests:
|
|
||||||
# guest_data = self.get_guest_info(guest)
|
|
||||||
# guest_data['bid'] = guest_data.pop('id')
|
|
||||||
|
|
||||||
# if guest_data:
|
|
||||||
# if guest_data.get('emails', None):
|
|
||||||
# guest_data['emails'] = [(6, 0, [
|
|
||||||
# self.env['exely.email'].search([('email', '=', email)], limit=1).id or
|
|
||||||
# self.env['exely.email'].create({'email': email}).id
|
|
||||||
# for email in guest_data['emails']
|
|
||||||
# ])]
|
|
||||||
# if guest_data.get('phones', None):
|
|
||||||
# guest_data['phones'] = [(6, 0, [
|
|
||||||
# self.env['exely.phones'].search([('phone', '=', phone)], limit=1).id or
|
|
||||||
# self.env['exely.phones'].create({'phone': phone}).id
|
|
||||||
# for phone in guest_data['phones']
|
|
||||||
# ])]
|
|
||||||
|
|
||||||
# found_guest = self.env['exely.guests'].search([('bid', '=', guest)])
|
|
||||||
# if found_guest:
|
|
||||||
# guest_id = found_guest.id
|
|
||||||
# else:
|
|
||||||
# guest_id = self.env['exely.guests'].create(guest_data).id
|
|
||||||
# guest_ids.append(guest_id)
|
|
||||||
|
|
||||||
# if guest_ids:
|
|
||||||
# roomstay['guestsIds'] = [(6, 0, guest_ids)]
|
|
||||||
|
|
||||||
# amenities = roomstay.pop('amenities', None)
|
|
||||||
|
|
||||||
# if not amenities:
|
|
||||||
# amenity_ids = []
|
|
||||||
# for amenity in amenities:
|
|
||||||
# found_amenity = self.env['exely.amenities'].search([('name', '=', amenity)])
|
|
||||||
# if found_amenity:
|
|
||||||
# amenity_id = found_amenity.id
|
|
||||||
# else:
|
|
||||||
# amenity_id = self.env['exely.amenities'].create({'name': amenity}).id
|
|
||||||
# amenity_ids.append(amenity_id)
|
|
||||||
|
|
||||||
# if amenity_ids:
|
|
||||||
# roomstay['amenities'] = [(6, 0, amenity_ids)]
|
|
||||||
|
|
||||||
# found_roomstay = self.env['exely.roomstays'].search([('bid', '=', roomstay['bid'])])
|
|
||||||
# if found_roomstay:
|
|
||||||
# roomstay_id = found_roomstay.id
|
|
||||||
# else:
|
|
||||||
# roomstay_id = self.env['exely.roomstays'].create(roomstay).id
|
|
||||||
# roomstays_ids.append(roomstay_id)
|
|
||||||
|
|
||||||
# if roomstays_ids:
|
|
||||||
# data['roomStays'] = [(6, 0, roomstays_ids)]
|
|
||||||
|
|
||||||
# to_create.append(data)
|
|
||||||
# else:
|
|
||||||
# _logger.warning(f"Failed to retrieve data. Status code: {response.status_code}")
|
|
||||||
# # except Exception as e:
|
|
||||||
# # _logger.warning(f"Error processing data: {e}")
|
|
||||||
|
|
||||||
# if to_create:
|
|
||||||
# for i in to_create:
|
|
||||||
# try:
|
|
||||||
# self.env['exely.bookings'].create(i)
|
|
||||||
# except Exception as e:
|
|
||||||
# _logger.warning(f"##############################: {i}")
|
|
||||||
# break
|
|
||||||
# cr.commit()
|
|
||||||
|
|
||||||
|
|
||||||
# if to_create:
|
|
||||||
# self.env['exely.bookings'].create(to_create)
|
|
||||||
|
|
||||||
|
|
||||||
class HmsBookings(models.Model):
|
class HmsBookings(models.Model):
|
||||||
_inherit = 'hms.bookings'
|
_inherit = 'hms.bookings'
|
||||||
_description = 'Hms Bookings'
|
_description = 'Hms Bookings'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user