From af56eaa218f7914f146fe05a02f650045ba0f15f Mon Sep 17 00:00:00 2001 From: agaldona Date: Fri, 17 Apr 2015 09:40:36 +0200 Subject: [PATCH 01/40] [ADD] l10n_es_aeat_mod115: nuevo modulo para el modelo 115 del aeat --- l10n_es_aeat_mod115/README.rst | 27 ++++ l10n_es_aeat_mod115/__init__.py | 22 +++ l10n_es_aeat_mod115/__openerp__.py | 35 +++++ l10n_es_aeat_mod115/models/__init__.py | 21 +++ l10n_es_aeat_mod115/models/mod115.py | 143 ++++++++++++++++++ .../security/ir.model.access.csv | 2 + l10n_es_aeat_mod115/views/mod115_view.xml | 74 +++++++++ l10n_es_aeat_mod115/wizard/__init__.py | 21 +++ .../wizard/export_mod115_to_boe.py | 93 ++++++++++++ .../wizard/export_mod115_to_boe.xml | 20 +++ 10 files changed, 458 insertions(+) create mode 100644 l10n_es_aeat_mod115/README.rst create mode 100644 l10n_es_aeat_mod115/__init__.py create mode 100644 l10n_es_aeat_mod115/__openerp__.py create mode 100644 l10n_es_aeat_mod115/models/__init__.py create mode 100644 l10n_es_aeat_mod115/models/mod115.py create mode 100644 l10n_es_aeat_mod115/security/ir.model.access.csv create mode 100644 l10n_es_aeat_mod115/views/mod115_view.xml create mode 100644 l10n_es_aeat_mod115/wizard/__init__.py create mode 100644 l10n_es_aeat_mod115/wizard/export_mod115_to_boe.py create mode 100644 l10n_es_aeat_mod115/wizard/export_mod115_to_boe.xml diff --git a/l10n_es_aeat_mod115/README.rst b/l10n_es_aeat_mod115/README.rst new file mode 100644 index 00000000000..26655091189 --- /dev/null +++ b/l10n_es_aeat_mod115/README.rst @@ -0,0 +1,27 @@ +Presentación del Modelo AEAT 115 +================================ +Modelo 115 de la AEAT. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza +* AvanzOSC (http://www.avanzosc.es) + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/l10n_es_aeat_mod115/__init__.py b/l10n_es_aeat_mod115/__init__.py new file mode 100644 index 00000000000..6353085b47d --- /dev/null +++ b/l10n_es_aeat_mod115/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import models +from . import wizard diff --git a/l10n_es_aeat_mod115/__openerp__.py b/l10n_es_aeat_mod115/__openerp__.py new file mode 100644 index 00000000000..c3ec894182c --- /dev/null +++ b/l10n_es_aeat_mod115/__openerp__.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'AEAT modelo 115', + 'version': '8.0.1.0.0', + 'category': "Localisation/Accounting", + 'author': "Spanish Localization Team,Odoo Community Association (OCA)", + 'website': "https://github.com/OCA/l10n-spain", + 'license': 'AGPL-3', + 'depends': ['l10n_es_aeat_mod111'], + 'data': [ + 'wizard/export_mod115_to_boe.xml', + 'views/mod115_view.xml', + 'security/ir.model.access.csv'], + 'active': False, + 'installable': True, +} diff --git a/l10n_es_aeat_mod115/models/__init__.py b/l10n_es_aeat_mod115/models/__init__.py new file mode 100644 index 00000000000..8d0cfa17492 --- /dev/null +++ b/l10n_es_aeat_mod115/models/__init__.py @@ -0,0 +1,21 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import mod115 diff --git a/l10n_es_aeat_mod115/models/mod115.py b/l10n_es_aeat_mod115/models/mod115.py new file mode 100644 index 00000000000..884742a0a56 --- /dev/null +++ b/l10n_es_aeat_mod115/models/mod115.py @@ -0,0 +1,143 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import fields, models, api, exceptions, _ + + +class L10nEsAeatMod115Report(models.Model): + + _description = 'AEAT 115 report' + _inherit = 'l10n.es.aeat.report' + _name = 'l10n.es.aeat.mod115.report' + + number = fields.Char(default='115') + casilla_01 = fields.Integer('Casilla [01]', readonly=True, + states={'calculated': [('readonly', False)]}, + help='Retenciones e ingresos a cuenta. ' + 'Número perceptores.') + casilla_02 = fields.Float('Casilla [02]', readonly=True, + states={'calculated': [('readonly', False)]}, + help='Retenciones e ingresos a cuenta. ' + 'Base retenciones e ingresos a cuenta.') + casilla_03 = fields.Float('Casilla [03]', readonly=True, + states={'calculated': [('readonly', False)]}, + help='Retenciones e ingresos a cuenta. ' + 'Retenciones e ingresos a cuenta.') + casilla_04 = fields.Integer('Casilla [04]', readonly=True, + states={'calculated': [('readonly', False)]}, + help='Retenciones e ingresos a cuenta. ' + 'Resultado anteriores declaraciones.') + casilla_05 = fields.Integer('Casilla [05]', + help='Retenciones e ingresos a cuenta. ' + 'Resultado a ingresar.', + compute='get_casilla05') + move_lines_02 = fields.Many2many(comodel_name='account.move.line', + relation='mod115_account_move_line02_rel', + column1='mod115', + column2='account_move_line') + move_lines_03 = fields.Many2many(comodel_name='account.move.line', + relation='mod115_account_move_line03_rel', + column1='mod115', + column2='account_move_line') + currency_id = fields.Many2one('res.currency', string='Moneda', + related='company_id.currency_id', store=True) + period_id = fields.Many2one('account.period', 'Periodo', readonly=True, + states={'draft': [('readonly', False)]}, + required=True) + tipo_declaracion = fields.Selection( + [('I', 'Ingreso'), ('U', 'Domiciliación'), + ('G', 'Ingreso a anotar en CCT'), ('N', 'Negativa')], + string='Tipo de declaración', readonly=True, + states={'draft': [('readonly', False)]}, required=True) + + @api.one + @api.depends('casilla_03', 'casilla_04') + def get_casilla05(self): + self.casilla_05 = self.casilla_03 - self.casilla_04 + + def __init__(self, pool, cr): + self._aeat_number = '115' + super(L10nEsAeatMod115Report, self).__init__(pool, cr) + + @api.multi + def _calc_prev_trimesters_data(self): + self.ensure_one() + periods = self.env['account.period'].search([('fiscalyear_id', '=', + self.fiscalyear_id.id), + ('special', '=', False)]) + amount = 0 + for period in periods: + if period == self.period_id: + break + report_ids = self.search( + [('period_id', '=', period.id), + ('fiscalyear_id', '=', self.fiscalyear_id.id), + ('company_id', '=', self.company_id.id)]) + if not report_ids: + raise exceptions.Warning( + "No se ha encontrado la " + "declaracion mod. 115 para el periodo %s. No se " + "puede continuar el calculo si no existe dicha " + "declaracion." % period.code) + amount = report_ids[0].casilla_05 or 0 + return amount + + @api.multi + def _get_tax_code_lines(self, tax_code): + self.ensure_one() + tax_code_obj = self.env['account.tax.code'] + move_line_obj = self.env['account.move.line'] + code_list = tax_code_obj.search([('code', '=', tax_code), + ('company_id', '=', + self.company_id.id)]) + move_line_domain = [('company_id', '=', self.company_id.id), + ('tax_code_id', 'child_of', code_list.id)] + if self.period_id: + move_line_domain += [('period_id', '=', self.period_id.id)] + move_lines = move_line_obj.search(move_line_domain) + return move_lines + + @api.multi + def calculate(self): + self.ensure_one() + move_lines02 = self._get_tax_code_lines('RBI') + move_lines03 = self._get_tax_code_lines('RLC115') + self.move_lines_02 = move_lines02.ids + self.move_lines_03 = move_lines03.ids + self.casilla_02 = sum([x.tax_amount for x in move_lines02]) + self.casilla_03 = sum([x.tax_amount for x in move_lines03]) + self.casilla_04 = self._calc_prev_trimesters_data() + self.casilla_01 = len(set([x.partner_id for x in (move_lines02 + + move_lines03)])) + + @api.multi + def show_move_lines(self): + move_lines = [] + if self.env.context.get('move_lines02', False): + move_lines = self.move_lines_02.ids + elif self.env.context.get('move_lines03', False): + move_lines = self.move_lines_03.ids + return {'type': 'ir.actions.act_window', + 'name': _('Account Move Lines'), + 'view_mode': 'tree,form', + 'view_type': 'form', + 'res_model': 'account.move.line', + 'domain': [('id', 'in', move_lines)] + } diff --git a/l10n_es_aeat_mod115/security/ir.model.access.csv b/l10n_es_aeat_mod115/security/ir.model.access.csv new file mode 100644 index 00000000000..a614edb49cd --- /dev/null +++ b/l10n_es_aeat_mod115/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_l10n_es_aeat_mod115_manager,l10n_es_aeat_mod115 manager,model_l10n_es_aeat_mod115_report,l10n_es_aeat.group_account_aeat,1,1,1,1 diff --git a/l10n_es_aeat_mod115/views/mod115_view.xml b/l10n_es_aeat_mod115/views/mod115_view.xml new file mode 100644 index 00000000000..28b7c1071b6 --- /dev/null +++ b/l10n_es_aeat_mod115/views/mod115_view.xml @@ -0,0 +1,74 @@ + + + + + l10n_es.aeat.mod115.report.form + l10n.es.aeat.mod115.report + + + + + + + + + + + + + + + - @@ -25,7 +24,11 @@ - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - -