This commit is contained in:
parent
1018350c76
commit
92b2f180f5
2
bross.py
2
bross.py
@ -45,7 +45,7 @@ headers = {
|
|||||||
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/guests/9007199255607320/room-stays", headers=headers)
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/guests/9007199255607320/room-stays", headers=headers)
|
||||||
|
|
||||||
# ALL ROOMS
|
# 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)
|
# response = requests.get("https://connect.hopenapi.com/api/exelypms/v1/rooms?roomTypeId=5020078", headers=headers)
|
||||||
|
|||||||
@ -11,5 +11,16 @@
|
|||||||
<field name="active" eval="False"/>
|
<field name="active" eval="False"/>
|
||||||
<field name="priority">100</field>
|
<field name="priority">100</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="ir_cron_process_movements_data" model="ir.cron">
|
||||||
|
<field name="name">Process Movements Data</field>
|
||||||
|
<field name="model_id" ref="model_bank_raw_movements"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.process_movements()</field>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="priority">100</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@ -4,6 +4,7 @@ from odoo import models, fields, _
|
|||||||
class BrosseBankAccount(models.Model):
|
class BrosseBankAccount(models.Model):
|
||||||
_name = 'brosse.bank.account'
|
_name = 'brosse.bank.account'
|
||||||
_description = 'Bank Account'
|
_description = 'Bank Account'
|
||||||
|
_rec_name = 'account_number'
|
||||||
|
|
||||||
account_number = fields.Char(string='Account Number', required=True)
|
account_number = fields.Char(string='Account Number', required=True)
|
||||||
holder_name = fields.Char(string='Holder Name')
|
holder_name = fields.Char(string='Holder Name')
|
||||||
|
|||||||
@ -7,3 +7,5 @@ class BrosseBankDeposits(models.Model):
|
|||||||
|
|
||||||
amount = fields.Monetary(string="Amount", currency_field='currency_id')
|
amount = fields.Monetary(string="Amount", currency_field='currency_id')
|
||||||
currency_id = fields.Many2one('res.currency', string='Account Currency')
|
currency_id = fields.Many2one('res.currency', string='Account Currency')
|
||||||
|
|
||||||
|
bank_account_id = fields.Many2one('brosse.bank.account', string="Bank Account")
|
||||||
|
|||||||
@ -2,12 +2,36 @@ import base64
|
|||||||
import tempfile
|
import tempfile
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
import math
|
||||||
import os
|
import os
|
||||||
from odoo import models, fields, _
|
from odoo import models, fields, _
|
||||||
from tbc_bank_integration_service_lib.client import TBCBankClient
|
from tbc_bank_integration_service_lib.client import TBCBankClient
|
||||||
from odoo.exceptions import UserError
|
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):
|
class BankMovements(models.Model):
|
||||||
_name = 'bank.raw.movements'
|
_name = 'bank.raw.movements'
|
||||||
_description = 'Bank Movements'
|
_description = 'Bank Movements'
|
||||||
@ -46,12 +70,62 @@ class BankMovements(models.Model):
|
|||||||
'json_hash_code': hash_hex,
|
'json_hash_code': hash_hex,
|
||||||
'bid': bid
|
'bid': bid
|
||||||
})
|
})
|
||||||
|
|
||||||
def get_movements(self):
|
def get_movements(self):
|
||||||
client = self.env['bank.settings'].get_request_object()
|
client = self.env['bank.settings'].get_request_object()
|
||||||
try:
|
res = client.get_account_movements_by_date_range('111111', '2024-01-01T00:00:00.000', '2024-10-01T00:00:00.000')
|
||||||
movement_id = '013762510743.2'
|
self.create_or_update_raw_data(res, 'bank.raw.movements', res['data'])
|
||||||
movements_by_id = client.get_account_movements_by_id('111111', movement_id)
|
pages = math.ceil(int(res['data']['pager']['totalcount']) / int(res['data']['pager']['pagesize']))
|
||||||
self.create_or_update_raw_data(movements_by_id, 'bank.raw.movements', movements_by_id['data'].get('movementId'))
|
if pages > 1:
|
||||||
except Exception as e:
|
for page in range(1, pages):
|
||||||
_logger.error(e)
|
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'))
|
||||||
|
|
||||||
@ -5,6 +5,7 @@
|
|||||||
<field name="model">brosse.bank.deposits</field>
|
<field name="model">brosse.bank.deposits</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<list string="Bank Deposits" editable="bottom">
|
<list string="Bank Deposits" editable="bottom">
|
||||||
|
<field name="bank_account_id"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
<field name="currency_id" invisible='1'/>
|
<field name="currency_id" invisible='1'/>
|
||||||
</list>
|
</list>
|
||||||
|
|||||||
@ -12,15 +12,20 @@
|
|||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
# 'cron/crons.xml',
|
# 'cron/crons.xml',
|
||||||
|
'data/service_kinds.xml',
|
||||||
'views/misc_menus.xml',
|
'views/misc_menus.xml',
|
||||||
'views/main_menus.xml',
|
'views/main_menus.xml',
|
||||||
'views/emails.xml',
|
'views/emails.xml',
|
||||||
'views/phones.xml',
|
'views/phones.xml',
|
||||||
'views/customers.xml',
|
'views/customers.xml',
|
||||||
'views/rooms.xml',
|
'views/rooms.xml',
|
||||||
|
'views/room_types.xml',
|
||||||
|
'views/floor.xml',
|
||||||
|
'views/services.xml',
|
||||||
'views/guests.xml',
|
'views/guests.xml',
|
||||||
'views/amenities.xml',
|
'views/amenities.xml',
|
||||||
'views/roomstays.xml',
|
'views/roomstays.xml',
|
||||||
|
'views/agents.xml',
|
||||||
'views/bookings.xml',
|
'views/bookings.xml',
|
||||||
'views/status.xml',
|
'views/status.xml',
|
||||||
],
|
],
|
||||||
|
|||||||
62
bross_hms/data/service_kinds.xml
Normal file
62
bross_hms/data/service_kinds.xml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data noupdate="1">
|
||||||
|
<record id="service_kind_0" model="hms.service.kinds">
|
||||||
|
<field name="name">accommodation</field>
|
||||||
|
<field name="hms_id">0</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_kind_1" model="hms.service.kinds">
|
||||||
|
<field name="name">extra service</field>
|
||||||
|
<field name="hms_id">1</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_kind_2" model="hms.service.kinds">
|
||||||
|
<field name="name">transfer</field>
|
||||||
|
<field name="hms_id">2</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_kind_3" model="hms.service.kinds">
|
||||||
|
<field name="name">early check-in</field>
|
||||||
|
<field name="hms_id">3</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_kind_4" model="hms.service.kinds">
|
||||||
|
<field name="name">late check-out</field>
|
||||||
|
<field name="hms_id">4</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="service_vat_kind_0" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">not subject to VAT</field>
|
||||||
|
<field name="hms_id">0</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_1" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 0% VAT</field>
|
||||||
|
<field name="hms_id">1</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_2" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 10% VAT</field>
|
||||||
|
<field name="hms_id">2</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_3" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 18% VAT</field>
|
||||||
|
<field name="hms_id">3</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_4" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 10/110 VAT</field>
|
||||||
|
<field name="hms_id">4</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_5" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 18/118 VAT</field>
|
||||||
|
<field name="hms_id">5</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_6" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 20/120 VAT</field>
|
||||||
|
<field name="hms_id">6</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_7" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 20% VAT</field>
|
||||||
|
<field name="hms_id">7</field>
|
||||||
|
</record>
|
||||||
|
<record id="service_vat_kind_8" model="hms.service.vat.kinds">
|
||||||
|
<field name="name">subject to 12% VAT</field>
|
||||||
|
<field name="hms_id">8</field>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -1,3 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from . import hms_data
|
from . import hms_models
|
||||||
|
|||||||
@ -51,8 +51,26 @@ class HmsRooms(models.Model):
|
|||||||
|
|
||||||
bid = fields.Char(string="Room ID", index=True)
|
bid = fields.Char(string="Room ID", index=True)
|
||||||
name = fields.Char(string="Name")
|
name = fields.Char(string="Name")
|
||||||
roomTypeId = fields.Char(string="Room Type ID")
|
roomTypeId = fields.Many2one(comodel_name="hms.room.types", string="Room Type")
|
||||||
floorId = fields.Char(string="Floor ID")
|
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):
|
class HmsGuests(models.Model):
|
||||||
@ -88,14 +106,14 @@ class HmsRoomStays(models.Model):
|
|||||||
bid = fields.Char(string="Room raw ID", index=True)
|
bid = fields.Char(string="Room raw ID", index=True)
|
||||||
bookingId = fields.Char(string="Booking ID", index=True)
|
bookingId = fields.Char(string="Booking ID", index=True)
|
||||||
roomId = fields.Many2one(comodel_name="hms.rooms", string="Room ID")
|
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")
|
guestsIds = fields.Many2many(comodel_name="hms.guests", string="Guests Ids")
|
||||||
checkInDateTime = fields.Char(string="Check In Date Time")
|
checkInDateTime = fields.Char(string="Check In Date Time")
|
||||||
checkOutDateTime = fields.Char(string="Check Out Date Time")
|
checkOutDateTime = fields.Char(string="Check Out Date Time")
|
||||||
actualCheckInDateTime = fields.Char(string="Actual Check In Date Time")
|
actualCheckInDateTime = fields.Char(string="Actual Check In Date Time")
|
||||||
actualCheckOutDateTime = fields.Char(string="Actual Check Out Date Time")
|
actualCheckOutDateTime = fields.Char(string="Actual Check Out Date Time")
|
||||||
status = fields.Char(string="Status")
|
status = fields.Many2one(comodel_name="hms.status", string="Status")
|
||||||
bookingStatus = fields.Char(string="Booking Status")
|
bookingStatus = fields.Many2one(comodel_name="hms.booking.status", string="Booking Status")
|
||||||
guestCountInfo = fields.Json(string="Guest Count Info")
|
guestCountInfo = fields.Json(string="Guest Count Info")
|
||||||
totalPrice = fields.Json(string="Total Price")
|
totalPrice = fields.Json(string="Total Price")
|
||||||
amenities = fields.Many2many(comodel_name="hms.amenities", string="Amenities")
|
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")
|
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):
|
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")
|
roomStays = fields.One2many(comodel_name="hms.roomstays", inverse_name="bookings_id", string="RoomStays")
|
||||||
customerCompany = fields.Json(string="Customer Company")
|
customerCompany = fields.Json(string="Customer Company")
|
||||||
source = fields.Json(string="RoomStays (Json)")
|
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):
|
class HmsStatus(models.Model):
|
||||||
@ -136,4 +160,57 @@ class HmsBookingStatus(models.Model):
|
|||||||
_name = 'hms.booking.status'
|
_name = 'hms.booking.status'
|
||||||
_description = 'Hms Booking Status'
|
_description = 'Hms Booking Status'
|
||||||
|
|
||||||
name = fields.Char(string="Booking Status", required=True)
|
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")
|
||||||
@ -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_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_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_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_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_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_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_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
|
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
|
||||||
|
27
bross_hms/views/agents.xml
Normal file
27
bross_hms/views/agents.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_agents_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Agents</field>
|
||||||
|
<field name="model">hms.agents</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_agents_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Agents</field>
|
||||||
|
<field name="res_model">hms.agents</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first amenity record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_agents" name="Agents" parent="customers_and_partners_root_menu" sequence="50" action="action_hms_agents_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -22,6 +22,6 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_amenities" name="Amenities" parent="property_management_root_menu" sequence="30" action="action_hms_amenities_action"/>
|
<menuitem id="menu_hms_amenities" name="Amenities" parent="property_management_root_menu" sequence="60" action="action_hms_amenities_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
28
bross_hms/views/floor.xml
Normal file
28
bross_hms/views/floor.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_floors_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Floor</field>
|
||||||
|
<field name="model">hms.floors</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="bid"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_floors_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Floor</field>
|
||||||
|
<field name="res_model">hms.floors</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first floor record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_floors" name="Floor" parent="property_management_root_menu" sequence="40" action="action_hms_floors_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
28
bross_hms/views/room_types.xml
Normal file
28
bross_hms/views/room_types.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_room_types_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Room Types</field>
|
||||||
|
<field name="model">hms.room.types</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="bid"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_room_types_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Room Types</field>
|
||||||
|
<field name="res_model">hms.room.types</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first room type record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_room_types" name="Room Types" parent="property_management_root_menu" sequence="30" action="action_hms_room_types_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="70" 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="40" action="action_hms_roomstays_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
28
bross_hms/views/services.xml
Normal file
28
bross_hms/views/services.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_hms_services_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Floor</field>
|
||||||
|
<field name="model">hms.services</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<list>
|
||||||
|
<field name="bid"/>
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_hms_services_action" model="ir.actions.act_window">
|
||||||
|
<field name="name">Floor</field>
|
||||||
|
<field name="res_model">hms.services</field>
|
||||||
|
<field name="view_mode">list</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
Create your first service record.
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="menu_hms_services" name="Services" parent="property_management_root_menu" sequence="50" action="action_hms_services_action"/>
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<menuitem id="menu_hms_status" name="Status" parent="property_management_root_menu" sequence="40" action="action_hms_status_action"/>
|
<menuitem id="menu_hms_status" name="Status" parent="property_management_root_menu" sequence="70" 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="50" action="action_hms_booking_status_action"/>
|
<menuitem id="menu_hms_booking_status" name="Booking Status" parent="property_management_root_menu" sequence="80" action="action_hms_booking_status_action"/>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@ -33,5 +33,16 @@
|
|||||||
<field name="active" eval="False"/>
|
<field name="active" eval="False"/>
|
||||||
<field name="priority">100</field>
|
<field name="priority">100</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="ir_cron_process_exely_payments" model="ir.cron">
|
||||||
|
<field name="name">Process Exely Payments</field>
|
||||||
|
<field name="model_id" ref="model_exely_modified_bookings"/>
|
||||||
|
<field name="state">code</field>
|
||||||
|
<field name="code">model.process_exely_payments()</field>
|
||||||
|
<field name="user_id" ref="base.user_root"/>
|
||||||
|
<field name="interval_number">1</field>
|
||||||
|
<field name="active" eval="False"/>
|
||||||
|
<field name="priority">100</field>
|
||||||
|
</record>
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
@ -190,6 +190,68 @@ class ExelyModifiedData(models.Model):
|
|||||||
if payments:
|
if payments:
|
||||||
self.create_or_update_raw_data(payments, 'exely.raw.payments', f"{start}{end}")
|
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):
|
def get_exely_data(self):
|
||||||
exely_api_conf = self.env['exely.api.conf'].search([], limit=1)
|
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)
|
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)
|
self.create_or_update_raw_data(guest, 'exely.raw.guests', bid)
|
||||||
## break
|
|
||||||
|
|
||||||
def process_exely_data(self):
|
def process_exely_data(self):
|
||||||
found_booking_record = self.env['hms.bookings'].search([], order="write_date desc", limit=1)
|
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:
|
for roomstay in roomstays:
|
||||||
roomstay['bid'] = roomstay.pop('id')
|
roomstay['bid'] = roomstay.pop('id')
|
||||||
|
|
||||||
if roomstay.get('roomId', None):
|
status = roomstay.pop('status', None)
|
||||||
roomstay['roomId'] = self.env['hms.rooms'].search([('bid', '=', roomstay['roomId'])]).id
|
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)
|
guests = roomstay.pop('guestsIds', None)
|
||||||
|
|
||||||
if guests:
|
if guests:
|
||||||
@ -363,6 +473,15 @@ class ExelyModifiedData(models.Model):
|
|||||||
if roomstays_ids:
|
if roomstays_ids:
|
||||||
data['roomStays'] = [(6, 0, 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)
|
to_create.append(data)
|
||||||
|
|
||||||
if to_create:
|
if to_create:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user