Improvements

This commit is contained in:
Oscar 2021-11-24 22:52:03 -05:00
parent ea9e825d8d
commit 3e75aba503
13 changed files with 67 additions and 110 deletions

View File

@ -150,7 +150,7 @@ class Booking(Workflow, ModelSQL, ModelView):
'invisible': Eval('state').in_(['finished', 'cancelled', 'not_show']),
},
'create_guest': {
'invisible': Eval('state') != 'offer',
'invisible': Eval('party'),
},
'cancel': {
'invisible': Eval('state').in_(
@ -379,9 +379,11 @@ class Booking(Workflow, ModelSQL, ModelView):
else:
party = fo.main_guest
booking = fo.booking
if not party:
raise UserError(gettext('hotel.msg_customer_is_required'))
bk = fo.booking
# FIXME: Add agent
agent_id = booking.party_seller.party.id if booking.party_seller else None
agent_id = bk.party_seller.agent.id if bk.party_seller else None
if party.id not in res.keys():
# Add room product to sale
reference = ''
@ -393,23 +395,23 @@ class Booking(Workflow, ModelSQL, ModelView):
)
res[party.id] = {
'party': party,
'currency': booking.currency.id,
'currency': bk.currency.id,
'payment_term': None,
'guests_qty': len(fo.guests) + 1,
'reference': reference,
# 'agent': agent_id,
'agent': agent_id,
'rooms': fo.room.name,
'company': booking.company.id,
'price_list': booking.price_list.id if booking.price_list else None,
'company': bk.company.id,
'price_list': bk.price_list.id if bk.price_list else None,
'add_default_charges': False,
'vouchers': booking.vouchers,
'vouchers': bk.vouchers,
'lines': [{
'folios': [fo],
'description': fo.get_room_info(),
'quantity': fo.nights_quantity,
'product': fo.product,
'unit_price': fo.unit_price,
'taxes_exception': booking.taxes_exception,
'taxes_exception': bk.taxes_exception,
}]
}
else:
@ -420,17 +422,17 @@ class Booking(Workflow, ModelSQL, ModelView):
'quantity': fo.nights_quantity,
'product': fo.product,
'unit_price': fo.unit_price,
'taxes_exception': booking.taxes_exception,
'taxes_exception': bk.taxes_exception,
})
for charge in charges:
invoice_party_id = charge.invoice_to.id
unit_price = booking.currency.round(charge.unit_price)
unit_price = bk.currency.round(charge.unit_price)
if invoice_party_id != party.id:
if invoice_party_id not in res.keys():
res[invoice_party_id] = {
'party': charge.invoice_to.id,
'currency': booking.currency.id,
'currency': bk.currency.id,
'payment_term': None,
'lines': [],
}
@ -444,7 +446,7 @@ class Booking(Workflow, ModelSQL, ModelView):
'product': charge.product,
'unit_price': unit_price,
'charge': charge,
'taxes_exception': booking.taxes_exception,
'taxes_exception': bk.taxes_exception,
})
return res
@ -454,6 +456,7 @@ class Booking(Workflow, ModelSQL, ModelView):
new_line = {
'type': 'line',
'invoice': invoice.id,
'operation_center': 1,
'unit': product.template.default_uom.id,
'account': product.template.account_category.account_revenue_used.id,
'invoice_type': 'out',
@ -517,11 +520,14 @@ class Booking(Workflow, ModelSQL, ModelView):
if rec.get('guests_qty') and rec.get('add_default_charges'):
for product in config.default_charges:
if rec['party']:
taxes_ids = cls.get_taxes(product, rec['party'], invoice.currency)
taxes_ids = cls.get_taxes(
product, rec['party'], invoice.currency
)
new_line = {
'invoice': invoice.id,
'type': 'line',
'unit': product.template.default_uom.id,
'operation_center': 1,
'quantity': rec['guests_qty'],
'unit_price': product.template.list_price,
'product': product.id,
@ -737,6 +743,7 @@ class SelectRoomsAsk(ModelView):
overbooking = fields.Boolean('Overbooking')
targets = fields.Function(fields.Many2Many('hotel.room', None, None,
'Targets'), 'on_change_with_targets')
unit_price = fields.Numeric('Unit Price', digits=(16, 4))
@staticmethod
def default_accommodation():

View File

@ -113,7 +113,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="domain" eval="[]" pyson="1"/>
<field name="act_window" ref="act_booking_form"/>
</record>
<menuitem parent="menu_hotel" sequence="40"
<menuitem parent="menu_hotel" sequence="10"
action="act_booking_form" id="menu_booking_form"/>
<record model="ir.ui.view" id="booking_folio_view_tree">

View File

@ -35,10 +35,12 @@ class SaleChannel(ModelSQL, ModelView):
depends=['company', 'type_commission'])
taxes = fields.Many2Many('hotel.channel-account.tax',
'channel', 'tax', 'Channel Taxes',
domain=[('parent', '=', None), ['OR',
domain=[
('parent', '=', None), ['OR',
('group', '=', None),
('group.kind', 'in', ['purchase', 'both'])],
])
]
)
currency = fields.Many2One('currency.currency', 'Currency',
required=True)
price_list = fields.Many2One('product.price_list', 'Price List')

Binary file not shown.

View File

@ -484,9 +484,9 @@ class Folio(ModelSQL, ModelView):
Calculation of sale commission for channel based on booking total amount
"""
res = Decimal(0)
if self.total_amount and self.booking.party_seller and \
self.booking.party_seller.party.sale_commission:
res = self.total_amount * self.booking.party_seller.sale_commission / 100
# if self.total_amount and self.booking.party_seller and \
# self.booking.party_seller.agent.sale_commission:
# res = self.total_amount * self.booking.party_seller.sale_commission / 100
return res

View File

@ -28,7 +28,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="view" ref="housekeeping_view_form"/>
<field name="act_window" ref="act_housekeeping_form"/>
</record>
<menuitem parent="menu_hotel" sequence="20"
<menuitem parent="menu_hotel" sequence="30"
action="act_housekeeping_form" id="menu_housekeeping_form"/>
<!-- Model Access -->

View File

@ -72,5 +72,8 @@ this repository contains the full copyright notices and license terms. -->
<record model="ir.message" id="msg_no_delete_folios">
<field name="text">Error, you can not delete folios actives</field>
</record>
<record model="ir.message" id="msg_customer_is_required">
<field name="text">The customer is required!</field>
</record>
</data>
</tryton>

View File

@ -36,75 +36,6 @@ 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 CreateGuest(Wizard):
'Create Party to Guest'
__name__ = 'hotel.party.guest'
@ -134,18 +65,33 @@ class CreateGuest(Wizard):
'type': contact.type, 'value': contact.value
})
party, = Party.create([{
if self.start.type_document == '31':
type_person = 'persona_juridica'
else:
type_person = 'persona_natural'
to_create = {
'name': self.start.name,
'id_number': self.start.id_number,
'type_document': self.start.type_document,
'type_person': type_person,
'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', contact_mechanisms)]
}])
'contact_mechanisms': [('create', contact_mechanisms)],
'addresses': [('create', [{
'street': '',
}])]
}
party, = Party.create([to_create])
party_id = party.id
Booking.write([record], {'party': party_id})
if record.lines:
for folio in record.lines:
if not folio.main_guest:
folio.main_guest = party_id
folio.save()
return 'end'

View File

@ -40,7 +40,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="view" ref="service_view_form"/>
<field name="act_window" ref="act_service_tree"/>
</record>
<menuitem name="Service" parent="hotel.menu_hotel" sequence="14"
<menuitem name="Service" parent="hotel.menu_hotel" sequence="40"
id="menu_hotel_service" action="act_service_tree"/>
<record model="ir.model.button" id="service_cancel_button">

View File

@ -22,12 +22,12 @@ this repository contains the full copyright notices and license terms. -->
<field name="host_quantity"/>
<label name="nationality"/>
<field name="nationality"/>
<label name="total_commission"/>
<field name="total_commission"/>
<label name="origin_country"/>
<field name="origin_country"/>
<label name="target_country"/>
<field name="target_country"/>
<!-- <label name="total_commission"/>
<field name="total_commission"/> -->
<notebook colspan="6">
<page string="Charges" id="hotel_charges">
<field name="charges" colspan="4"/>

View File

@ -3,9 +3,9 @@
this repository contains the full copyright notices and license terms. -->
<form col="6">
<label name="party"/>
<field name="party"/>
<field name="party" colspan="2"/>
<button name="create_guest" string="Create Guest"
icon="tryton-open" colspan="2"/>
icon="tryton-open"/>
<label name="number"/>
<field name="number"/>
<label name="contact"/>
@ -25,15 +25,17 @@ this repository contains the full copyright notices and license terms. -->
<label name="ota_booking_code"/>
<field name="ota_booking_code"/>
<button name="select_rooms" string="Select Rooms"
icon="tryton-open" colspan="2"/>
<button name="do_pay" string="Do Pay" icon="tryton-open" colspan="2"/>
<button name="send_email" string="Send Email"
icon="tryton-open" colspan="2"/>
icon="tryton-open" colspan="4"/>
<button name="do_pay" string="Do Pay" icon="tryton-open"/>
<button name="send_email" string="Send Email" icon="tryton-open"/>
<notebook colspan="6">
<page string="Lines" id="lines">
<field name="lines" colspan="4"
view_ids="hotel.booking_folio_view_tree"/>
</page>
<page string="Advances Payments" id="vouchers">
<field name="vouchers" colspan="4"/>
</page>
<page string="Additional Info" id="additional_info">
<label name="payment_term"/>
<field name="payment_term" widget="selection"/>
@ -71,9 +73,6 @@ this repository contains the full copyright notices and license terms. -->
<label name="created_channel"/>
<field name="created_channel"/>
</page>
<page string="Advances Payments" id="vouchers">
<field name="vouchers" colspan="4"/>
</page>
</notebook>
<group col="4" colspan="4" id="buttons">
<label name="taxes_exception"/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- 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>
<form col="6">
<label name="name"/>
<field name="name"/>
<label name="type_document"/>
@ -12,9 +12,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="birthday"/>
<label name="sex"/>
<field name="sex"/>
<label name="type_person"/>
<field name="type_person"/>
<group colspan="4" col="8" id="names">
<group colspan="6" col="8" id="names">
<separator string="Names" colspan="4" id="names"/>
<newline/>
<label name="first_name"/>
@ -26,6 +24,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"
<field name="contact_mechanisms" colspan="6"
view_ids="party.contact_mechanism_view_tree_sequence"/>
</form>

View File

@ -10,6 +10,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="accommodation" widget="selection"/>
<label name="overbooking"/>
<field name="overbooking"/>
<label name="unit_price"/>
<field name="unit_price"/>
<field name="targets" invisible="1" colspan="4"/>
<field name="rooms" colspan="4"/>
</form>