Fix create guest
This commit is contained in:
parent
c202ba6ca8
commit
d671b5204b
|
@ -46,7 +46,7 @@ def register():
|
|||
channel.ChannelTax,
|
||||
booking.Guest,
|
||||
booking.SelectRoomsAsk,
|
||||
party.CreateGuestStart,
|
||||
# party.CreateGuestStart,
|
||||
booking.BookingVoucher,
|
||||
booking.RoomsOccupancyStart,
|
||||
booking.BookingForecastStart,
|
||||
|
|
|
@ -92,7 +92,7 @@ MEDIA = [
|
|||
]
|
||||
|
||||
PLAN = [
|
||||
('', ''),
|
||||
('no_breakfast', 'No Breakfast'),
|
||||
('all_inclusive', 'All Inclusive'),
|
||||
('bed_breakfast', 'Bed & Breakfast'),
|
||||
('full_american', 'Full American'),
|
||||
|
@ -242,7 +242,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
'invisible': Eval('state') != 'offer',
|
||||
},
|
||||
'create_guest': {
|
||||
|
||||
'invisible': Eval('state') != 'offer',
|
||||
},
|
||||
'cancel': {
|
||||
'invisible': Eval('state').in_(['cancel', '']) and
|
||||
|
@ -864,6 +864,7 @@ class BookingLine(ModelSQL, ModelView):
|
|||
# if not accommodation:
|
||||
# kind = 'statement'
|
||||
|
||||
breakfast_included = line.booking.plan != 'no_breakfast' or False
|
||||
values = {
|
||||
'kind': kind,
|
||||
'accommodation': accommodation,
|
||||
|
@ -877,6 +878,7 @@ class BookingLine(ModelSQL, ModelView):
|
|||
'complementary': line.booking.complementary,
|
||||
'type_complementary': line.booking.type_complementary,
|
||||
'taxes_exception': line.booking.taxes_exception,
|
||||
'breakfast_included': breakfast_included,
|
||||
}
|
||||
if line.room:
|
||||
values['room'] = line.room.id
|
||||
|
@ -1484,7 +1486,7 @@ class GuestsListReport(Report):
|
|||
occupancy_rate = round(_rooms_occupied / num_rooms, 2)
|
||||
else:
|
||||
occupancy_rate = 0
|
||||
print('operations ...', operations)
|
||||
|
||||
operations_ = []
|
||||
for op in operations:
|
||||
for guest in op.guests:
|
||||
|
|
11
booking.xml
11
booking.xml
|
@ -371,5 +371,16 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<menuitem parent="hotel.menu_reporting" id="menu_hotel_booking_daily"
|
||||
action="wizard_print_booking_daily"/>
|
||||
|
||||
<record model="ir.action.wizard" id="wizard_party_guest">
|
||||
<field name="name">Create Guest</field>
|
||||
<field name="wiz_name">hotel.party.guest</field>
|
||||
<field name="model">hotel.booking</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_party_guest">
|
||||
<field name="model">party.party</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">create_guest_form</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
|
@ -100,6 +100,7 @@ class Operation(Workflow, ModelSQL, ModelView):
|
|||
unit_price_w_tax = fields.Function(fields.Numeric('Unit Price With Tax'),
|
||||
'get_unit_price_w_tax')
|
||||
taxes_exception = fields.Boolean('Taxes Exception', states=STATES_OP)
|
||||
breakfast_included = fields.Boolean('Breakfast Included', states=STATES_OP)
|
||||
add_default_charges = fields.Boolean('Add Default Charges', states=STATES_OP)
|
||||
# sale = fields.Function(fields.Many2One('sale.sale', 'Sale'), 'get_sale')
|
||||
sale_line = fields.Many2One('sale.line', 'Sale Line', select=True)
|
||||
|
|
177
party.py
177
party.py
|
@ -2,10 +2,10 @@
|
|||
#the top level of this repository contains the full copyright notices
|
||||
#and license terms.
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields, ModelView
|
||||
from trytond.model import fields
|
||||
from trytond.wizard import Wizard, StateView, Button, StateTransition
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.i18n import gettext
|
||||
|
||||
TYPE = [
|
||||
|
@ -15,19 +15,6 @@ TYPE = [
|
|||
('implicit', 'Implicit'),
|
||||
]
|
||||
|
||||
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'),
|
||||
]
|
||||
|
||||
|
||||
class Party(metaclass=PoolMeta):
|
||||
__name__ = 'party.party'
|
||||
|
@ -49,79 +36,79 @@ class Party(metaclass=PoolMeta):
|
|||
visa_date = fields.Date('Visa Date')
|
||||
|
||||
|
||||
class CreateGuestStart(ModelView):
|
||||
'Create Party to Guest Start'
|
||||
__name__ = 'hotel.party.guest.start'
|
||||
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 CreateGuestStart(ModelView):
|
||||
# 'Create Party to Guest Start'
|
||||
# __name__ = 'hotel.party.guest.start'
|
||||
# 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'
|
||||
__name__ = 'hotel.party.guest'
|
||||
start = StateView('hotel.party.guest.start',
|
||||
start = StateView('party.party',
|
||||
'hotel.view_party_guest', [
|
||||
Button('Exit', 'end', 'tryton-cancel'),
|
||||
Button('Create', 'create_', 'tryton-ok', default=True),
|
||||
|
@ -129,10 +116,6 @@ class CreateGuest(Wizard):
|
|||
)
|
||||
create_ = StateTransition()
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(CreateGuest, cls).__setup__()
|
||||
|
||||
def transition_create_(self):
|
||||
pool = Pool()
|
||||
Party = pool.get('party.party')
|
||||
|
@ -143,10 +126,16 @@ class CreateGuest(Wizard):
|
|||
('id_number', '=', self.start.id_number)
|
||||
])
|
||||
if parties:
|
||||
self.get_message(('El usuario %s ya existe')%(self.start.name))
|
||||
raise UserError(gettext('El usuario ya existe!'))
|
||||
else:
|
||||
contact_mechanisms = []
|
||||
for contact in self.start.contact_mechanisms:
|
||||
contact_mechanisms.append({
|
||||
'type': contact.type, 'value': contact.value
|
||||
})
|
||||
|
||||
party, = Party.create([{
|
||||
'name': self.start.full_name,
|
||||
'name': self.start.name,
|
||||
'id_number': self.start.id_number,
|
||||
'type_document': self.start.type_document,
|
||||
'birthday': self.start.birthday,
|
||||
|
@ -155,16 +144,8 @@ class CreateGuest(Wizard):
|
|||
'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},
|
||||
])
|
||||
]
|
||||
'contact_mechanisms': [('create', contact_mechanisms)]
|
||||
}])
|
||||
party_id = party.id
|
||||
Booking.write([record], {'party': party_id})
|
||||
return 'end'
|
||||
|
||||
def get_message(self, message):
|
||||
raise AccessError(gettext('hotel.msg_error', s=message))
|
||||
|
|
10
party.xml
10
party.xml
|
@ -3,16 +3,6 @@
|
|||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.action.wizard" id="wizard_party_guest">
|
||||
<field name="name">Create Party Guest</field>
|
||||
<field name="wiz_name">hotel.party.guest</field>
|
||||
<field name="model">hotel.party</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_party_guest">
|
||||
<field name="model">hotel.party.guest.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">party_guest</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="party_view_form">
|
||||
<field name="model">party.party</field>
|
||||
<field name="inherit" ref="party.party_view_form"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.2
|
||||
version=6.0.3
|
||||
depends:
|
||||
party
|
||||
company
|
||||
|
|
|
@ -26,10 +26,12 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="party_seller" widget="selection"/>
|
||||
<label name="taxes_exception"/>
|
||||
<field name="taxes_exception"/>
|
||||
<label name="plan"/>
|
||||
<field name="plan"/>
|
||||
<button name="select_rooms" string="Select Rooms"
|
||||
icon="tryton-open"/>
|
||||
<button name="send_email" string="Send Email"
|
||||
icon="tryton-open" colspan="2"/>
|
||||
<button name="select_rooms" string="Select Rooms"
|
||||
icon="tryton-open" colspan="2"/>
|
||||
<notebook colspan="6">
|
||||
<page string="Lines" id="lines">
|
||||
<field name="lines" colspan="4"
|
||||
|
@ -76,15 +78,11 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="guarantee"/>
|
||||
<field name="guarantee"/>
|
||||
<newline/>
|
||||
<separator id="marketing_guest" string="Guest information" colspan="4"/>
|
||||
<label name="plan"/>
|
||||
<field name="plan"/>
|
||||
<label name="segment"/>
|
||||
<field name="segment"/>
|
||||
<newline/>
|
||||
<separator id="marketing_advertisement" string="Advertisement information" colspan="4"/>
|
||||
<label name="source_contact"/>
|
||||
<field name="source_contact"/>
|
||||
<label name="segment"/>
|
||||
<field name="segment"/>
|
||||
</page>
|
||||
<page string="Advances Payments" id="vouchers">
|
||||
<field name="vouchers" colspan="4"/>
|
||||
|
|
|
@ -9,5 +9,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="booking_date" widget="date"/>
|
||||
<field name="price_list"/>
|
||||
<field name="total_amount"/>
|
||||
<field name="total_advance"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
<!-- 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="full_name"/>
|
||||
<field name="full_name"/>
|
||||
<label name="name"/>
|
||||
<field name="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"/>
|
||||
|
@ -30,4 +26,6 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<label name="second_family_name"/>
|
||||
<field name="second_family_name"/>
|
||||
</group>
|
||||
<field name="contact_mechanisms" colspan="4"
|
||||
view_ids="party.contact_mechanism_view_tree_sequence"/>
|
||||
</form>
|
Loading…
Reference in New Issue