From 6dff8baea35e63cdfc39780c32bf173e7c095fe5 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 11:42:46 +0100 Subject: [PATCH 1/8] [FIX] var on service _get_display_price --- hotel/models/hotel_service.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hotel/models/hotel_service.py b/hotel/models/hotel_service.py index e472f3bad..e81aa5396 100644 --- a/hotel/models/hotel_service.py +++ b/hotel/models/hotel_service.py @@ -169,7 +169,7 @@ class HotelService(models.Model): if self.compute_lines_out_vals(vals): reservation = self.env['hotel.reservation'].browse(vals['ser_room_line']) product = self.env['product.product'].browse(vals['product_id']) - + vals.update(self.prepare_service_lines( dfrom=reservation.checkin, days=reservation.nights, @@ -251,7 +251,7 @@ class HotelService(models.Model): return product.with_context(pricelist=origin.pricelist_id.id).price product_context = dict(self.env.context, partner_id=origin.partner_id.id, date=folio.date_order if folio else fields.Date.today(), uom=self.product_id.uom_id.id) final_price, rule_id = origin.pricelist_id.with_context(product_context).get_product_price_rule(self.product_id, self.product_qty or 1.0, origin.partner_id) - base_price, currency_id = self.with_context(product_context)._get_real_price_currency(product, rule_id, self.product_qty, product_id.uom_id, origin.pricelist_id.id) + base_price, currency_id = self.with_context(product_context)._get_real_price_currency(product, rule_id, self.product_qty, self.product_id.uom_id, origin.pricelist_id.id) if currency_id != origin.pricelist_id.currency_id.id: base_price = self.env['res.currency'].browse(currency_id).with_context(product_context).compute(base_price, origin.pricelist_id.currency_id) # negative discounts (= surcharge) are included in the display price @@ -326,11 +326,11 @@ class HotelService(models.Model): if board_room_type.price_type == 'fixed': return self.env['hotel.board.service.room.type.line'].search([ ('hotel_board_service_room_type_id', '=', board_room_type.id), - ('product_id','=',self.product_id.id)]).amount + ('product_id', '=', self.product_id.id)]).amount else: return (reservation.price_total * self.env['hotel.board.service.room.type.line'].search([ ('hotel_board_service_room_type_id', '=', board_room_type.id), - ('product_id','=',self.product_id.id)]).amount) / 100 + ('product_id', '=', self.product_id.id)]).amount) / 100 else: product = self.product_id.with_context( lang=partner.lang, @@ -408,7 +408,7 @@ class HotelService(models.Model): action['res_id'] = self.id action['target'] = 'new' return action - + #~ @api.constrains('product_qty') #~ def constrains_qty_per_day(self): #~ for record in self: From 45f07a90842697ca975589c6b295da2a444b916a Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 13:23:56 +0100 Subject: [PATCH 2/8] [WIP] report parte viajero --- hotel_l10n_es/report/report_parte_viajero.xml | 10 +++++----- .../inherit_hotel_checkin_partner_views.xml | 4 ++-- hotel_l10n_es/views/report_viajero.xml | 2 +- .../views/report_viajero_document.xml | 20 +++++++++---------- .../wizard/inherit_checkin_wizard.py | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/hotel_l10n_es/report/report_parte_viajero.xml b/hotel_l10n_es/report/report_parte_viajero.xml index 05d42a824..02d2a99d2 100644 --- a/hotel_l10n_es/report/report_parte_viajero.xml +++ b/hotel_l10n_es/report/report_parte_viajero.xml @@ -1,12 +1,12 @@ - - + + diff --git a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml index ab369ca55..5ab2c0fd5 100644 --- a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml +++ b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml @@ -1,6 +1,6 @@ - + hotel.checkin.partner.view.form hotel.checkin.partner @@ -62,5 +62,5 @@ - + diff --git a/hotel_l10n_es/views/report_viajero.xml b/hotel_l10n_es/views/report_viajero.xml index cd1c00917..db46715f8 100644 --- a/hotel_l10n_es/views/report_viajero.xml +++ b/hotel_l10n_es/views/report_viajero.xml @@ -24,7 +24,7 @@ .titulo {font-size:0.93em;} .titulo2 {font-size:1.93em;} - + diff --git a/hotel_l10n_es/views/report_viajero_document.xml b/hotel_l10n_es/views/report_viajero_document.xml index 681ce498a..5d3c71d2d 100644 --- a/hotel_l10n_es/views/report_viajero_document.xml +++ b/hotel_l10n_es/views/report_viajero_document.xml @@ -11,8 +11,8 @@ style="width:100%; max-heigth:50px; margin:0 0 1em 0;"/>

PART OF TRAVELERS ENTRY

Document number: / - ( ) - + ( ) +

Total amount (Reservation Card):

CIF:
@@ -30,21 +30,21 @@ Document number - + Type - + Expedition date - +
@@ -86,7 +86,7 @@ Origin - +
@@ -148,21 +148,21 @@ Document number - + Type - + Expedition date - +
@@ -204,7 +204,7 @@ Origin - +
diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.py b/hotel_l10n_es/wizard/inherit_checkin_wizard.py index 438c04685..f768a92ca 100644 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.py +++ b/hotel_l10n_es/wizard/inherit_checkin_wizard.py @@ -107,7 +107,7 @@ class CheckinWizard(models.TransientModel): @api.multi def pdf_viajero(self, cardex_id): cardex = self.env['cardex'].search([('id', '=', cardex_id)]) - return self.env['report'].get_action(cardex, 'report.viajero') + return self.env['report'].get_action(cardex, 'action.report.viajero') @api.multi def action_save_check(self): From 1cc390f0325062006b6e04ba08d261f11312efc8 Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 17:10:49 +0100 Subject: [PATCH 3/8] [WIP] police report --- hotel/models/inherited_res_partner.py | 1 - hotel_l10n_es/models/inherit_hotel_checkin_partner.py | 1 + hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml | 2 ++ hotel_l10n_es/wizard/police_wizard.py | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hotel/models/inherited_res_partner.py b/hotel/models/inherited_res_partner.py index d803e9a74..39b4080c9 100644 --- a/hotel/models/inherited_res_partner.py +++ b/hotel/models/inherited_res_partner.py @@ -63,7 +63,6 @@ class ResPartner(models.Model): for i, record in enumerate(self): if record.unconfirmed is True: partner_dst = self.env['res.partner']._check_duplicated_partner(record) - return res = super(ResPartner, self).write(vals) return res diff --git a/hotel_l10n_es/models/inherit_hotel_checkin_partner.py b/hotel_l10n_es/models/inherit_hotel_checkin_partner.py index 5314d50ee..b14608d89 100644 --- a/hotel_l10n_es/models/inherit_hotel_checkin_partner.py +++ b/hotel_l10n_es/models/inherit_hotel_checkin_partner.py @@ -30,6 +30,7 @@ class HotelCheckinPartner(models.Model): document_number = fields.Char(related='partner_id.document_number') document_expedition_date = fields.Date(related='partner_id.document_expedition_date') gender = fields.Selection('Gender', related='partner_id.gender') + birthdate_date = fields.Date('Birhdate', related='partner_id.birthdate_date') code_ine_id = fields.Many2one(related="partner_id.code_ine_id") #TMP_FIX VAT Validation diff --git a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml index 5ab2c0fd5..dee25f35c 100644 --- a/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml +++ b/hotel_l10n_es/views/inherit_hotel_checkin_partner_views.xml @@ -35,6 +35,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/hotel_l10n_es/wizard/police_wizard.py b/hotel_l10n_es/wizard/police_wizard.py index a9b9462b4..c31cca439 100644 --- a/hotel_l10n_es/wizard/police_wizard.py +++ b/hotel_l10n_es/wizard/police_wizard.py @@ -41,9 +41,9 @@ class PoliceWizard(models.TransientModel): def generate_file(self): company = self.env.user.company_id if company.police_number is not False and company.property_name is not False: - lines = self.env['cardex'].search([('enter_date', '=', + lines = self.env['hotel.checkin.partner'].search([('enter_date', '=', self.download_date)]) - content = "1|"+company.police_number+"|"+compa.property_name.upper()[0:40] + content = "1|"+company.police_number+"|"+company.property_name.upper()[0:40] content += "|" content += datetime.datetime.now().strftime("%Y%m%d|%H%M") content += "|"+str(len(lines)) + """ From bae27d9fc3e0604ace2bd504216f5b23791e50cf Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 18:03:11 +0100 Subject: [PATCH 4/8] [WIP] INE Wizard --- hotel/models/hotel_reservation.py | 2 +- hotel_l10n_es/wizard/ine_wizard.py | 26 ++++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 8f4590cb9..dca880991 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -214,9 +214,9 @@ class HotelReservation(models.Model): partner_invoice_country_id = fields.Many2one(related="partner_invoice_id.country_id") partner_invoice_email = fields.Char(related="partner_invoice_id.email") partner_invoice_lang = fields.Selection(related="partner_invoice_id.lang") - closure_reason_id = fields.Many2one(related='folio_id.closure_reason_id') partner_invoice_type = fields.Selection(related="partner_invoice_id.type") partner_invoice_parent_id = fields.Many2one(related="partner_invoice_id.parent_id") + closure_reason_id = fields.Many2one(related='folio_id.closure_reason_id') partner_diff_invoicing = fields.Boolean('Bill to another Address', default='_default_diff_invoicing') company_id = fields.Many2one(related='folio_id.company_id', string='Company', store=True, readonly=True) reservation_line_ids = fields.One2many('hotel.reservation.line', diff --git a/hotel_l10n_es/wizard/ine_wizard.py b/hotel_l10n_es/wizard/ine_wizard.py index fd8009cda..46a1fb29f 100644 --- a/hotel_l10n_es/wizard/ine_wizard.py +++ b/hotel_l10n_es/wizard/ine_wizard.py @@ -28,7 +28,6 @@ import xml.etree.cElementTree as ET from openerp.exceptions import UserError - def get_years(): year_list = [] for i in range(2017, get_year()+1): @@ -120,7 +119,7 @@ class IneWizard(models.TransientModel): [('capacity', '>', 0)]) ET.SubElement(cabezera, "HABITACIONES").text = str(active_room) ET.SubElement(cabezera, "PLAZAS_DISPONIBLES_SIN_SUPLETORIAS" - ).text = str(company.seats) + ).text = str(company.ine_seats) ET.SubElement(cabezera, "URL").text = company.website alojamiento = ET.SubElement(encuesta, "ALOJAMIENTO") # Bucle de RESIDENCIA @@ -140,8 +139,6 @@ class IneWizard(models.TransientModel): code_control = lines[0].partner_id.code_ine_id.code if code_control is False: - _logger.error('Usuario sin codigo de INE: ' + - lines[0].partner_id.name) raise UserError(_('ERROR: Usuario sin codigo de INE: ' + lines[0].partner_id.name)) @@ -232,12 +229,10 @@ class IneWizard(models.TransientModel): ('checkin', '<=', str(m_f_d_search)), ('checkout', '>=', str(m_e_d_search))], order="checkin") for line_res in lines_res: - room = self.env['hotel.room'].search([( - 'product_id', '=', line_res.product_id.id)]) + room = line_res.room_id # No es Staff o Out y esta booking if (line_res.reservation_type == 'normal') and ( - (line_res.state == 'booking') or ( - line_res.state == 'done')): + (line_res.state == 'booking') or (line_res.state == 'done')): # calculamos capacidad de habitacion # !!!!! ATENCION !!!! @@ -250,8 +245,8 @@ class IneWizard(models.TransientModel): capacidad = room.capacity + suple_room # Cuadramos adultos con los checkin realizados. - if line_res.adults > line_res.cardex_count: - adultos = line_res.cardex_count + if line_res.adults > line_res.checkin_partner_count: + adultos = line_res.checkin_partner_count else: adultos = line_res.adults @@ -259,7 +254,6 @@ class IneWizard(models.TransientModel): f_salida = line_res.checkout.split('-') f_entrada[2] = f_entrada[2].split()[0] f_salida[2] = f_salida[2].split()[0] - # Ha entrado este mes if int(f_entrada[1]) == self.ine_month: ine_entrada[int(f_entrada[2])] += 1 @@ -306,7 +300,7 @@ class IneWizard(models.TransientModel): # Otras Habitaciones movimientos[dia_x-1][3] += 1 else: - _logger.info(str(dia_x) + + raise UserError(str(dia_x) + 'Exceso de habitaciones ' + str(line_res) + ' ' + line_res.name + ' ' + line_res.partner_id.name + @@ -355,13 +349,10 @@ class IneWizard(models.TransientModel): "HABITACIONES_MOVIMIENTO") ET.SubElement(habitaciones_m, "HABITACIONES_N_DIA").text = "%02d" % (dia_x) - if ine_pernoct_total[dia_x] > company.seats: + if ine_pernoct_total[dia_x] > company.ine_seats: # Añadimos Supletorias por si excedemos plazas movimientos[dia_x][0] = (ine_pernoct_total[dia_x] - - company.seats) - _logger.info(' Dia: ' + str(dia_x) + - ' [ADD] Supletorias a : ' + - str(movimientos[dia_x][0])) + - company.ine_seats) ET.SubElement(habitaciones_m, "PLAZAS_SUPLETORIAS").text = str( movimientos[dia_x][0]) @@ -448,4 +439,3 @@ class IneWizard(models.TransientModel): return self.write({ 'rev_screen': _('No data in this month') }) - From 5999a705e8b5008302a1743ea13cc64407f89ccf Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Mon, 11 Feb 2019 18:10:44 +0100 Subject: [PATCH 5/8] [DEL] l10n_es Wizard checkin --- hotel/__manifest__.py | 1 - hotel/wizard/__init__.py | 1 - hotel/wizard/checkinwizard.py | 221 ------------------ hotel/wizard/checkinwizard.xml | 104 --------- hotel_l10n_es/__manifest__.py | 1 - hotel_l10n_es/wizard/__init__.py | 1 - .../wizard/inherit_checkin_wizard.py | 172 -------------- .../wizard/inherit_checkin_wizard.xml | 37 --- 8 files changed, 538 deletions(-) delete mode 100644 hotel/wizard/checkinwizard.py delete mode 100644 hotel/wizard/checkinwizard.xml delete mode 100644 hotel_l10n_es/wizard/inherit_checkin_wizard.py delete mode 100644 hotel_l10n_es/wizard/inherit_checkin_wizard.xml diff --git a/hotel/__manifest__.py b/hotel/__manifest__.py index ff768ccc2..c5f3201a2 100644 --- a/hotel/__manifest__.py +++ b/hotel/__manifest__.py @@ -29,7 +29,6 @@ 'data/menus.xml', 'views/inherited_account_payment_views.xml', 'views/inherited_account_invoice_views.xml', - 'wizard/checkinwizard.xml', 'wizard/massive_price_reservation_days.xml', 'wizard/folio_make_invoice_advance_views.xml', 'data/hotel_sequence.xml', diff --git a/hotel/wizard/__init__.py b/hotel/wizard/__init__.py index 9fbcd6f9e..2717e90d1 100644 --- a/hotel/wizard/__init__.py +++ b/hotel/wizard/__init__.py @@ -22,7 +22,6 @@ # ############################################################################## from . import folio_make_invoice_advance -from . import checkinwizard from . import massive_changes from . import split_reservation from . import duplicate_reservation diff --git a/hotel/wizard/checkinwizard.py b/hotel/wizard/checkinwizard.py deleted file mode 100644 index 8bb5b669e..000000000 --- a/hotel/wizard/checkinwizard.py +++ /dev/null @@ -1,221 +0,0 @@ -import logging -from openerp import models, fields, api -_logger = logging.getLogger(__name__) - - -class Wizard(models.TransientModel): - _name = 'checkin.wizard' - - def default_enter_date(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin - if 'enter_date' in self.env.context: - return self.env.context['enter_date'] - return False - - def default_exit_date(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkout - if 'exit_date' in self.env.context: - return self.env.context['exit_date'] - return False - - def default_reservation_id(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - if len(reservations) == 1: - # return current room line (onlyone in this case) - return reservations - for res in reservations: - # return the first room line with free space for a checkin - # TODO: add 'done' to res.state condition... Maybe too restrictive right now - if res.checkin_partner_count < (res.adults + res.children) and \ - res.state not in ["cancelled"]: - return res - elif 'reservation_id' in self.env.context: - return self.env['hotel.reservation'].browse( - self.env.context['reservation_id']) - - _logger.info('default_reservation_id is FALSE') - return False - - def default_partner_id(self): - # no partner by default. User must search and choose one - return False - - def default_checkin_partner_ids(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin_partner_ids - - def default_checkin_partner_ids(self): - if ('reservation_ids' and 'folio') in self.env.context: - ids = [item[1] for item in self.env.context.get('reservation_ids')] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.segmentation_id - - ''' TODO: clean-up - def default_count_checkin_partner(self): - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.checkin_partner_count - ''' - ''' TODO: clean-up - def default_pending_checkin_partner(self): - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - return res.adults + res.children - res.checkin_partner_count - ''' - ''' TODO: clean-up - list of checkins on smart button clean is not used anymore - def comp_checkin_list_visible(self): - if 'partner_id' in self.env.context: - self.list_checkin_checkin_partner = False - return - ''' - def comp_checkin_edit(self): - if 'edit_checkin_partner' in self.env.context: - return True - return False - - checkin_partner_ids = fields.Many2many('hotel.checkin.partner', 'reservation_id', - default=default_checkin_partner_ids) - # count_checkin_partner = fields.Integer('Checkin counter', - # default=default_count_checkin_partner) - # pending_checkin_partner = fields.Integer('Checkin pending', - # default=default_pending_checkin_partner) - partner_id = fields.Many2one('res.partner', - default=default_partner_id) - reservation_id = fields.Many2one('hotel.reservation', - default=default_reservation_id) - enter_date = fields.Date(default=default_enter_date, - required=True) - exit_date = fields.Date(default=default_exit_date, - required=True) - - firstname_checkin_partner = fields.Char('Firstname', - required=True) - lastname_checkin_partner = fields.Char('Lastname', - required=True) - - email_checkin_partner = fields.Char('E-mail') - - mobile_checkin_partner = fields.Char('Mobile') - - segmentation_ids = fields.Many2many( - related='reservation_id.segmentation_ids') - - - ''' TODO: clean-up - list of checkins on smart button clean is not used anymore - list_checkin_checkin_partner = fields.Boolean(compute=comp_checkin_list_visible, - default=True, store=True) - ''' - # edit_checkin_checkin_partner = fields.Boolean(default=comp_checkin_edit, - # store=True) - - op_select_partner = fields.Selection([ - ('S', 'Select a partner for checkin'), - ('C', 'Create a new partner for checkin') - ], default='S', string='Partner for checkin') - # checkin mode: - # 0 - no selection made by the user, so hide the client fields - # 1 - select a client for update his values and do the checkin - # 2 - create a new client with the values and do the checkin - checkin_mode = fields.Integer(default=0) - - @api.multi - def action_save_check(self): - # prepare partner values - if self.op_select_partner == 'S': - partner_vals = { - 'id': self.partner_id.id, - 'firstname': self.firstname_checkin_partner, - 'lastname': self.lastname_checkin_partner, - 'email': self.email_checkin_partner, - 'mobile': self.mobile_checkin_partner, - } - self.partner_id.sudo().write(partner_vals) - elif self.op_select_partner == 'C': - partner_vals = { - 'firstname': self.firstname_checkin_partner, - 'lastname': self.lastname_checkin_partner, - 'email': self.email_checkin_partner, - 'mobile': self.mobile_checkin_partner, - } - new_partner = self.env['res.partner'].create(partner_vals) - self.partner_id = self.env['res.partner'].browse(new_partner.id) - - # prepare checkin values - checkin_partner_val = { - 'partner_id': self.partner_id.id, - 'enter_date': self.enter_date, - 'exit_date': self.exit_date - } - record_id = self.env['hotel.reservation'].browse( - self.reservation_id.id) - # save the checkin for this reservation - record_id.write({ - 'checkin_partner_ids': [(0, False, checkin_partner_val)], - 'segmentation_id': self.segmentation_id, - }) - - # update the state of the current reservation - if record_id.checkin_partner_count > 0: - record_id.state = 'booking' - - @api.onchange('reservation_id') - def change_enter_exit_date(self): - record_id = self.env['hotel.reservation'].browse( - self.reservation_id.id) - - self.enter_date = record_id.checkin - self.exit_date = record_id.checkout - - ''' trying to filter the reservations only to pending checkins ... - if 'reservation_ids' and 'folio' in self.env.context: - ids = [item[1] for item in self.env.context['reservation_ids']] - reservations = self.env['hotel.reservation'].browse(ids) - for res in reservations: - _logger.info('reservation checkin_partner_count %d', res.checkin_partner_count) - - # return { - # 'domain': {'reservation_id': [('folio_id','=', self.env.context['folio']), 'count_checkin_partner','=','2']}, - # 'warning': {'title': "Warning", 'message': self.env.context['checkin_partner_count']}, - # } - ''' - - @api.onchange('partner_id') - def onchange_partner_id(self): - # update partner fields - write_vals = { - 'firstname_checkin_partner': self.partner_id.firstname, - 'lastname_checkin_partner': self.partner_id.lastname, - 'email_checkin_partner': self.partner_id.email, - 'mobile_checkin_partner': self.partner_id.mobile, - } - # show the checkin fields if a partner is selected - if self.op_select_partner == 'S' and self.partner_id.id != False: - write_vals.update({'checkin_mode': 1}) - self.update(write_vals) - - @api.onchange('op_select_partner') - def onchange_op_select_partner(self): - # field one2many return false is record does not exist - if self.op_select_partner == 'S' and self.partner_id.id: - self.checkin_mode = 1 - # field one2many return 0 on empty record (nothing typed) - elif self.op_select_partner == 'C' and self.partner_id.id == 0: - self.checkin_mode = 2 diff --git a/hotel/wizard/checkinwizard.xml b/hotel/wizard/checkinwizard.xml deleted file mode 100644 index 6b582c9c9..000000000 --- a/hotel/wizard/checkinwizard.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - wizard.form2 - checkin.wizard - -

- - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - - - - Add Check - checkin.wizard - - new - - - - - - - -
diff --git a/hotel_l10n_es/__manifest__.py b/hotel_l10n_es/__manifest__.py index 39e66b520..34086fe90 100644 --- a/hotel_l10n_es/__manifest__.py +++ b/hotel_l10n_es/__manifest__.py @@ -43,7 +43,6 @@ 'views/report_viajero.xml', 'wizard/police_wizard.xml', 'wizard/ine_wizard.xml', - 'wizard/inherit_checkin_wizard.xml', 'views/category_tourism.xml', 'views/code_ine.xml', 'views/inherit_res_company.xml', diff --git a/hotel_l10n_es/wizard/__init__.py b/hotel_l10n_es/wizard/__init__.py index 0bd21cdd8..9da10d1bc 100644 --- a/hotel_l10n_es/wizard/__init__.py +++ b/hotel_l10n_es/wizard/__init__.py @@ -21,5 +21,4 @@ ############################################################################## from . import police_wizard -from . import inherit_checkin_wizard from . import ine_wizard diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.py b/hotel_l10n_es/wizard/inherit_checkin_wizard.py deleted file mode 100644 index f768a92ca..000000000 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.py +++ /dev/null @@ -1,172 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2018 Alda Hotels -# Jose Luis Algara -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp import models, fields, api -from openerp.exceptions import UserError -from openerp.tools.translate import _ -from datetime import datetime, timedelta - -class CheckinWizard(models.TransientModel): - _inherit = 'checkin.wizard' - - def validation_under_age(self): - if self.birthdate_date_cardex != False: - years = str(datetime.now().date() - timedelta(days=365*16+4)) - limit_date = datetime.strptime(years, "%Y-%m-%d") - birth_date = datetime.strptime(self.birthdate_date_cardex, '%Y-%m-%d') - limit = str(limit_date.day)+ ' de ' + str(limit_date.month)+ ' de ' + str(limit_date.year) - if limit_date < birth_date: - return {'warning': {'title': _('Error in Birthdate'), 'message': _('Does the client have less than 16 years?. Data collection is not performed for those born before %s.' % (limit)),},} - if self.polexpedition_cardex != False: - if self.birthdate_date_cardex > self.polexpedition_cardex: - raise ValidationError(_('Date of document shipment, prior to birth date')) - - @api.onchange('polexpedition_cardex') - def validation_polexpedition(self): - if self.birthdate_date_cardex != False and self.polexpedition_cardex != False: - if self.birthdate_date_cardex > self.polexpedition_cardex: - return {'warning': {'title': _('Error in Birthdate or Expedition date'), 'message': _('Date of document shipment, prior to birth date'),},} - - # Validation for DNI/Permiso conducir erroneo - @api.onchange('poldocument_cardex', 'documenttype_cardex') - def validation_poldocument_dni(self): - if self.poldocument_cardex != False: - if self.documenttype_cardex in ['D','C']: - validcaracter = "TRWAGMYFPDXBNJZSQVHLCKE" - dig_ext = "XYZ" - reemp_dig_ext = {'X':'0', 'Y':'1', 'Z':'2'} - numeros = "1234567890" - dni = self.poldocument_cardex.upper() - if len(dni) == 9: - dig_control = dni[8] - dni = dni[:8] - # 'extranjero empieza por XYZ' - if dni[0] in dig_ext: - dni = dni.replace(dni[0], reemp_dig_ext[dni[0]]) - if not ((len(dni) == len([n for n in dni if n in numeros])) and (validcaracter[int(dni)%23] == dig_control)): - return {'warning': {'title': _('Error in DNI/NIE/DRIVE LICENSE'), 'message': _('Wrong DNI/NIE/DRIVE LICENSE, check it.'),},} - else: - return {'warning': {'title': _('Error in DNI/NIE/DRIVE LICENSE'), 'message': _('DNI/NIE/DRIVE LICENSE erroneous length, the correct format is: (12345678A or X1234567A)'),},} - - # Validation for Tipo de documento no valido para Extranjero - # @api.onchange('x') - # Pendiente - - # Validation for Nacionalidad erronea - # @api.onchange('x') - # Pendiente - - # NOTE: All the fields are required but they are set required=True in the .xml - # The reason is found in the bt_select_partner and bt_create_partner buttons to bypass the ORM null constraint - # when the buttons are clicked to show the hidden fields - - documenttype_cardex = fields.Selection([ - ('D', 'DNI'), - ('P', 'Pasaporte'), - ('C', 'Permiso de Conducir'), - ('I', 'Carta o Doc. de Identidad'), - ('N', 'Permiso Residencia Español'), - ('X', 'Permiso Residencia Europeo')], - help='Select a valid document type', - default='D', - string='Doc. type') - - poldocument_cardex = fields.Char('Doc. number') - - polexpedition_cardex = fields.Date('Expedition date') - - gender_cardex = fields.Selection([('male', 'Male'), ('female', 'Female')]) - - birthdate_date_cardex = fields.Date("Birthdate") - - code_ine_cardex = fields.Many2one('code.ine', - help='Country or province of origin. Used for INE statistics.') - - # TODO: Add tags in the cardex not in the partner anb move this field to out of localization - #category_id_cardex = fields.Many2many('res.partner.category', 'id', required=True) - - @api.multi - def pdf_viajero(self, cardex_id): - cardex = self.env['cardex'].search([('id', '=', cardex_id)]) - return self.env['report'].get_action(cardex, 'action.report.viajero') - - @api.multi - def action_save_check(self): - # Check dates - self.validation_under_age() - # take a 'snapshot' of the current cardexes in this reservation - record_id = self.env['hotel.reservation'].browse(self.reservation_id.id) - old_cardex = self.env['cardex'].search([('reservation_id', '=', record_id.id)]) - - # the above lines must be executed before call the super().action_save_check() - - # call the super action_save_check() for checkin - super(Wizard, self).action_save_check() - - # prepare category in partner from category_id - the_list = self.segmentation_id - self.partner_id.category_id - the_list = self.partner_id.category_id + the_list - - # prepare localization partner values - partner_vals = { - 'documenttype': self.documenttype_cardex, - 'poldocument': self.poldocument_cardex, - 'polexpedition': self.polexpedition_cardex, - 'gender': self.gender_cardex, - 'birthdate_date': self.birthdate_date_cardex, - # (4, ID) link to existing record with id = ID (adds a relationship) ... - 'code_ine': self.code_ine_cardex.id, - # (6, 0, [IDs]) replace the list of linked IDs ... - 'category_id': [(6, False, [x.id for x in the_list])], - } - - # Update Accounting VAT number on customer - if self.documenttype_cardex in ('D','C'): - partner_vat = 'ES' + self.poldocument_cardex - partner_vals.update({ - 'vat': partner_vat - }) - - # Are you templed to merge the following write with the super() ? - # Be warned: Premature optimization is the root of all evil -- DonaldKnuth - # This TransientModel inherit from checkin.wizard and it is intended for localization - # So, if you need to write something here must be _after_ the super() - - # update the localization partner values for this reservation - self.partner_id.sudo().write(partner_vals); - - # get the last cardex in this reservation (set difference theory) - cardex = self.env['cardex'].search([('reservation_id', '=', record_id.id)]) - old_cardex - return self.pdf_viajero(cardex.id) - - @api.onchange('partner_id') - def onchange_partner_id(self): - # call the super update_partner_fields - super(Wizard, self).onchange_partner_id() - # update local fields - self.documenttype_cardex = self.partner_id.documenttype; - self.poldocument_cardex = self.partner_id.poldocument; - self.polexpedition_cardex = self.partner_id.polexpedition; - self.gender_cardex = self.partner_id.gender; - self.birthdate_date_cardex = self.partner_id.birthdate_date; - self.code_ine_cardex = self.partner_id.code_ine; - #self.category_id_cardex = self.partner_id.category_id; diff --git a/hotel_l10n_es/wizard/inherit_checkin_wizard.xml b/hotel_l10n_es/wizard/inherit_checkin_wizard.xml deleted file mode 100644 index ed1e8c69f..000000000 --- a/hotel_l10n_es/wizard/inherit_checkin_wizard.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - wizard.form2 - checkin.wizard - - - - - - - - - - - - - - - - - - - - - -