diff --git a/account_tax_chart_interval/README.rst b/account_tax_chart_interval/README.rst new file mode 100644 index 000000000..0ddba17b1 --- /dev/null +++ b/account_tax_chart_interval/README.rst @@ -0,0 +1,40 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Tax chart for a period interval +=============================== + +Regular tax chart wizard lets you select only one period. With this module, +you can select an initial and ending period, and you will get taxes data +for that interval. + +Known issues / Roadmap +====================== + +* sum_period compute logic has been completely overwritten when coming from + tax chart wizard because there is no provided hook or facility, so changes + in the computation upstream (unlikely, but possible) will not be reflected + with this module. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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/account_tax_chart_interval/__init__.py b/account_tax_chart_interval/__init__.py new file mode 100644 index 000000000..3fc79a2d7 --- /dev/null +++ b/account_tax_chart_interval/__init__.py @@ -0,0 +1,7 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import models +from . import wizard diff --git a/account_tax_chart_interval/__openerp__.py b/account_tax_chart_interval/__openerp__.py new file mode 100644 index 000000000..711c99b92 --- /dev/null +++ b/account_tax_chart_interval/__openerp__.py @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# (c) 2015 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) +# Pedro M. Baeza +# +# 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 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 http://www.gnu.org/licenses/. +# +############################################################################## + +{ + "name": "Tax chart for a period interval", + "version": "1.0", + "depends": [ + "account", + ], + "author": "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + 'Antiun IngenierĂ­a S.L., ' + 'Odoo Community Association (OCA)', + "website": "http://www.antiun.com", + "contributors": [ + "Pedro M. Baeza ", + ], + "category": "Accounting & Finance", + "data": [ + 'wizard/account_tax_chart_view.xml', + ], + "installable": True, +} diff --git a/account_tax_chart_interval/i18n/account_tax_chart_interval.pot b/account_tax_chart_interval/i18n/account_tax_chart_interval.pot new file mode 100644 index 000000000..59b2c98b9 --- /dev/null +++ b/account_tax_chart_interval/i18n/account_tax_chart_interval.pot @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_tax_chart_interval +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-22 10:52+0000\n" +"PO-Revision-Date: 2015-05-22 10:52+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,period_to:0 +msgid "End period" +msgstr "" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,fiscalyear_id:0 +msgid "Fiscal year" +msgstr "" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,period_from:0 +msgid "Start period" +msgstr "" + diff --git a/account_tax_chart_interval/i18n/es.po b/account_tax_chart_interval/i18n/es.po new file mode 100644 index 000000000..8a358146f --- /dev/null +++ b/account_tax_chart_interval/i18n/es.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_tax_chart_interval +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-05-22 10:52+0000\n" +"PO-Revision-Date: 2015-05-22 10:52+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,period_to:0 +msgid "End period" +msgstr "Periodo final" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,fiscalyear_id:0 +msgid "Fiscal year" +msgstr "Ejercicio fiscal" + +#. module: account_tax_chart_interval +#: field:account.tax.chart,period_from:0 +msgid "Start period" +msgstr "Periodo inicial" + diff --git a/account_tax_chart_interval/models/__init__.py b/account_tax_chart_interval/models/__init__.py new file mode 100644 index 000000000..d36d2d54a --- /dev/null +++ b/account_tax_chart_interval/models/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import account_tax_code diff --git a/account_tax_chart_interval/models/account_tax_code.py b/account_tax_chart_interval/models/account_tax_code.py new file mode 100644 index 000000000..24ff01ca1 --- /dev/null +++ b/account_tax_chart_interval/models/account_tax_code.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models, fields, api + + +class AccountTaxCode(models.Model): + _inherit = 'account.tax.code' + + sum_period = fields.Float(compute="_sum_period") + + @api.one + def _sum_period(self): + context = self.env.context + if context.get('period_ids'): + move_state = ('posted', ) + if context.get('state', False) == 'all': + move_state = ('draft', 'posted', ) + self.sum_period = self._sum( + 'sum_period', [], + where=' AND line.period_id IN %s AND move.state IN %s', + where_params=(tuple(context['period_ids']), + move_state))[self.id] + else: + self.sum_period = super(AccountTaxCode, + self)._sum_period('sum_period', [])[self.id] diff --git a/account_tax_chart_interval/static/description/icon.png b/account_tax_chart_interval/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/account_tax_chart_interval/static/description/icon.png differ diff --git a/account_tax_chart_interval/wizard/__init__.py b/account_tax_chart_interval/wizard/__init__.py new file mode 100644 index 000000000..df20e31cd --- /dev/null +++ b/account_tax_chart_interval/wizard/__init__.py @@ -0,0 +1,6 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from . import account_tax_chart diff --git a/account_tax_chart_interval/wizard/account_tax_chart.py b/account_tax_chart_interval/wizard/account_tax_chart.py new file mode 100644 index 000000000..3c6f766f8 --- /dev/null +++ b/account_tax_chart_interval/wizard/account_tax_chart.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## + +from openerp import models, fields, api + + +class AccountTaxChart(models.TransientModel): + _inherit = 'account.tax.chart' + + def default_fiscalyear(self): + return self.env['account.fiscalyear'].find() + + fiscalyear_id = fields.Many2one( + comodel_name='account.fiscalyear', string='Fiscal year', + default=default_fiscalyear) + period_from = fields.Many2one( + comodel_name='account.period', string='Start period', + domain="[('fiscalyear_id', '=', fiscalyear_id)]") + period_to = fields.Many2one( + comodel_name='account.period', string='End period', + domain="[('fiscalyear_id', '=', fiscalyear_id)]") + + @api.one + @api.onchange('fiscalyear_id') + def onchange_fiscalyear(self): + self.period_from = (self.fiscalyear_id.period_ids and + self.fiscalyear_id.period_ids[0] or False) + self.period_to = (self.fiscalyear_id.period_ids and + self.fiscalyear_id.period_ids[-1] or False) + + @api.multi + def account_tax_chart_open_window(self): + res = super(AccountTaxChart, self).account_tax_chart_open_window() + res['context'] = eval(res['context']) + if self.fiscalyear_id: + res['context']['fiscalyear_id'] = self.fiscalyear_id.id + if self.period_from and self.period_to: + res['context']['period_ids'] = ( + self.env['account.period'].build_ctx_periods( + self.period_from.id, self.period_to.id)) + name = res['name'] + if name.find(':'): + name = name[:name.find(':')] + name += ":%s-%s" %(self.period_from.code, self.period_to.code) + res['name'] = name + return res diff --git a/account_tax_chart_interval/wizard/account_tax_chart_view.xml b/account_tax_chart_interval/wizard/account_tax_chart_view.xml new file mode 100644 index 000000000..69be82caf --- /dev/null +++ b/account_tax_chart_interval/wizard/account_tax_chart_view.xml @@ -0,0 +1,26 @@ + + + + + + account.tax.chart.form.interval + account.tax.chart + + + + 1 + + + + + + + + + + + + + + +