2020-04-16 14:45:13 +02:00
|
|
|
#This file is part of Hotel module for Tryton. The COPYRIGHT file at
|
|
|
|
#the top level of this repository contains the full copyright notices
|
|
|
|
#and license terms.
|
2021-03-08 14:32:20 +01:00
|
|
|
from trytond.pool import PoolMeta, Pool
|
|
|
|
from trytond.model import fields, ModelView
|
|
|
|
from trytond.wizard import Wizard, StateView, Button, StateTransition, StateReport
|
|
|
|
from trytond.transaction import Transaction
|
2020-04-16 14:45:13 +02:00
|
|
|
|
2021-03-08 14:32:20 +01:00
|
|
|
|
|
|
|
__all__ = ['Party','CreateGuest','CreateGuestStart']
|
2020-04-16 14:45:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
TYPE = [
|
|
|
|
('', ''),
|
|
|
|
('service_acomplished', 'Service Acomplished'),
|
|
|
|
('direct', 'Direct'),
|
|
|
|
('implicit', 'Implicit'),
|
|
|
|
]
|
|
|
|
|
2021-03-08 14:32:20 +01:00
|
|
|
TYPE_DOCUMENT = [
|
|
|
|
('', ''),
|
|
|
|
('11', 'Civil Registry of Birth'),
|
|
|
|
('12', 'Identity Card'),
|
|
|
|
('13', 'Citizenship Card'),
|
|
|
|
('21', 'Tarjeta de Extranjeria'),
|
|
|
|
('22', 'Alien Registration Card'),
|
|
|
|
('31', 'NIT'),
|
|
|
|
('41', 'Passport'),
|
|
|
|
('42', 'Type of Foreign Document'),
|
|
|
|
('43', 'Without Foreign Identification or for use as defined by the DIAN'),
|
|
|
|
]
|
|
|
|
|
2020-04-16 14:45:13 +02:00
|
|
|
|
|
|
|
class Party(metaclass=PoolMeta):
|
|
|
|
__name__ = 'party.party'
|
|
|
|
'''
|
|
|
|
Party field and function aditions for channels management. Sales
|
|
|
|
commissions, taxes and price lists.
|
|
|
|
'''
|
|
|
|
sale_commission = fields.Numeric('Sales Commission %', digits=(3, 2),
|
|
|
|
help="Add the percentage of sales commission for this channel.",)
|
|
|
|
# Must be required if party is hotel channel.
|
|
|
|
# states={
|
|
|
|
# 'readonly': ~Eval('active', True),
|
|
|
|
# 'required': Bool(Eval('vat_country')),
|
|
|
|
# },
|
|
|
|
# depends=['active', 'vat_country'], size=12, select=True)
|
|
|
|
sale_commission_type = fields.Selection(TYPE, 'Sales Commission Type')
|
|
|
|
visa_category = fields.Char('Visa Category')
|
|
|
|
visa_number = fields.Char('Visa Number')
|
|
|
|
visa_date = fields.Date('Visa Date')
|
2021-03-08 14:32:20 +01:00
|
|
|
|
|
|
|
class CreateGuestStart(ModelView):
|
|
|
|
'Create Party to Guest Start'
|
|
|
|
__name__ = 'hotel.party.guest.start'
|
|
|
|
name = fields.Char('Name', required=True)
|
|
|
|
type_document = fields.Selection(TYPE_DOCUMENT, 'Type Document')
|
|
|
|
id_number = fields.Char('Id Number')
|
|
|
|
|
|
|
|
class CreateGuest(Wizard):
|
|
|
|
'Create Party to Guest'
|
|
|
|
__name__ = 'hotel.party.guest'
|
|
|
|
start = StateView('hotel.party.guest.start',
|
|
|
|
'hotel.view_party_guest', [
|
|
|
|
Button('Exit', 'end', 'tryton-cancel'),
|
|
|
|
Button('Create', 'create_', 'tryton-ok', default=True),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
create_ = StateTransition()
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __setup__(cls):
|
|
|
|
super(CreateGuest, cls).__setup__()
|
|
|
|
|
|
|
|
def transition_create_(self):
|
|
|
|
pool = Pool()
|
|
|
|
Party = pool.get('party.party')
|
|
|
|
Booking = pool.get('hotel.booking')
|
|
|
|
id = Transaction().context.get('active_id', False)
|
|
|
|
record = Booking(id)
|
|
|
|
parties = Party.search([
|
|
|
|
('id_number', '=', self.start.id_number)
|
|
|
|
])
|
|
|
|
if parties:
|
|
|
|
self.get_message(('El usuario %s ya existe')%(self.start.name))
|
|
|
|
else:
|
|
|
|
party, = Party.create([{
|
|
|
|
'name': self.start.name,
|
|
|
|
'type_document': self.start.type_document,
|
|
|
|
'id_number': self.start.id_number
|
|
|
|
}])
|
|
|
|
party.save()
|
|
|
|
Booking.write([record], {'party': party})
|
|
|
|
return 'end'
|
|
|
|
|
|
|
|
def get_message(self, message):
|
|
|
|
self.raise_user_error(message)
|