Fix
This commit is contained in:
parent
869f2cf186
commit
23fbaa286f
|
@ -45,6 +45,7 @@ def register():
|
|||
booking.BookingVoucher,
|
||||
booking.RoomsOccupancyStart,
|
||||
booking.BookingForecastStart,
|
||||
booking.UpdateHolderStart,
|
||||
folio.FolioGuest,
|
||||
folio.GuestsListStart,
|
||||
folio.StatisticsByMonthStart,
|
||||
|
@ -90,6 +91,7 @@ def register():
|
|||
booking.BookingForecast,
|
||||
booking.RoomsOccupancy,
|
||||
booking.BookingDaily,
|
||||
booking.UpdateHolder,
|
||||
folio.OpenMigration,
|
||||
folio.GuestsList,
|
||||
folio.StatisticsByMonth,
|
||||
|
|
282
booking.py
282
booking.py
|
@ -18,8 +18,10 @@ from trytond.i18n import gettext
|
|||
from .constants import (
|
||||
STATE_BOOKING, REGISTRATION_STATE, REASON, GUARANTEE, SATISFACTION,
|
||||
MEDIA, PLAN, INVOICE_METHOD, COMPLEMENTARY, PAYMENT_METHOD_CHANNEL,
|
||||
TYPE_DOCUMENT
|
||||
)
|
||||
|
||||
|
||||
STATES = {
|
||||
'readonly': Eval('state') != 'offer',
|
||||
}
|
||||
|
@ -150,6 +152,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
'Channel Paymode', states={'invisible': ~Eval('channel')},
|
||||
depends=['channel']
|
||||
)
|
||||
invoices = fields.Function(fields.Many2Many('account.invoice',
|
||||
None, None, 'Invoices'), 'get_invoices')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
|
@ -167,8 +171,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
'select_rooms': {
|
||||
'invisible': Eval('state').in_(['finished', 'cancelled', 'not_show']),
|
||||
},
|
||||
'create_guest': {
|
||||
'invisible': Eval('party'),
|
||||
'update_holder': {
|
||||
'invisible': Eval('state').in_(['finished', 'cancelled', 'not_show']),
|
||||
},
|
||||
'cancel': {
|
||||
'invisible': Eval('state').in_(
|
||||
|
@ -256,6 +260,16 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
now = datetime.now()
|
||||
return now
|
||||
|
||||
def get_invoices(self, name=None):
|
||||
res = []
|
||||
for folio in self.lines:
|
||||
if folio.invoice_line:
|
||||
res.append(folio.invoice_line.id)
|
||||
for charge in folio.charges:
|
||||
if charge.invoice_line:
|
||||
res.append(charge.invoice_line.id)
|
||||
return res
|
||||
|
||||
def get_person_num(self, name):
|
||||
res = 0
|
||||
for line in self.lines:
|
||||
|
@ -294,8 +308,8 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
pass
|
||||
|
||||
@classmethod
|
||||
@ModelView.button_action('hotel.wizard_party_guest')
|
||||
def create_guest(cls, bookings):
|
||||
@ModelView.button_action('hotel.wizard_update_holder')
|
||||
def update_holder(cls, bookings):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
|
@ -738,7 +752,7 @@ class Booking(Workflow, ModelSQL, ModelView):
|
|||
agent=agent,
|
||||
journal=journal,
|
||||
type='out',
|
||||
invoice_type='P',
|
||||
invoice_type='1',
|
||||
invoice_address=address.id,
|
||||
)
|
||||
|
||||
|
@ -1302,79 +1316,185 @@ class InvoicePaymentForm(ModelView):
|
|||
return Date.today()
|
||||
|
||||
|
||||
# class WizardInvoicePayment(Wizard):
|
||||
# 'Wizard Invoice Payment'
|
||||
# __name__ = 'invoice.payment'
|
||||
# start = StateView('invoice.payment.form',
|
||||
# 'hotel.invoice_payment_view_form', [
|
||||
# Button('Cancel', 'end', 'tryton-cancel'),
|
||||
# Button('Pay', 'pay_', 'tryton-ok', default=True),
|
||||
# ])
|
||||
# pay_ = StateTransition()
|
||||
#
|
||||
# @classmethod
|
||||
# def __setup__(cls):
|
||||
# super(WizardInvoicePayment, cls).__setup__()
|
||||
#
|
||||
# def default_start(self, fields):
|
||||
# pool = Pool()
|
||||
# Booking = pool.get('hotel.booking')
|
||||
# Date = pool.get('ir.date')
|
||||
# booking = Booking(Transaction().context['active_id'])
|
||||
# return {
|
||||
# 'payment_amount': booking.pending_to_pay,
|
||||
# 'party': booking.party.id,
|
||||
# 'pay_date': Date.today(),
|
||||
# }
|
||||
#
|
||||
# def transition_pay_(self):
|
||||
# pool = Pool()
|
||||
# Booking = pool.get('hotel.booking')
|
||||
# Invoice = pool.get('account.invoice')
|
||||
# active_id = Transaction().context.get('active_id', False)
|
||||
# booking = Booking(active_id)
|
||||
#
|
||||
# invoices = []
|
||||
# for folio in booking.lines:
|
||||
# inv = folio.invoice
|
||||
# if inv.state != 'posted':
|
||||
# continue
|
||||
# invoices.append(inv)
|
||||
# if not invoices:
|
||||
# return 'end'
|
||||
#
|
||||
# invoice = invoices[0]
|
||||
# invoice.create_move_advance(booking.vouchers)
|
||||
#
|
||||
# # if not sale.number:
|
||||
# # Invoice.set_number([sale])
|
||||
#
|
||||
# if not invoice.party.account_receivable:
|
||||
# # raise PartyMissingAccount(
|
||||
# # gettext('sale_pos.msg_party_without_account_receivable', s=sale.party.name))
|
||||
# pass
|
||||
# account = invoice.party.account_receivable.id
|
||||
#
|
||||
# if form.payment_amount:
|
||||
# payment = StatementLine(
|
||||
# statement=statements[0].id,
|
||||
# date=date.today(),
|
||||
# amount=form.payment_amount,
|
||||
# party=sale.party.id,
|
||||
# account=account,
|
||||
# description=self.start.voucher,
|
||||
# sale=active_id,
|
||||
# # number=self.start.voucher,
|
||||
# # voucher=self.start.voucher,
|
||||
# )
|
||||
# payment.save()
|
||||
#
|
||||
# if sale.total_amount != sale.paid_amount:
|
||||
# return 'start'
|
||||
# sale.save()
|
||||
# if self.start.do_invoice:
|
||||
# # for inv in sale.invoices:
|
||||
# # if inv.state == 'posted':
|
||||
# # inv.write([inv], {'state': 'draft'})
|
||||
# Invoice.workflow_to_end([sale])
|
||||
# return 'end'
|
||||
class UpdateHolderStart(ModelView):
|
||||
'Update Holder Start'
|
||||
__name__ = 'hotel.update_holder.start'
|
||||
name = fields.Char('Name', required=True)
|
||||
nationality = fields.Many2One('party.nationality', 'Nationality')
|
||||
sex = fields.Selection([
|
||||
('male', 'Male'),
|
||||
('female', 'Female'),
|
||||
], 'Sex', required=True)
|
||||
phone = fields.Char('Phone', required=True)
|
||||
email = fields.Char('Email')
|
||||
birthday = fields.Date('Birthday')
|
||||
|
||||
origin_country = fields.Many2One('party.country_code', 'Origin Country')
|
||||
target_country = fields.Many2One('party.country_code', 'Target Country')
|
||||
|
||||
country = fields.Many2One('party.country_code', 'Country')
|
||||
city = fields.Char('City')
|
||||
address = fields.Char('Address')
|
||||
|
||||
type_document = fields.Selection(TYPE_DOCUMENT, 'Tipo de Documento',
|
||||
required=True)
|
||||
id_number = fields.Char('Id Number', required=True)
|
||||
visa_number = fields.Char('Visa Number')
|
||||
visa_date = fields.Date('Visa Date')
|
||||
notes = fields.Text('Notes')
|
||||
|
||||
customer_id_number = fields.Char('Customer Id Number')
|
||||
customer_name = fields.Char('Customer Name')
|
||||
customer_country = fields.Many2One('party.country_code', 'Customer Country')
|
||||
customer_subdivision = fields.Many2One('party.department_code',
|
||||
'Customer Subdivision')
|
||||
customer_city = fields.Many2One('party.city_code', 'Customer City')
|
||||
customer_address = fields.Char('Customer Address')
|
||||
customer_phone = fields.Char('Customer Phone')
|
||||
customer_email = fields.Char('Customer Email')
|
||||
customer_type_document = fields.Selection(TYPE_DOCUMENT, 'Tipo de Documento Cliente')
|
||||
|
||||
|
||||
class UpdateHolder(Wizard):
|
||||
'Update Holder'
|
||||
__name__ = 'hotel.update_holder'
|
||||
start = StateView('hotel.update_holder.start',
|
||||
'hotel.update_holder_start_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Update', 'update', 'tryton-ok', default=True),
|
||||
])
|
||||
update = StateTransition()
|
||||
|
||||
def default_start(self, fields):
|
||||
pool = Pool()
|
||||
Booking = pool.get('hotel.booking')
|
||||
booking = Booking(Transaction().context['active_id'])
|
||||
res = {}
|
||||
print(booking.party)
|
||||
party = booking.party
|
||||
if party and party.id > 0:
|
||||
address = party.addresses[0] if party.addresses else None
|
||||
res = {
|
||||
'name': party.name,
|
||||
'nationality': party.nationality.id if party.nationality else None,
|
||||
'id_number': party.id_number,
|
||||
'type_document': party.type_document,
|
||||
'sex': party.sex,
|
||||
'phone': party.phone,
|
||||
'email': party.email,
|
||||
'visa_number': party.visa_number,
|
||||
'visa_date': party.visa_date,
|
||||
'birthday': party.birthday,
|
||||
'notes': party.notes,
|
||||
}
|
||||
if address:
|
||||
res['country'] = address.country_code.id if address.country_code else None
|
||||
res['city'] = address.city_code.id if address.city_code else None
|
||||
return res
|
||||
|
||||
def _set_cms(self, action, rec, phone, email):
|
||||
cms = [] # contact_mechanisms
|
||||
if phone:
|
||||
cms.append({'type': 'phone', 'value': phone})
|
||||
if email:
|
||||
cms.append({'type': 'email', 'value': email})
|
||||
if cms:
|
||||
rec['contact_mechanisms'] = [(action, cms)]
|
||||
return
|
||||
|
||||
def transition_update(self):
|
||||
pool = Pool()
|
||||
Booking = pool.get('hotel.booking')
|
||||
Folio = pool.get('hotel.folio')
|
||||
Party = pool.get('party.party')
|
||||
Address = pool.get('party.address')
|
||||
active_id = Transaction().context.get('active_id', False)
|
||||
edit = True
|
||||
booking = Booking(active_id)
|
||||
_party = self.start
|
||||
rec_company = {}
|
||||
to_folio = {}
|
||||
rec = {
|
||||
'name': _party.name.upper(),
|
||||
'nationality': _party.nationality.id if _party.nationality else None,
|
||||
'sex': _party.sex,
|
||||
'birthday': _party.birthday,
|
||||
'type_document': _party.type_document,
|
||||
'id_number': _party.id_number,
|
||||
'visa_number': _party.visa_number,
|
||||
'visa_date': _party.visa_date,
|
||||
'notes': _party.notes,
|
||||
}
|
||||
country_code = _party.country.id if _party.country else None
|
||||
city_code = _party.city.id if _party.city else None
|
||||
street = _party.address.upper() if _party.address else ''
|
||||
address = {}
|
||||
address['country_code'] = country_code
|
||||
address['city_code'] = city_code
|
||||
address['street'] = street
|
||||
if not booking.party:
|
||||
edit = False
|
||||
parties = Party.search([
|
||||
('id_number', '=', _party.id_number),
|
||||
])
|
||||
if parties:
|
||||
raise UserError('Este cliente ya existe!')
|
||||
|
||||
self._set_cms('create', rec, _party.phone, _party.email)
|
||||
rec['addresses'] = [('create', [address])]
|
||||
else:
|
||||
if booking.party.addresses:
|
||||
Address.write(list(booking.party.addresses), address)
|
||||
else:
|
||||
Address.create([address])
|
||||
if booking.party.contact_mechanisms:
|
||||
for cm in booking.party.contact_mechanisms:
|
||||
if cm.type == 'phone':
|
||||
cm.value = _party.phone
|
||||
if cm.type == 'email':
|
||||
cm.value = _party.email
|
||||
cm.save()
|
||||
else:
|
||||
self._set_cms('create', rec, _party.phone, _party.email)
|
||||
|
||||
|
||||
# to_folio['origin_country'] = _party.origin_country,
|
||||
# to_folio['target_country'] = _party.target_country,
|
||||
# rec['party_obligation_tax'] = [('add', [116])]
|
||||
|
||||
rec_ = None
|
||||
if _party.customer_id_number and _party.customer_name and _party.customer_type_document:
|
||||
rec_ = {
|
||||
'name': _party.customer_name,
|
||||
'id_number': _party.customer_id_number,
|
||||
'type_document': _party.customer_type_document,
|
||||
}
|
||||
address_cust = {
|
||||
'country_code': None,
|
||||
'city_code': None,
|
||||
'street': '',
|
||||
}
|
||||
if _party.customer_country:
|
||||
address_cust['country_code'] = _party.customer_country.id
|
||||
if _party.customer_city:
|
||||
address_cust['city_code'] = _party.customer_city.id
|
||||
if _party.customer_address:
|
||||
address_cust['street'] = _party.customer_address.upper()
|
||||
|
||||
rec_['addresses'] = [('create', [address_cust])]
|
||||
self._set_cms(
|
||||
'create', rec_, _party.customer_phone, _party.customer_email
|
||||
)
|
||||
party, = Party.create([rec_])
|
||||
# rec['party_obligation_tax'] = [('add', [116])]
|
||||
if edit:
|
||||
Party.write([booking.party], rec)
|
||||
else:
|
||||
print(rec)
|
||||
party, = Party.create([rec])
|
||||
Booking.write([booking], {'party': party.id})
|
||||
booking.save()
|
||||
|
||||
for folio in booking.lines:
|
||||
Folio.write([folio], to_folio)
|
||||
return 'end'
|
||||
|
|
12
booking.xml
12
booking.xml
|
@ -304,15 +304,15 @@ 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>
|
||||
<record model="ir.action.wizard" id="wizard_update_holder">
|
||||
<field name="name">Create / Update Guest</field>
|
||||
<field name="wiz_name">hotel.update_holder</field>
|
||||
<field name="model">hotel.booking</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="view_party_guest">
|
||||
<field name="model">party.party</field>
|
||||
<record model="ir.ui.view" id="update_holder_start_view_form">
|
||||
<field name="model">hotel.update_holder.start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">create_guest_form</field>
|
||||
<field name="name">update_holder_form</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="booking_bill_button">
|
||||
|
|
15
constants.py
15
constants.py
|
@ -97,3 +97,18 @@ PAYMENT_METHOD_CHANNEL = [
|
|||
('at_destination', 'At Destination'),
|
||||
('ota_collect', 'OTA Collect'),
|
||||
]
|
||||
|
||||
TYPE_DOCUMENT = [
|
||||
('11', 'Registro Civil de Nacimiento'),
|
||||
('12', 'Tarjeta de Identidad'),
|
||||
('13', 'Cedula de Ciudadania'),
|
||||
('21', 'Tarjeta de Extranjeria'),
|
||||
('22', 'Cedula de Extranjeria'),
|
||||
('31', 'NIT'),
|
||||
('41', 'Pasaporte'),
|
||||
('42', 'Tipo de Documento Extranjero'),
|
||||
('47', 'PEP'),
|
||||
('50', 'NIT de otro pais'),
|
||||
('91', 'NUIP'),
|
||||
('', ''),
|
||||
]
|
||||
|
|
1
folio.py
1
folio.py
|
@ -824,7 +824,6 @@ class FolioCharge(Workflow, ModelSQL, ModelView):
|
|||
self.invoice_to = self.folio.main_guest.id
|
||||
|
||||
|
||||
|
||||
class OpenMigrationStart(ModelView):
|
||||
'Open Migration Start'
|
||||
__name__ = 'hotel.open_migration.start'
|
||||
|
|
|
@ -4,7 +4,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<form col="6">
|
||||
<label name="party"/>
|
||||
<field name="party" colspan="2"/>
|
||||
<button name="create_guest" string="Create Guest"
|
||||
<button name="update_holder" string="Create/Update Holder"
|
||||
icon="tryton-open"/>
|
||||
<label name="number"/>
|
||||
<field name="number"/>
|
||||
|
@ -33,8 +33,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="lines" colspan="4"
|
||||
view_ids="hotel.booking_folio_view_tree"/>
|
||||
</page>
|
||||
<page string="Advances Payments" id="vouchers">
|
||||
<page string="Advances and Invoices" id="invoices_vouchers">
|
||||
<field name="vouchers" colspan="4"/>
|
||||
<field name="invoices" colspan="4"/>
|
||||
</page>
|
||||
<page string="Additional Info" id="additional_info">
|
||||
<label name="payment_term"/>
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?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 col="6">
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="type_document"/>
|
||||
<field name="type_document"/>
|
||||
<label name="id_number"/>
|
||||
<field name="id_number"/>
|
||||
<label name="birthday"/>
|
||||
<field name="birthday"/>
|
||||
<label name="sex"/>
|
||||
<field name="sex"/>
|
||||
<label name="nationality"/>
|
||||
<field name="nationality"/>
|
||||
<group colspan="6" 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>
|
||||
<field name="contact_mechanisms" colspan="6"
|
||||
view_ids="party.contact_mechanism_view_tree_sequence"/>
|
||||
</form>
|
|
@ -0,0 +1,66 @@
|
|||
<?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>
|
||||
<group colspan="4" col="8" id="general_info" string="General Info">
|
||||
<label name="name"/>
|
||||
<field name="name"/>
|
||||
<label name="nationality"/>
|
||||
<field name="nationality"/>
|
||||
<label name="type_document"/>
|
||||
<field name="type_document"/>
|
||||
<label name="id_number"/>
|
||||
<field name="id_number"/>
|
||||
<label name="sex"/>
|
||||
<field name="sex"/>
|
||||
<label name="phone"/>
|
||||
<field name="phone"/>
|
||||
<label name="email"/>
|
||||
<field name="email"/>
|
||||
<label name="birthday"/>
|
||||
<field name="birthday"/>
|
||||
</group>
|
||||
<group colspan="4" col="4" id="travel_info" string="Travel Info">
|
||||
<label name="origin_country"/>
|
||||
<field name="origin_country"/>
|
||||
<label name="target_country"/>
|
||||
<field name="target_country"/>
|
||||
</group>
|
||||
<group colspan="4" col="6" id="address_information" string="Address Info">
|
||||
<label name="country"/>
|
||||
<field name="country"/>
|
||||
<label name="city"/>
|
||||
<field name="city"/>
|
||||
<label name="address"/>
|
||||
<field name="address"/>
|
||||
</group>
|
||||
<group colspan="4" col="4" id="identity_info" string="Identity Info">
|
||||
<label name="visa_number"/>
|
||||
<field name="visa_number"/>
|
||||
<label name="visa_date"/>
|
||||
<field name="visa_date"/>
|
||||
</group>
|
||||
<group colspan="4" col="4" id="bill_info" string="Bill Info">
|
||||
<label name="customer_id_number"/>
|
||||
<field name="customer_id_number"/>
|
||||
<label name="customer_type_document"/>
|
||||
<field name="customer_type_document"/>
|
||||
<label name="customer_name"/>
|
||||
<field name="customer_name"/>
|
||||
<label name="customer_country"/>
|
||||
<field name="customer_country"/>
|
||||
<label name="customer_subdivision"/>
|
||||
<field name="customer_subdivision"/>
|
||||
<label name="customer_city"/>
|
||||
<field name="customer_city"/>
|
||||
<label name="customer_address"/>
|
||||
<field name="customer_address"/>
|
||||
<label name="customer_phone"/>
|
||||
<field name="customer_phone"/>
|
||||
<label name="customer_email"/>
|
||||
<field name="customer_email"/>
|
||||
</group>
|
||||
<group colspan="4" col="1" id="notes" string="Notes">
|
||||
<field name="notes"/>
|
||||
</group>
|
||||
</form>
|
Loading…
Reference in New Issue