[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,13 @@
DOOR CODES
==========
Generate HOTEL DOOR CODES
Credits
=======
Creator
------------
* Jose Luis Algara Toledo <osotranquilo@gmail.com>

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2018-2019 Jose Luis Algara Toledo <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 models
from . import wizard

View File

@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 2018-2019 Jose Luis Algara Toledo <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/>.
#
##############################################################################
{
'name': 'Hotel Door Codes',
'version': '2.1',
'author': "Jose Luis Algara Toledo <osotranquilo@gmail.com>",
'website': 'https://www.aldahotels.com',
'category': 'hotel code',
'summary': "Generate Hotel door codes, in Pseudo random system",
'description': "Hotel Door Codes",
'depends': [
'hotel', 'hotel_l10n_es'
],
'data': [
'wizard/door_code.xml',
'data/menus.xml',
'views/inherit_res_company.xml',
'views/inherit_hotel_reservation.xml',
'views/inherit_report_viajero.xml',
],
'qweb': [],
'test': [
],
'installable': True,
'auto_install': False,
'application': False,
'license': 'AGPL-3',
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem
id="menu_hotel_door_code"
name="Codigos para la Puerta"
parent="hotel.hotel_reports_menu"
action="door_code_act"
groups="hotel.group_hotel_user,hotel.group_hotel_manager"
sequence="45"
/>
</data>
</odoo>

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='')

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Hotel Settings -->
<data>
<!-- Inherit Company view to add 'door_code' in Reservation Form -->
<record id="door_code_reservation_form" model="ir.ui.view">
<field name="name">door_code.reservation_form</field>
<field name="model">hotel.reservation</field>
<field name="inherit_id" ref="hotel.hotel_reservation_view_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='others']" position="after">
<page name="doorcode" string="Códigos entrada">
<group>
<field name="door_codes" />
<field name="box_number" />
<field name="box_code" />
</group>
</page>
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Hotel Settings -->
<data>
<!-- Inherit viajero repdort to add 'door_code' -->
<template id="door_code_view_report" inherit_id="hotel_l10n_es.report_viajero_document">
<xpath expr="//div[@class='final']" position="replace">
<div class ="doorcodes" style="font-size:1.8em;">
<span t-field="o.reservation_id.door_codes"/>
</div>
</xpath>
</template>
</data>
</odoo>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Hotel Settings -->
<data>
<!-- Inherit Company view to add 'door_code' -->
<record id="door_code_view_company_form" model="ir.ui.view">
<field name="name">door_code.config.view_company_form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='cardex_warning']" position="after">
<field name="precode" />
<field name="postcode" />
</xpath>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2018-2019 Jose Luis Algara Toledo <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 door_code

View File

@@ -0,0 +1,78 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 2018-2019 Jose Luis Algara Toledo <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/>.
#
##############################################################################
import datetime
from datetime import datetime, date, time, timedelta
from odoo import api, fields, models, _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
class DoorCodeWizard(models.TransientModel):
_name = 'door_code'
@api.model
def _get_default_date_start(self):
return datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
date_start = fields.Date("Inicio periodo",
default=_get_default_date_start)
date_end = fields.Date("Fin del periodo",
default=_get_default_date_start)
door_code = fields.Html(u'Código para la puerta')
@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 check_code(self):
entrada = datetime.strptime(
self.date_start, DEFAULT_SERVER_DATE_FORMAT)
if datetime.weekday(entrada) == 0:
entrada = entrada + timedelta(days=1)
salida = datetime.strptime(
self.date_end, 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: 2em;">' +
self.doorcode4(self.date_start) +
'</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: 2em;">' +
self.doorcode4(datetime.strftime(
entrada, "%Y-%m-%d")) +
'</span></strong>')
entrada = entrada + timedelta(days=1)
return self.write({
'door_code': codes
})

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" ?>
<odoo>
<data>
<record model="ir.ui.view" id="hotel_door_code_view">
<field name="name">door_code.view</field>
<field name="model">door_code</field>
<field name="arch" type="xml">
<form string="Door Code Generator" >
<sheet>
<group>
<group>
<field name="date_start" required="1" />
<field name="date_end" required="1" />
</group>
</group>
<group>
<field name="door_code" readonly="1"/>
</group>
<footer>
<button name="check_code" string="Generate Code" type="object" class="oe_highlight" />
</footer>
</sheet>
</form>
</field>
</record>
<act_window
id="door_code_act"
name="Door Code Generator"
res_model="door_code"
view_mode="form"
/>
</data>
</odoo>

View File

@@ -56,6 +56,8 @@
Asimismo hemos solicitado que confirme esta autorización para ofrecerle nuestros servicios y poder fidelizarle como cliente.</p> Asimismo hemos solicitado que confirme esta autorización para ofrecerle nuestros servicios y poder fidelizarle como cliente.</p>
</div> </div>
</div> </div>
<div class="final">
</div>
</template> </template>
</data> </data>
</odoo> </odoo>