[ADD] INE module

This commit is contained in:
Jose Luis
2019-05-17 14:54:15 +02:00
parent b7666aa439
commit 28dbe10a7f
10 changed files with 162 additions and 449 deletions

22
hotel_ine/__init__.py Normal file
View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 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 wizard

40
hotel_ine/__manifest__.py Normal file
View File

@@ -0,0 +1,40 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
# Copyright (C) 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 Ine',
'description': """
Create de INE Report""",
'version': '1.0.0',
'license': 'AGPL-3',
'summary': "Export hotel data for INE report",
'author': "Jose Luis Algara (Alda hotels) <osotranquilo@gmail.com>",
'website': 'www.aldahotels.com',
'depends': ['hotel', 'hotel_l10n_es'],
'category': 'hotel/ine',
'data': [
'wizard/inewizard.xml',
],
'demo': [
],
'installable': True,
'auto_install': False,
'application': False,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 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 inewizard

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2017 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, _
import base64
import datetime
import calendar
import xml.etree.cElementTree as ET
from openerp.exceptions import UserError
import logging
_logger = logging.getLogger(__name__)
def _get_default_date(option):
now = datetime.datetime.now()
month = int(now.month)-1
year = int(now.year)
if month <= 0:
month = 12
year -= year
start_date = datetime.datetime(year, month, 1)
end_date = calendar.monthrange(year, month)[1] - 1
month_end_date = start_date + datetime.timedelta(days=end_date)
if option == "start":
return start_date
return month_end_date
class Wizard(models.TransientModel):
_name = 'ine.wizard'
@api.onchange('ine_start')
def onchange_ine_start(self):
if self.ine_start > self.ine_end:
self.ine_start = self.ine_end
txt_filename = fields.Char()
txt_binary = fields.Binary()
ine_start = fields.Date("Fecha inicio", default=_get_default_date('start'))
ine_end = fields.Date("Fecha final", default=_get_default_date('end'))
adr_screen = fields.Char()
rev_screen = fields.Char()
# Debug Stop -------------------
# import wdb; wdb.set_trace()
# Debug Stop -------------------

View File

@@ -0,0 +1,54 @@
<?xml version="1.0"?>
<openerp>
<data>
<act_window
id="action_ine_download"
name="Action INE File Download"
res_model="ine.wizard"
view_mode="form"
/>
<record id="view_ine_download" model="ir.ui.view">
<field name="name">INE File Download</field>
<field name="model">ine.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<group string="Generar estadistica para el I.N.E." colspan="1">
<field name="ine_start" style="width:110px;"/>
<field name="ine_end" style="width:110px"/>
</group>
<div>
<button name="generate_file" class="oe_form_button_save btn btn-primary btn-sm" type="object" string="Generate file"/>
<field name="txt_filename" invisible="1"/>
<field name="txt_binary" filename="txt_filename" readonly="1" style="margin-left: 20px;"/>
</div>
<separator string="ADR y RevPar"/>
<group>
<div>
<field name="adr_screen" readonly="1"/>
<field name="rev_screen" readonly="1"/>
</div>
</group>
<group>
<div><!-- site-exportine -->
<p>Abrir web del I.N.E.: <a href="https://arce.ine.es/ARCE/jsp/encuestaXml.jsp" target="_blank">Presentar encuesta I.N.E. <i class="fa fa-signal"></i></a></p>
</div>
</group>
</sheet>
</form>
</field>
</record>
<menuitem
id="menu_ine_download"
name="INE File Download"
parent="hotel.hotel_reports_menu"
sequence="37"
action="action_ine_download"
/>
</data>
</openerp>