fix migrations report and guest creation

This commit is contained in:
wilson gomez sanchez 2021-03-27 09:35:46 -05:00
parent ed8185e413
commit 1b6fae6152
11 changed files with 1310 additions and 27 deletions

View File

@ -742,9 +742,9 @@ class BookingLine(ModelSQL, ModelView):
guests = fields.One2Many('hotel.booking.guest', 'booking_line', 'Guests')
operation = fields.Many2One('hotel.operation', 'Operation')
nationality = fields.Many2One('party.nationality', 'Nationality')
origin_city = fields.Many2One('hotel.migration_city', 'Origin City',
origin_country = fields.Many2One('party.nationality', 'Origin Country',
select=True)
target_city = fields.Many2One('hotel.migration_city', 'Target City',
target_country = fields.Many2One('party.nationality', 'Target Country',
select=True)
registration_state = fields.Selection(REGISTRATION_STATE, 'State Registration',
readonly=True)
@ -1181,9 +1181,9 @@ class Guest(ModelSQL, ModelView):
], 'Type Guest')
type_guest_string = type_guest.translated('type_guest')
nationality = fields.Many2One('party.nationality', 'Nationality')
origin_city = fields.Many2One('hotel.migration_city', 'Origin City',
origin_country = fields.Many2One('party.nationality', 'Origin Country',
select=True)
target_city = fields.Many2One('hotel.migration_city', 'Target City',
target_country = fields.Many2One('party.nationality', 'Target Country',
select=True)
# New fields for speed reason
@ -1204,6 +1204,40 @@ class Guest(ModelSQL, ModelView):
('male', 'Male'),
('', ''),
], 'Sex')
first_name = fields.Char('First Name')
second_name = fields.Char('Second Name')
first_family_name = fields.Char('First Family Name')
second_family_name = fields.Char('Second Family Name')
type_person = fields.Selection([
('persona_natural', 'Persona Natural'),
('persona_juridica', 'Persona Juridica'),
], 'Type Person')
@fields.depends('name', 'first_name', 'second_name',
'first_family_name', 'second_family_name', 'type_person')
def on_change_name(self):
second_family_name = None
first_family_name = None
second_name = None
first_name = None
if self.name and self.type_person == 'persona_natural':
names = self.name.split(' ')
first_name = names[0]
second_family_name = names[-1]
if len(names) > 1:
first_family_name = names[-2]
if len(names) == 2:
second_family_name = None
first_family_name = names[1]
elif len(names) == 5:
second_name = names[1] + ' ' + names[2]
elif len(names) == 4:
second_name = names[1]
self.second_family_name = second_family_name
self.first_family_name = first_family_name
self.second_name = second_name
self.first_name = first_name
def get_rec_name(self, name):
if self.party:
@ -1217,6 +1251,10 @@ class Guest(ModelSQL, ModelView):
def default_sex():
return 'male'
@staticmethod
def default_type_person():
return 'persona_natural'
@staticmethod
def default_type_document():
return '13'
@ -1225,10 +1263,11 @@ class Guest(ModelSQL, ModelView):
def default_principal_guest():
return False
@fields.depends('origin_city', 'target_city')
def on_change_origin_city(self):
if self.origin_city:
self.target_city = self.origin_city.id
@fields.depends('nationality', 'origin_country', 'target_country')
def on_change_nationality(self):
if self.nationality:
self.target_country = self.nationality.id
self.origin_country = self.nationality.id
@classmethod
def create(cls, vlist):
@ -1251,6 +1290,11 @@ class Guest(ModelSQL, ModelView):
'type_document': v['type_document'],
'birthday': v['birthday'],
'sex': v['sex'],
'first_name': v['first_name'],
'second_name': v['second_name'],
'first_family_name': v['first_family_name'],
'second_family_name': v['second_family_name'],
'type_person': v['type_person'],
'contact_mechanisms': [
('create', [
{'type': 'email', 'value': v['email']},

View File

@ -4,10 +4,11 @@ from trytond.model import ModelView, ModelSQL, fields
__all__ = ['MigrationCity']
class MigrationCity(ModelSQL, ModelView):
"Migration City"
__name__ = "hotel.migration_city"
_rec_name = 'name'
_rec_name = 'name'
name = fields.Char('Name', required=True)
code = fields.Char('Code')

1123
code_city_migrations.csv Normal file

File diff suppressed because it is too large Load Diff

BIN
code_city_migrations.ods Normal file

Binary file not shown.

Binary file not shown.

View File

@ -7,7 +7,7 @@ from trytond.wizard import Wizard, StateView, Button, StateTransition, StateRepo
from trytond.transaction import Transaction
__all__ = ['Party','CreateGuest','CreateGuestStart']
__all__ = ['Party', 'CreateGuest', 'CreateGuestStart']
TYPE = [
@ -50,12 +50,75 @@ class Party(metaclass=PoolMeta):
visa_number = fields.Char('Visa Number')
visa_date = fields.Date('Visa Date')
class CreateGuestStart(ModelView):
'Create Party to Guest Start'
__name__ = 'hotel.party.guest.start'
name = fields.Char('Name', required=True)
full_name = fields.Char('Name')
first_name = fields.Char('First Name')
second_name = fields.Char('Second Name')
first_family_name = fields.Char('First Family Name')
second_family_name = fields.Char('Second Family Name')
type_document = fields.Selection(TYPE_DOCUMENT, 'Type Document')
id_number = fields.Char('Id Number')
type_document = fields.Selection([
('12', 'Tarjeta de Identidad'),
('13', 'Cedula de Ciudadania'),
('21', 'Tarjeta de Extranjeria'),
('22', 'Cedula de Extranjeria'),
('41', 'Pasaporte'),
], 'Document Type')
mobile = fields.Char('Mobile', select=True)
email = fields.Char('Email', select=True)
birthday = fields.Date('Birthday', select=True)
sex = fields.Selection([
('female', 'Female'),
('male', 'Male'),
('', ''),
], 'Sex')
type_person = fields.Selection([
('persona_natural', 'Persona Natural'),
('persona_juridica', 'Persona Juridica'),
], 'Type Person')
@fields.depends('full_name', 'first_name', 'second_name',
'first_family_name', 'second_family_name','type_person')
def on_change_full_name(self):
second_family_name = None
first_family_name = None
second_name = None
first_name = None
if self.full_name and self.type_person == 'persona_natural':
names = self.full_name.split(' ')
first_name = names[0]
second_family_name = names[-1]
if len(names) > 1:
first_family_name = names[-2]
if len(names) == 2:
second_family_name = None
first_family_name = names[1]
elif len(names) == 5:
second_name = names[1] + ' ' + names[2]
elif len(names) == 4:
second_name = names[1]
self.second_family_name = second_family_name
self.first_family_name = first_family_name
self.second_name = second_name
self.first_name = first_name
@staticmethod
def default_sex():
return 'male'
@staticmethod
def default_type_person():
return 'persona_natural'
@staticmethod
def default_type_document():
return '13'
class CreateGuest(Wizard):
'Create Party to Guest'
@ -86,11 +149,23 @@ class CreateGuest(Wizard):
else:
party, = Party.create([{
'name': self.start.name,
'id_number': self.start.id_number,
'type_document': self.start.type_document,
'id_number': self.start.id_number
'birthday': self.start.birthday,
'sex': self.start.sex,
'first_name': self.start.first_name,
'second_name': self.start.second_name,
'first_family_name': self.start.first_family_name,
'second_family_name': self.start.second_family_name,
'contact_mechanisms': [
('create', [
{'type': 'email', 'value': self.start.email},
{'type': 'mobile', 'value': self.start.mobile},
])
]
}])
party.save()
Booking.write([record], {'party': party})
party_id = party.id
Booking.write([record], {'party': party_id})
return 'end'
def get_message(self, message):

View File

@ -24,10 +24,10 @@ this repository contains the full copyright notices and license terms. -->
<field name="total_commission"/>
<label name="nationality"/>
<field name="nationality"/>
<label name="origin_city"/>
<field name="origin_city"/>
<label name="target_city"/>
<field name="target_city"/>
<label name="origin_country"/>
<field name="origin_country"/>
<label name="target_country"/>
<field name="target_country"/>
<label name="operation"/>
<field name="operation"/>
<field name="guests" colspan="4"/>

View File

@ -3,7 +3,7 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="product"/>
<button name="check_in" string="Check In" type="object"/>
<button name="check_in" string="Check In" />
<button name="check_out" string="Check Out"/>
<field name="main_guest"/>
<field name="room"/>

View File

@ -2,6 +2,10 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="type_person"/>
<field name="type_person"/>
<label name="type_document"/>
<field name="type_document"/>
<label name="name"/>
<field name="name"/>
<label name="party"/>
@ -20,8 +24,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="type_guest"/>
<label name="birthday"/>
<field name="birthday"/>
<label name="origin_city"/>
<field name="origin_city"/>
<label name="target_city"/>
<field name="target_city"/>
<label name="origin_country"/>
<field name="origin_country"/>
<label name="target_country"/>
<field name="target_country"/>
<label name="first_name"/>
<field name="first_name"/>
<label name="second_name"/>
<field name="second_name"/>
<label name="first_family_name"/>
<field name="first_family_name"/>
<label name="second_family_name"/>
<field name="second_family_name"/>
</form>

View File

@ -3,13 +3,19 @@
this repository contains the full copyright notices and license terms. -->
<tree editable="top">
<field name="party"/>
<field name="name"/>
<field name="type_document"/>
<field name="name"/>
<field name="doc_number"/>
<field name="mobile"/>
<field name="email"/>
<field name="nationality"/>
<field name="birthday"/>
<field name="origin_country"/>
<field name="target_country"/>
<field name="sex"/>
<field name="type_guest"/>
<field name="birthday"/>
<field name="first_name"/>
<field name="second_name"/>
<field name="first_family_name"/>
<field name="second_family_name"/>
</tree>

View File

@ -2,10 +2,32 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<form>
<label name="name"/>
<field name="name"/>
<label name="full_name"/>
<field name="full_name"/>
<label name="type_document"/>
<field name="type_document"/>
<label name="id_number"/>
<field name="id_number"/>
<label name="mobile"/>
<field name="mobile"/>
<label name="email"/>
<field name="email"/>
<label name="birthday"/>
<field name="birthday"/>
<label name="sex"/>
<field name="sex"/>
<label name="type_person"/>
<field name="type_person"/>
<group colspan="4" col="8" id="names">
<separator string="Names" colspan="4" id="names"/>
<newline/>
<label name="first_name"/>
<field name="first_name"/>
<label name="second_name"/>
<field name="second_name"/>
<label name="first_family_name"/>
<field name="first_family_name"/>
<label name="second_family_name"/>
<field name="second_family_name"/>
</group>
</form>