This commit is contained in:
oscar alvarez 2022-05-22 01:52:05 -05:00
parent 8b04df56e1
commit 70505d0a09
10 changed files with 124 additions and 115 deletions

View File

@ -21,7 +21,6 @@ from .constants import (
TYPE_DOCUMENT
)
STATES = {
'readonly': Eval('state') != 'offer',
}
@ -862,7 +861,7 @@ class Booking(Workflow, ModelSQL, ModelView):
for comm in self.extra_commissions:
extras = sum(base_comm) * Decimal(comm.commission / 100)
res.append(extras)
return sum(res)
return self.currency.round(sum(res))
def send_email_to(self):
pool = Pool()
@ -1371,6 +1370,7 @@ class UpdateHolderStart(ModelView):
customer_phone = fields.Char('Customer Phone')
customer_email = fields.Char('Customer Email')
customer_type_document = fields.Selection(TYPE_DOCUMENT, 'Tipo de Documento Cliente')
main_guest = fields.Boolean('Main Guest')
class UpdateHolder(Wizard):
@ -1441,9 +1441,10 @@ class UpdateHolder(Wizard):
_party = self.start
rec_company = {}
to_folio = {}
nationality_id = _party.nationality.id if _party.nationality else None
rec = {
'name': _party.name.upper(),
'nationality': _party.nationality.id if _party.nationality else None,
'nationality': nationality_id,
'sex': _party.sex,
'birthday': _party.birthday,
'type_document': _party.type_document,
@ -1537,12 +1538,15 @@ class UpdateHolder(Wizard):
party, = Party.create([rec])
Booking.write([booking], {'party': party.id})
booking.save()
if _party.main_guest:
for folio in booking.lines:
if not folio.main_guest:
folio.main_guest = party.id
folio.save()
break
Guest.create([rec])
for folio in booking.lines:
Folio.write([folio], to_folio)
return 'end'

164
folio.py
View File

@ -71,7 +71,9 @@ class Folio(ModelSQL, ModelView):
'get_unit_price_w_tax')
uom = fields.Many2One('product.uom', 'UOM', readonly=True)
main_guest = fields.Many2One('party.party', 'Main Guest', select=True,
states=STATES_CHECKIN
states={
'readonly': True
}
)
contact = fields.Char('Contact', states=STATES_CHECKIN)
num_children = fields.Function(fields.Integer('No. Children'),
@ -215,7 +217,6 @@ class Folio(ModelSQL, ModelView):
raise UserError(gettext('hotel.msg_missing_select_room'))
rec.set_registration_number()
rec.check_room()
rec.add_main_guest()
cls.update_room(rec.room, 'dirty')
cls.write(records, {'registration_state': 'check_in'})
@ -287,15 +288,6 @@ class Folio(ModelSQL, ModelView):
self.registration_card = number
self.save()
def add_main_guest(self):
Guest = Pool().get('hotel.folio.guest')
Guest.create([{
'folio': self.id,
'party': self.main_guest.id,
'type_guest': 'adult',
'type_document': 13,
}])
def create_invoice(self):
pool = Pool()
Booking = pool.get('hotel.booking')
@ -505,20 +497,20 @@ class Folio(ModelSQL, ModelView):
class FolioGuest(ModelSQL, ModelView):
'Folio Guest'
__name__ = 'hotel.folio.guest'
_rec_name = 'party'
folio = fields.Many2One('hotel.folio', 'Folio', required=True,
ondelete='CASCADE')
party = fields.Many2One('party.party', 'Party', required=False)
main_guest = fields.Boolean('Main Guest')
type_guest = fields.Selection([
('adult', 'Adult'),
('child', 'Child'),
], 'Type Guest')
], 'Type Guest', required=True)
type_guest_string = type_guest.translated('type_guest')
nationality = fields.Many2One('party.nationality', 'Nationality')
nationality = fields.Many2One('party.nationality', 'Nationality',
required=True)
origin_country = fields.Many2One('party.nationality', 'Origin Country',
select=True)
select=True, required=True)
target_country = fields.Many2One('party.nationality', 'Target Country',
select=True)
select=True, required=True)
# New fields for speed reason
type_document = fields.Selection([
('12', 'Tarjeta de Identidad'),
@ -526,34 +518,31 @@ class FolioGuest(ModelSQL, ModelView):
('21', 'Tarjeta de Extranjeria'),
('22', 'Cedula de Extranjeria'),
('41', 'Pasaporte'),
], 'Document Type')
doc_number = fields.Char('Doc. Id', select=True)
name = fields.Char('Name', select=True)
mobile = fields.Char('Mobile', select=True)
email = fields.Char('Email', select=True)
], 'Document Type', required=True)
id_number = fields.Char('Id Number', select=True, required=True)
name = fields.Char('Name', select=True, required=True)
mobile = fields.Char('Mobile', select=True, required=True)
email = fields.Char('Email', select=True, required=True)
birthday = fields.Date('Birthday', select=True)
sex = fields.Selection([
('female', 'Female'),
('male', 'Male'),
('', ''),
], 'Sex')
], 'Sex', required=True)
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')
notes = fields.Text('Notes')
@fields.depends('name', 'first_name', 'second_name',
'first_family_name', 'second_family_name', 'type_person')
'first_family_name', 'second_family_name')
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':
if self.name:
names = self.name.split(' ')
first_name = names[0]
second_family_name = names[-1]
@ -572,10 +561,6 @@ class FolioGuest(ModelSQL, ModelView):
self.second_name = second_name
self.first_name = first_name
def get_rec_name(self, name):
if self.party:
return self.party.name
@staticmethod
def default_type_guest():
return 'adult'
@ -584,18 +569,10 @@ class FolioGuest(ModelSQL, ModelView):
def default_sex():
return 'male'
@staticmethod
def default_type_person():
return 'persona_natural'
@staticmethod
def default_type_document():
return '13'
@staticmethod
def default_principal_guest():
return False
@fields.depends('nationality', 'origin_country', 'target_country')
def on_change_nationality(self):
if self.nationality:
@ -603,42 +580,78 @@ class FolioGuest(ModelSQL, ModelView):
self.origin_country = self.nationality.id
@classmethod
def create(cls, vlist):
def manage_party(cls, v):
Party = Pool().get('party.party')
new_values = []
for v in vlist:
# if not v.get('doc_number'):
# continue
party = v.get('party')
if not party:
parties = Party.search([
('id_number', '=', v['doc_number']),
])
if parties:
party = parties[0]
else:
party, = Party.create([{
'name': v['name'],
'id_number': v['doc_number'],
'type_document': v['type_document'],
'birthday': v['birthday'],
'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': [
('create', [
{'type': 'email', 'value': v['email']},
{'type': 'mobile', 'value': v['mobile']},
])
]
}])
v['party'] = party.id
new_values.append(v)
is_main_guest = v.pop('main_guest')
_ = v.pop('type_guest', None)
_ = v.pop('origin_country', None)
_ = v.pop('target_country', None)
folio = v.pop('folio', None)
if is_main_guest:
parties = Party.search([
('id_number', '=', v['id_number']),
])
email = v.pop('email', '')
mobile = v.pop('mobile', '')
v['type_person'] = 'persona_natural'
if not parties:
v['contact_mechanisms'] = [
('create', [
{'type': 'email', 'value': email},
{'type': 'mobile', 'value': mobile},
])
]
party, = Party.create([v])
else:
Party.write(parties, v)
party = parties[0]
has_email = False
has_mobile = False
for cm in party.contact_mechanisms:
if email and cm.type == 'email':
cm.value = email
has_email = True
elif mobile and cm.type == 'mobile':
cm.value = mobile
has_mobile = True
cm.save()
to_write = []
if not has_mobile and mobile:
to_write.append({'type': 'mobile', 'value': mobile})
if not has_email and email:
to_write.append({'type': 'email', 'value': email})
if to_write:
Party.write(
[parties],
{'contact_mechanisms': [('create', to_write)]}
)
super(FolioGuest, cls).create(new_values)
if folio:
Folio = Pool().get('hotel.folio')
folio = Folio(folio)
folio.main_guest = party.id
folio.save()
@classmethod
def create(cls, vlist):
super(FolioGuest, cls).create(vlist)
for v in vlist:
cls.manage_party(v)
@classmethod
def write(cls, records, values):
super(FolioGuest, cls).write(records, values)
fields = cls.fields_get()
for val in ('id', 'rec_name', 'write_date', 'write_uid', 'create_date'):
fields.pop(val)
data = {}
fields_list = fields.keys()
rec = records[0]
for field in fields_list:
data[field] = getattr(rec, field)
data.update(values)
cls.manage_party(data)
class OperationMaintenance(Workflow, ModelSQL, ModelView):
@ -891,7 +904,6 @@ class Migration(Report):
('arrival_date', '>=', start),
('arrival_date', '<=', end),
('main_guest', '!=', None),
('guests.party', '!=', None),
('registration_state', 'in', ['check_in', 'check_out']),
])
return report_context

View File

@ -10,9 +10,10 @@ class Invoice(metaclass=PoolMeta):
@classmethod
def post(cls, invoices):
super(Invoice, cls).post(invoices)
for invoice in invoices:
if invoice.type == 'out':
cls.set_advances_from_origin(invoice)
# FIXME: esta creando notas en ceros
# for invoice in invoices:
# if invoice.type == 'out':
# cls.set_advances_from_origin(invoice)
@classmethod
def set_advances_from_origin(cls, invoice):

Binary file not shown.

View File

@ -20,8 +20,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="nights_quantity"/>
<label name="unit_price"/>
<field name="unit_price"/>
<label name="party"/>
<field name="party"/>
<!-- <label name="party"/>
<field name="party"/> -->
<label name="host_quantity"/>
<field name="host_quantity"/>
<label name="breakfast_included"/>

View File

@ -2,8 +2,6 @@
<!-- 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="party"/>
<field name="party"/>
<label name="folio"/>
<field name="folio"/>
<label name="type_guest"/>
@ -12,16 +10,16 @@ this repository contains the full copyright notices and license terms. -->
<field name="nationality" widget="selection"/>
<label name="type_document"/>
<field name="type_document"/>
<label name="doc_number"/>
<field name="doc_number"/>
<label name="id_number"/>
<field name="id_number"/>
<label name="mobile"/>
<field name="mobile"/>
<label name="email"/>
<field name="email"/>
<label name="sex"/>
<field name="sex"/>
<label name="origin_country"/>
<field name="origin_country" widget="selection"/>
<label name="target_country"/>
<field name="target_country" widget="selection"/>
<label name="sex"/>
<field name="sex"/>
</form>

View File

@ -3,11 +3,10 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="folio"/>
<field name="party" expand="1"/>
<field name="type_guest"/>
<field name="nationality" widget="selection"/>
<field name="type_document"/>
<field name="doc_number"/>
<field name="id_number"/>
<field name="mobile"/>
<field name="email"/>
<field name="sex"/>

View File

@ -2,16 +2,17 @@
<!-- 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="type_person"/>
<field name="type_person"/>
<label name="main_guest"/>
<field name="main_guest"/>
<newline />
<label name="type_guest"/>
<field name="type_guest"/>
<label name="type_document"/>
<field name="type_document"/>
<label name="name"/>
<field name="name"/>
<label name="party"/>
<field name="party"/>
<label name="doc_number"/>
<field name="doc_number"/>
<label name="id_number"/>
<field name="id_number"/>
<label name="mobile"/>
<field name="mobile"/>
<label name="email"/>
@ -20,10 +21,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="nationality"/>
<label name="sex"/>
<field name="sex"/>
<label name="type_guest"/>
<field name="type_guest"/>
<label name="birthday"/>
<field name="birthday"/>
<label name="origin_country"/>
<field name="origin_country"/>
<label name="target_country"/>
@ -36,4 +33,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="first_family_name"/>
<label name="second_family_name"/>
<field name="second_family_name"/>
<label name="birthday"/>
<field name="birthday"/>
<separator string="Notes" colspan="4"/>
<field name="notes" colspan="4"/>
</form>

View File

@ -2,21 +2,13 @@
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="party" expand="1"/>
<field name="type_document"/>
<field name="main_guest"/>
<field name="type_document" expand="1"/>
<field name="name" expand="1"/>
<field name="doc_number"/>
<field name="id_number" expand="1"/>
<field name="nationality" expand="1"/>
<field name="type_guest" expand="1"/>
<field name="mobile"/>
<field name="email"/>
<field name="nationality"/>
<field name="birthday"/>
<field name="origin_country"/>
<field name="target_country"/>
<field name="sex"/>
<field name="type_guest"/>
<field name="first_name"/>
<field name="second_name"/>
<field name="first_family_name"/>
<field name="second_family_name"/>
<field name="type_person"/>
</tree>

View File

@ -21,6 +21,8 @@ this repository contains the full copyright notices and license terms. -->
<field name="sex"/>
<label name="birthday"/>
<field name="birthday"/>
<label name="main_guest"/>
<field name="main_guest"/>
</group>
<group colspan="4" col="4" id="travel_info" string="Travel Info">
<label name="origin_country"/>