[ADD] Multile Customers

This commit is contained in:
Jose Luis
2019-04-02 11:15:51 +02:00
parent a525ac9984
commit e25f4b79eb
2 changed files with 40 additions and 35 deletions

View File

@@ -20,42 +20,44 @@ class HotelFolio(models.Model):
json_response = dict() json_response = dict()
# Need checkin? # Need checkin?
if reservation_rm.checkin_partner_pending_count > 0: if reservation_rm.checkin_partner_pending_count > 0 and len(stay["Customers"]) < reservation_rm.checkin_partner_pending_count:
checkin_partner_val = { # Debug Stop -------------------
'folio_id': reservation_rm.folio_id.id, # import wdb; wdb.set_trace()
'reservation_id': reservation_rm.id, # Debug Stop ------------------
'enter_date': datetime.strptime(stay["Arrival"], "%d%m%Y").date(), for room_partner in stay["Customers"]:
'exit_date': datetime.strptime(stay["Departure"], "%d%m%Y").date(), checkin_partner_val = {
'partner_id': stay["Customers"]["Customer"]["Id"], 'folio_id': reservation_rm.folio_id.id,
'email': stay["Customers"]["Customer"]["Contact"]["Email"], 'reservation_id': reservation_rm.id,
'mobile': stay["Customers"]["Customer"]["Contact"]["Mobile"], 'enter_date': datetime.strptime(stay["Arrival"], "%d%m%Y").date(),
'document_type': stay["Customers"]["Customer"]["IdentityDocument"]["Type"], 'exit_date': datetime.strptime(stay["Departure"], "%d%m%Y").date(),
'document_number': stay["Customers"]["Customer"]["IdentityDocument"]["Number"], 'partner_id': room_partner["Customer"]["Id"],
'document_expedition_date': datetime.strptime(stay["Customers"]["Customer"]["IdentityDocument"]["ExpiryDate"], "%d%m%Y").date(), 'email': room_partner["Customer"]["Contact"]["Email"],
'gender': stay["Customers"]["Customer"]["Sex"], 'mobile': room_partner["Customer"]["Contact"]["Mobile"],
'birthdate_date': datetime.strptime(stay["Customers"]["Customer"]["Birthday"], "%d%m%Y").date(), 'document_type': room_partner["Customer"]["IdentityDocument"]["Type"],
'code_ine_id': stay["Customers"]["Customer"]["Address"]["Province"], 'document_number': room_partner["Customer"]["IdentityDocument"]["Number"],
'state': 'booking', 'document_expedition_date': datetime.strptime(room_partner["Customer"]["IdentityDocument"]["ExpiryDate"], "%d%m%Y").date(),
} 'gender': room_partner["Customer"]["Sex"],
try: 'birthdate_date': datetime.strptime(room_partner["Customer"]["Birthday"], "%d%m%Y").date(),
# Debug Stop ------------------- 'code_ine_id': room_partner["Customer"]["Address"]["Province"],
#import wdb; wdb.set_trace() 'state': 'booking',
# Debug Stop ------------------ }
_logger.info('ROOMMATIK check-in Document: %s in (%s reservation_id).', try:
checkin_partner_val['document_number'], _logger.info('ROOMMATIK check-in Document: %s in (%s reservation_id).',
checkin_partner_val['reservation_id']) checkin_partner_val['document_number'],
json_response = {'Estate': 'O.K.'} checkin_partner_val['reservation_id'])
record = self.env['hotel.checkin.partner'].create(checkin_partner_val) json_response = {'Estate': 'O.K.'}
except: record = self.env['hotel.checkin.partner'].create(checkin_partner_val)
json_response = {'Estate': 'Error not create Checkin'} except:
_logger.error('ROOMMATIK writing %s in (%s reservation_id).', json_response = {'Estate': 'Error not create Checkin'}
checkin_partner_val['document_number'], _logger.error('ROOMMATIK writing %s in (%s reservation_id).',
checkin_partner_val['reservation_id']) checkin_partner_val['document_number'],
checkin_partner_val['reservation_id'])
return json_response
# ATENCION SI LO CREA, AUNQUE DA ERROR CUANDO ES LA MISMA PERSONA. # ATENCION SI LO CREA, AUNQUE DA ERROR CUANDO ES LA MISMA PERSONA.
else: else:
json_response = {'Estate': 'Error not create Checkin NO checkin_partner_pending_count'} json_response = {'Estate': 'Error checkin_partner_pending_count values do not match.'}
_logger.error('ROOMMATIK NO checkin pending count in Reservation ID %s.', reservation_rm.id) _logger.error('ROOMMATIK checkin pending count do not match for Reservation ID %s.', reservation_rm.id)
# stay1 = { # stay1 = {
# #
# "Id": 123, # "Id": 123,

View File

@@ -4,7 +4,8 @@
import json import json
from datetime import datetime from datetime import datetime
from odoo import api, models from odoo import api, models
import logging
_logger = logging.getLogger(__name__)
class RoomMatik(models.Model): class RoomMatik(models.Model):
_name = 'roommatik.api' _name = 'roommatik.api'
@@ -23,12 +24,14 @@ class RoomMatik(models.Model):
@api.model @api.model
def rm_add_customer(self, customer): def rm_add_customer(self, customer):
# RoomMatik API CREACIÓN DE CLIENTE # RoomMatik API CREACIÓN DE CLIENTE
_logger.info('ROOMMATIK Customer Creation')
apidata = self.env['res.partner'] apidata = self.env['res.partner']
return apidata.rm_add_customer(customer) return apidata.rm_add_customer(customer)
@api.model @api.model
def rm_checkin_partner(self, stay): def rm_checkin_partner(self, stay):
# RoomMatik API CHECK-IN # RoomMatik API CHECK-IN
_logger.info('ROOMMATIK Check-IN')
apidata = self.env['hotel.folio'] apidata = self.env['hotel.folio']
return apidata.rm_checkin_partner(stay) return apidata.rm_checkin_partner(stay)