[IMP] Roommatic checkin sistem

This commit is contained in:
Jose Luis
2019-04-03 14:40:47 +02:00
parent 70deef7ee6
commit d2095d2312
2 changed files with 36 additions and 40 deletions

View File

@@ -3,7 +3,7 @@
import json
from odoo import api, models
from datetime import date, datetime
from datetime import datetime
import logging
class HotelFolio(models.Model):
@@ -20,11 +20,16 @@ class HotelFolio(models.Model):
json_response = dict()
# Need checkin?
if reservation_rm.checkin_partner_pending_count > 0 and len(stay["Customers"]) < reservation_rm.checkin_partner_pending_count:
# Debug Stop -------------------
# import wdb; wdb.set_trace()
# Debug Stop ------------------
total_chekins = reservation_rm.checkin_partner_pending_count
if total_chekins > 0 and len(stay["Customers"]) <= total_chekins:
_logger.info('ROOMMATIK checkin %s customer in %s Reservation.', total_chekins, reservation_rm.id)
for room_partner in stay["Customers"]:
# ADD costumer ?
# costumer = self.env['res.partner'].rm_add_customer(room_partner["Customer"])
# Debug Stop -------------------
# import wdb; wdb.set_trace()
# Debug Stop ------------------
checkin_partner_val = {
'folio_id': reservation_rm.folio_id.id,
'reservation_id': reservation_rm.id,
@@ -42,11 +47,13 @@ class HotelFolio(models.Model):
'state': 'booking',
}
try:
_logger.info('ROOMMATIK check-in Document: %s in (%s reservation_id).',
checkin_partner_val['document_number'],
checkin_partner_val['reservation_id'])
json_response = {'Estate': 'O.K.'}
record = self.env['hotel.checkin.partner'].create(checkin_partner_val)
_logger.info('ROOMMATIK check-in Document: %s in (%s Reservation) ID:%s.',
checkin_partner_val['document_number'],
checkin_partner_val['reservation_id'],
record.id)
stay['Id'] = record.id
json_response = stay
except:
json_response = {'Estate': 'Error not create Checkin'}
_logger.error('ROOMMATIK writing %s in (%s reservation_id).',

View File

@@ -18,7 +18,7 @@ class ResPartner(models.Model):
partner_res = self.env['res.partner'].search([(
'document_number', '=',
customer['IdentityDocument'][0]['Number'])])
customer['IdentityDocument']['Number'])])
json_response = {'Id': 0}
if any(partner_res):
@@ -57,25 +57,21 @@ class ResPartner(models.Model):
'ZipCode': write_custumer.zip,
'City': write_custumer.city,
'Street': write_custumer.street,
'House': customer['IdentityDocument'][0][
'Address'][0]['House'],
'Flat': customer['IdentityDocument'][0][
'Address'][0]['Flat'],
'Number': customer['IdentityDocument'][0][
'Address'][0]['Number'],
'Province': customer['IdentityDocument'][0][
'Address'][0]['Province'],
'House': customer['Address']['House'],
'Flat': customer['Address']['Flat'],
'Number': customer['Address']['Number'],
'Province': customer['Address']['Province'],
},
'IdentityDocument': {
'Number': write_custumer.document_number,
'Type': write_custumer.document_type,
'ExpiryDate': customer[
'IdentityDocument'][0]['ExpiryDate'],
'IdentityDocument']['ExpiryDate'],
'ExpeditionDate': write_custumer.document_expedition_date,
},
'Contact': {
'Telephone': write_custumer.phone,
'Fax': customer['Contact'][0]['Fax'],
'Fax': customer['Contact']['Fax'],
'Mobile': write_custumer.mobile,
'Email': write_custumer.email,
}
@@ -90,15 +86,11 @@ class ResPartner(models.Model):
customer['Sex'] = ''
# Check state_id
city_srch = self.env['res.country.state'].search([
('name', 'ilike', customer['IdentityDocument'][0][
'Address'][0]['Province'])])
('name', 'ilike', customer['Address']['Province'])])
# Create Street2
street_2 = '' + customer['IdentityDocument'][0][
'Address'][0]['House']
street_2 += ', ' + customer['IdentityDocument'][0][
'Address'][0]['Flat']
street_2 += ', ' + customer['IdentityDocument'][0][
'Address'][0]['Number']
street_2 = '' + customer['Address']['House']
street_2 += ', ' + customer['Address']['Flat']
street_2 += ', ' + customer['Address']['Number']
return {
'firstname': customer['FirstName'],
'lastname': customer['LastName1'],
@@ -106,20 +98,17 @@ class ResPartner(models.Model):
'birthdate_date': datetime.strptime(customer['Birthday'],
"%d%m%Y").date(),
'gender': customer['Sex'],
'zip': customer['IdentityDocument'][0][
'Address'][0]['ZipCode'],
'city': customer['IdentityDocument'][0][
'Address'][0]['City'],
'street': customer['IdentityDocument'][0][
'Address'][0]['Street'],
'zip': customer['Address']['ZipCode'],
'city': customer['Address']['City'],
'street': customer['Address']['Street'],
'street2': street_2,
'state_id': city_srch.id,
'phone': customer['Contact'][0]['Telephone'],
'mobile': customer['Contact'][0]['Mobile'],
'email': customer['Contact'][0]['Email'],
'document_number': customer['IdentityDocument'][0]['Number'],
'document_type': customer['IdentityDocument'][0]['Type'],
'phone': customer['Contact']['Telephone'],
'mobile': customer['Contact']['Mobile'],
'email': customer['Contact']['Email'],
'document_number': customer['IdentityDocument']['Number'],
'document_type': customer['IdentityDocument']['Type'],
'document_expedition_date': datetime.strptime(customer[
'IdentityDocument'][0]['ExpeditionDate'],
'IdentityDocument']['ExpeditionDate'],
"%d%m%Y").date(),
}