[ADD] Door Codes in Hotels

This commit is contained in:
Jose Luis
2019-03-20 19:30:12 +01:00
parent 210e8a8fc5
commit 2ab1663cb2
15 changed files with 407 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2018-2019 Alda Hotels <informatica@aldahotels.com>
# Jose Luis Algara <osotranquilo@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import inherit_res_company
from . import inherit_hotel_reservation

View File

@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2018-2019 Alda Hotels <informatica@aldahotels.com>
# Jose Luis Algara <osotranquilo@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
from datetime import datetime, date, time, timedelta
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
class Inherit_hotel_reservation(models.Model):
_inherit = 'hotel.reservation'
@api.multi
def doorcode4(self, fecha):
# Calculate de Door Code... need a date in String format "%Y-%m-%d"
compan = self.env.user.company_id
d = datetime.strptime(fecha, DEFAULT_SERVER_DATE_FORMAT)
dia_semana = datetime.weekday(d) # Dias a restar y ponerlo en lunes
d = d - timedelta(days=dia_semana)
dtxt = d.strftime('%s.%%06d') % d.microsecond
dtxt = compan.precode + dtxt[4:8] + compan.postcode
return dtxt
@api.multi
def _compute_door_codes(self):
for res in self:
entrada = datetime.strptime(
res.checkin[:10], DEFAULT_SERVER_DATE_FORMAT)
if datetime.weekday(entrada) == 0:
entrada = entrada + timedelta(days=1)
salida = datetime.strptime(
res.checkout[:10], DEFAULT_SERVER_DATE_FORMAT)
if datetime.weekday(salida) == 0:
salida = salida - timedelta(days=1)
codes = (u'Código de entrada: ' +
'<strong><span style="font-size: 1.4em;">' +
res.doorcode4(datetime.strftime(entrada, "%Y-%m-%d")) +
'</span></strong>')
while entrada <= salida:
if datetime.weekday(entrada) == 0:
codes += ("<br>" +
u'Cambiará el Lunes ' +
datetime.strftime(entrada, "%d-%m-%Y") +
' a: <strong><span style="font-size: 1.4em;">' +
res.doorcode4(datetime.strftime(
entrada, "%Y-%m-%d")) +
'</span></strong>')
entrada = entrada + timedelta(days=1)
res.door_codes = codes
door_codes = fields.Html(u'Códigos de entrada',
compute='_compute_door_codes')
box_number = fields.Integer ('Numero de Caja')
box_code = fields.Char ('Cod. Caja')

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2018-2019 Alda Hotels <informatica@aldahotels.com>
# Jose Luis Algara <osotranquilo@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
class Inherit_res_company(models.Model):
_inherit = 'res.company'
precode = fields.Char('Characters before the door code', default='')
postcode = fields.Char('Characters after the code', default='')