diff --git a/hotel_door_codes/README.rst b/hotel_door_codes/README.rst new file mode 100644 index 000000000..39b189275 --- /dev/null +++ b/hotel_door_codes/README.rst @@ -0,0 +1,13 @@ +DOOR CODES +========== + +Generate HOTEL DOOR CODES + + +Credits +======= + +Creator +------------ + +* Jose Luis Algara Toledo diff --git a/hotel_door_codes/__init__.py b/hotel_door_codes/__init__.py new file mode 100644 index 000000000..d81805226 --- /dev/null +++ b/hotel_door_codes/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2018-2019 Jose Luis Algara Toledo +# +# 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 . import models +from . import wizard diff --git a/hotel_door_codes/__manifest__.py b/hotel_door_codes/__manifest__.py new file mode 100644 index 000000000..299e75b83 --- /dev/null +++ b/hotel_door_codes/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, Open Source Management Solution +# Copyright (C) 2018-2019 Jose Luis Algara Toledo +# +# 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 . +# +############################################################################## + +{ + 'name': 'Hotel Door Codes', + 'version': '2.1', + 'author': "Jose Luis Algara Toledo ", + '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', +} diff --git a/hotel_door_codes/data/menus.xml b/hotel_door_codes/data/menus.xml new file mode 100644 index 000000000..ce3b25d84 --- /dev/null +++ b/hotel_door_codes/data/menus.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/hotel_door_codes/models/__init__.py b/hotel_door_codes/models/__init__.py new file mode 100644 index 000000000..71658e650 --- /dev/null +++ b/hotel_door_codes/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2018-2019 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 . import inherit_res_company +from . import inherit_hotel_reservation diff --git a/hotel_door_codes/models/inherit_hotel_reservation.py b/hotel_door_codes/models/inherit_hotel_reservation.py new file mode 100644 index 000000000..0ed077f4f --- /dev/null +++ b/hotel_door_codes/models/inherit_hotel_reservation.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2018-2019 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 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: ' + + '' + + res.doorcode4(datetime.strftime(entrada, "%Y-%m-%d")) + + '') + while entrada <= salida: + if datetime.weekday(entrada) == 0: + codes += ("
" + + u'Cambiará el Lunes ' + + datetime.strftime(entrada, "%d-%m-%Y") + + ' a: ' + + res.doorcode4(datetime.strftime( + entrada, "%Y-%m-%d")) + + '') + 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') diff --git a/hotel_door_codes/models/inherit_res_company.py b/hotel_door_codes/models/inherit_res_company.py new file mode 100644 index 000000000..181d6424c --- /dev/null +++ b/hotel_door_codes/models/inherit_res_company.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2018-2019 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 + + +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='') diff --git a/hotel_door_codes/static/description/icon.png b/hotel_door_codes/static/description/icon.png new file mode 100644 index 000000000..0d7c99f06 Binary files /dev/null and b/hotel_door_codes/static/description/icon.png differ diff --git a/hotel_door_codes/views/inherit_hotel_reservation.xml b/hotel_door_codes/views/inherit_hotel_reservation.xml new file mode 100644 index 000000000..3c236a4e4 --- /dev/null +++ b/hotel_door_codes/views/inherit_hotel_reservation.xml @@ -0,0 +1,23 @@ + + + + + + + door_code.reservation_form + hotel.reservation + + + + + + + + + + + + + + + diff --git a/hotel_door_codes/views/inherit_report_viajero.xml b/hotel_door_codes/views/inherit_report_viajero.xml new file mode 100644 index 000000000..0e1257ddf --- /dev/null +++ b/hotel_door_codes/views/inherit_report_viajero.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/hotel_door_codes/views/inherit_res_company.xml b/hotel_door_codes/views/inherit_res_company.xml new file mode 100644 index 000000000..b1638a40d --- /dev/null +++ b/hotel_door_codes/views/inherit_res_company.xml @@ -0,0 +1,18 @@ + + + + + + + door_code.config.view_company_form + res.company + + + + + + + + + + diff --git a/hotel_door_codes/wizard/__init__.py b/hotel_door_codes/wizard/__init__.py new file mode 100644 index 000000000..180966b56 --- /dev/null +++ b/hotel_door_codes/wizard/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2018-2019 Jose Luis Algara Toledo +# +# 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 . import door_code diff --git a/hotel_door_codes/wizard/door_code.py b/hotel_door_codes/wizard/door_code.py new file mode 100644 index 000000000..334be679a --- /dev/null +++ b/hotel_door_codes/wizard/door_code.py @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Odoo, Open Source Management Solution +# Copyright (C) 2018-2019 Jose Luis Algara Toledo +# +# 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 . +# +############################################################################## +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: ' + + '' + + self.doorcode4(self.date_start) + + '') + while entrada <= salida: + if datetime.weekday(entrada) == 0: + codes += ("
" + + u'Cambiará el Lunes ' + + datetime.strftime(entrada, "%d-%m-%Y") + + ' a: ' + + self.doorcode4(datetime.strftime( + entrada, "%Y-%m-%d")) + + '') + entrada = entrada + timedelta(days=1) + + return self.write({ + 'door_code': codes + }) diff --git a/hotel_door_codes/wizard/door_code.xml b/hotel_door_codes/wizard/door_code.xml new file mode 100644 index 000000000..f0506a79c --- /dev/null +++ b/hotel_door_codes/wizard/door_code.xml @@ -0,0 +1,33 @@ + + + + + door_code.view + door_code + +
+ + + + + + + + + + +
+
+
+
+
+
+ +
+
diff --git a/hotel_l10n_es/views/report_viajero_document.xml b/hotel_l10n_es/views/report_viajero_document.xml index e3b6f194f..e66c18ce7 100755 --- a/hotel_l10n_es/views/report_viajero_document.xml +++ b/hotel_l10n_es/views/report_viajero_document.xml @@ -56,6 +56,8 @@ Asimismo hemos solicitado que confirme esta autorización para ofrecerle nuestros servicios y poder fidelizarle como cliente.

+
+