fix migrations report and guest creation
This commit is contained in:
parent
ed8185e413
commit
1b6fae6152
60
booking.py
60
booking.py
|
@ -742,9 +742,9 @@ class BookingLine(ModelSQL, ModelView):
|
||||||
guests = fields.One2Many('hotel.booking.guest', 'booking_line', 'Guests')
|
guests = fields.One2Many('hotel.booking.guest', 'booking_line', 'Guests')
|
||||||
operation = fields.Many2One('hotel.operation', 'Operation')
|
operation = fields.Many2One('hotel.operation', 'Operation')
|
||||||
nationality = fields.Many2One('party.nationality', 'Nationality')
|
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)
|
select=True)
|
||||||
target_city = fields.Many2One('hotel.migration_city', 'Target City',
|
target_country = fields.Many2One('party.nationality', 'Target Country',
|
||||||
select=True)
|
select=True)
|
||||||
registration_state = fields.Selection(REGISTRATION_STATE, 'State Registration',
|
registration_state = fields.Selection(REGISTRATION_STATE, 'State Registration',
|
||||||
readonly=True)
|
readonly=True)
|
||||||
|
@ -1181,9 +1181,9 @@ class Guest(ModelSQL, ModelView):
|
||||||
], 'Type Guest')
|
], 'Type Guest')
|
||||||
type_guest_string = type_guest.translated('type_guest')
|
type_guest_string = type_guest.translated('type_guest')
|
||||||
nationality = fields.Many2One('party.nationality', 'Nationality')
|
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)
|
select=True)
|
||||||
target_city = fields.Many2One('hotel.migration_city', 'Target City',
|
target_country = fields.Many2One('party.nationality', 'Target Country',
|
||||||
select=True)
|
select=True)
|
||||||
|
|
||||||
# New fields for speed reason
|
# New fields for speed reason
|
||||||
|
@ -1204,6 +1204,40 @@ class Guest(ModelSQL, ModelView):
|
||||||
('male', 'Male'),
|
('male', 'Male'),
|
||||||
('', ''),
|
('', ''),
|
||||||
], 'Sex')
|
], '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):
|
def get_rec_name(self, name):
|
||||||
if self.party:
|
if self.party:
|
||||||
|
@ -1217,6 +1251,10 @@ class Guest(ModelSQL, ModelView):
|
||||||
def default_sex():
|
def default_sex():
|
||||||
return 'male'
|
return 'male'
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_type_person():
|
||||||
|
return 'persona_natural'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default_type_document():
|
def default_type_document():
|
||||||
return '13'
|
return '13'
|
||||||
|
@ -1225,10 +1263,11 @@ class Guest(ModelSQL, ModelView):
|
||||||
def default_principal_guest():
|
def default_principal_guest():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@fields.depends('origin_city', 'target_city')
|
@fields.depends('nationality', 'origin_country', 'target_country')
|
||||||
def on_change_origin_city(self):
|
def on_change_nationality(self):
|
||||||
if self.origin_city:
|
if self.nationality:
|
||||||
self.target_city = self.origin_city.id
|
self.target_country = self.nationality.id
|
||||||
|
self.origin_country = self.nationality.id
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, vlist):
|
def create(cls, vlist):
|
||||||
|
@ -1251,6 +1290,11 @@ class Guest(ModelSQL, ModelView):
|
||||||
'type_document': v['type_document'],
|
'type_document': v['type_document'],
|
||||||
'birthday': v['birthday'],
|
'birthday': v['birthday'],
|
||||||
'sex': v['sex'],
|
'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': [
|
'contact_mechanisms': [
|
||||||
('create', [
|
('create', [
|
||||||
{'type': 'email', 'value': v['email']},
|
{'type': 'email', 'value': v['email']},
|
||||||
|
|
3
city.py
3
city.py
|
@ -4,10 +4,11 @@ from trytond.model import ModelView, ModelSQL, fields
|
||||||
|
|
||||||
__all__ = ['MigrationCity']
|
__all__ = ['MigrationCity']
|
||||||
|
|
||||||
|
|
||||||
class MigrationCity(ModelSQL, ModelView):
|
class MigrationCity(ModelSQL, ModelView):
|
||||||
"Migration City"
|
"Migration City"
|
||||||
__name__ = "hotel.migration_city"
|
__name__ = "hotel.migration_city"
|
||||||
_rec_name = 'name'
|
_rec_name = 'name'
|
||||||
name = fields.Char('Name', required=True)
|
name = fields.Char('Name', required=True)
|
||||||
code = fields.Char('Code')
|
code = fields.Char('Code')
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
85
party.py
85
party.py
|
@ -7,7 +7,7 @@ from trytond.wizard import Wizard, StateView, Button, StateTransition, StateRepo
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['Party','CreateGuest','CreateGuestStart']
|
__all__ = ['Party', 'CreateGuest', 'CreateGuestStart']
|
||||||
|
|
||||||
|
|
||||||
TYPE = [
|
TYPE = [
|
||||||
|
@ -50,12 +50,75 @@ class Party(metaclass=PoolMeta):
|
||||||
visa_number = fields.Char('Visa Number')
|
visa_number = fields.Char('Visa Number')
|
||||||
visa_date = fields.Date('Visa Date')
|
visa_date = fields.Date('Visa Date')
|
||||||
|
|
||||||
|
|
||||||
class CreateGuestStart(ModelView):
|
class CreateGuestStart(ModelView):
|
||||||
'Create Party to Guest Start'
|
'Create Party to Guest Start'
|
||||||
__name__ = 'hotel.party.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')
|
type_document = fields.Selection(TYPE_DOCUMENT, 'Type Document')
|
||||||
id_number = fields.Char('Id Number')
|
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):
|
class CreateGuest(Wizard):
|
||||||
'Create Party to Guest'
|
'Create Party to Guest'
|
||||||
|
@ -86,11 +149,23 @@ class CreateGuest(Wizard):
|
||||||
else:
|
else:
|
||||||
party, = Party.create([{
|
party, = Party.create([{
|
||||||
'name': self.start.name,
|
'name': self.start.name,
|
||||||
|
'id_number': self.start.id_number,
|
||||||
'type_document': self.start.type_document,
|
'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()
|
party_id = party.id
|
||||||
Booking.write([record], {'party': party})
|
Booking.write([record], {'party': party_id})
|
||||||
return 'end'
|
return 'end'
|
||||||
|
|
||||||
def get_message(self, message):
|
def get_message(self, message):
|
||||||
|
|
|
@ -24,10 +24,10 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="total_commission"/>
|
<field name="total_commission"/>
|
||||||
<label name="nationality"/>
|
<label name="nationality"/>
|
||||||
<field name="nationality"/>
|
<field name="nationality"/>
|
||||||
<label name="origin_city"/>
|
<label name="origin_country"/>
|
||||||
<field name="origin_city"/>
|
<field name="origin_country"/>
|
||||||
<label name="target_city"/>
|
<label name="target_country"/>
|
||||||
<field name="target_city"/>
|
<field name="target_country"/>
|
||||||
<label name="operation"/>
|
<label name="operation"/>
|
||||||
<field name="operation"/>
|
<field name="operation"/>
|
||||||
<field name="guests" colspan="4"/>
|
<field name="guests" colspan="4"/>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree>
|
<tree>
|
||||||
<field name="product"/>
|
<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"/>
|
<button name="check_out" string="Check Out"/>
|
||||||
<field name="main_guest"/>
|
<field name="main_guest"/>
|
||||||
<field name="room"/>
|
<field name="room"/>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<form>
|
<form>
|
||||||
|
<label name="type_person"/>
|
||||||
|
<field name="type_person"/>
|
||||||
|
<label name="type_document"/>
|
||||||
|
<field name="type_document"/>
|
||||||
<label name="name"/>
|
<label name="name"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<label name="party"/>
|
<label name="party"/>
|
||||||
|
@ -20,8 +24,16 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<field name="type_guest"/>
|
<field name="type_guest"/>
|
||||||
<label name="birthday"/>
|
<label name="birthday"/>
|
||||||
<field name="birthday"/>
|
<field name="birthday"/>
|
||||||
<label name="origin_city"/>
|
<label name="origin_country"/>
|
||||||
<field name="origin_city"/>
|
<field name="origin_country"/>
|
||||||
<label name="target_city"/>
|
<label name="target_country"/>
|
||||||
<field name="target_city"/>
|
<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>
|
</form>
|
||||||
|
|
|
@ -3,13 +3,19 @@
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<tree editable="top">
|
<tree editable="top">
|
||||||
<field name="party"/>
|
<field name="party"/>
|
||||||
<field name="name"/>
|
|
||||||
<field name="type_document"/>
|
<field name="type_document"/>
|
||||||
|
<field name="name"/>
|
||||||
<field name="doc_number"/>
|
<field name="doc_number"/>
|
||||||
<field name="mobile"/>
|
<field name="mobile"/>
|
||||||
<field name="email"/>
|
<field name="email"/>
|
||||||
<field name="nationality"/>
|
<field name="nationality"/>
|
||||||
|
<field name="birthday"/>
|
||||||
|
<field name="origin_country"/>
|
||||||
|
<field name="target_country"/>
|
||||||
<field name="sex"/>
|
<field name="sex"/>
|
||||||
<field name="type_guest"/>
|
<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>
|
</tree>
|
||||||
|
|
|
@ -2,10 +2,32 @@
|
||||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
this repository contains the full copyright notices and license terms. -->
|
this repository contains the full copyright notices and license terms. -->
|
||||||
<form>
|
<form>
|
||||||
<label name="name"/>
|
<label name="full_name"/>
|
||||||
<field name="name"/>
|
<field name="full_name"/>
|
||||||
<label name="type_document"/>
|
<label name="type_document"/>
|
||||||
<field name="type_document"/>
|
<field name="type_document"/>
|
||||||
<label name="id_number"/>
|
<label name="id_number"/>
|
||||||
<field 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>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue