diff --git a/l10n_nl_intrastat/README.rst b/l10n_nl_intrastat/README.rst new file mode 100644 index 000000000..cc07c58ab --- /dev/null +++ b/l10n_nl_intrastat/README.rst @@ -0,0 +1,76 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================================= +Intrastat reporting (ICP) for the Netherlands +============================================= + +Based on the OCA Intrastat framework, this module provides an +intrastat report for the Netherlands. Only generating the required data +for a manual declaration is supported. Message communication with the +tax authority has not yet been implemented. + +Installation +============ + +Just install. + +Configuration +============= + +To configure this module, you need to: + +#. Configure the country of your company (NL) +#. Configure some accounting periods + +Usage +===== + +To use this module, you need to: + +#. Invoice some companies in other EU countries +#. Go to Accounting - Legal Reports - Intrastat - ICP report +#. View there the values for each period +#. Manually copy the values into your ICP tax entry + +Known issues / Roadmap +====================== + +* The Dutch tax authority accepts an XML format, generate this to avoid manual processing. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* Therp BV + +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 https://odoo-community.org. diff --git a/l10n_nl_intrastat/__init__.py b/l10n_nl_intrastat/__init__.py new file mode 100644 index 000000000..601ffa6a9 --- /dev/null +++ b/l10n_nl_intrastat/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +from . import models + diff --git a/l10n_nl_intrastat/__openerp__.py b/l10n_nl_intrastat/__openerp__.py new file mode 100644 index 000000000..a7822ad4a --- /dev/null +++ b/l10n_nl_intrastat/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# Copyright 2010-2011 Akretion (http://www.akretion.com). +# Modifications Copyright 2012-2016 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +{ + 'name': 'Intrastat reporting (ICP) for the Netherlands', + 'version': '8.0.1.0.1', + 'category': 'Localisation/Report Intrastat', + 'license': 'AGPL-3', + 'summary': """Intrastat report for the Netherlands""", + 'author': 'Therp BV, Odoo Community Association (OCA)', + 'website': 'https://launchpad.net/new-report-intrastat', + 'depends': ['intrastat_base'], + 'data': [ + 'views/l10n_nl_intrastat.xml', + 'security/ir.model.access.csv', + ], +} diff --git a/l10n_nl_intrastat/i18n/l10n_nl_intrastat.pot b/l10n_nl_intrastat/i18n/l10n_nl_intrastat.pot new file mode 100644 index 000000000..71de90fe6 --- /dev/null +++ b/l10n_nl_intrastat/i18n/l10n_nl_intrastat.pot @@ -0,0 +1,172 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_nl_intrastat +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-10-23 11:48+0000\n" +"PO-Revision-Date: 2012-10-23 11:48+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: l10n_nl_intrastat +#: model:ir.model,name:l10n_nl_intrastat.model_l10n_nl_report_intrastat +msgid "Declaration of intracommunautary transactions (ICP)" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,amount_service:0 +msgid "Amount services" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,state:0 +msgid "State" +msgstr "" + +#. module: l10n_nl_intrastat +#: selection:l10n_nl.report.intrastat,state:0 +msgid "Draft" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,amount_product:0 +msgid "Amount products" +msgstr "" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:144 +#, python-format +msgid "" +"Missing country on the invoice addresses of the following partners:\n" +"%s" +msgstr "" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,notes:0 +msgid "You can add some comments here if you want." +msgstr "" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,company_id:0 +msgid "Related company." +msgstr "" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,date_done:0 +msgid "Last date when the intrastat declaration was converted to 'Done' state." +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,company_id:0 +msgid "Company" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,vat:0 +msgid "VAT" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,total_amount:0 +msgid "Total amount" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,country_code:0 +msgid "Country Code" +msgstr "" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 field:l10n_nl.report.intrastat,notes:0 +msgid "Notes" +msgstr "" + +#. module: l10n_nl_intrastat +#: model:ir.model,name:l10n_nl_intrastat.model_l10n_nl_report_intrastat_line +msgid "ICP report line" +msgstr "" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:219 +#, python-format +msgid "Cannot remove IPC reports in a non-draft state" +msgstr "" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:119 +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:143 +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:218 +#, python-format +msgid "Error" +msgstr "" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,state:0 +msgid "" +"State of the declaration. When the state is set to 'Done', the parameters " +"become read-only." +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,report_id:0 +msgid "ICP report" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,line_ids:0 +msgid "ICP line" +msgstr "" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,total_amount:0 +msgid "Total amount in company currency of the declaration." +msgstr "" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:120 +#, python-format +msgid "Cannot generate reports lines in a non-draft state" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,period_id:0 +msgid "Period" +msgstr "" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 +msgid "Generate lines" +msgstr "" + +#. module: l10n_nl_intrastat +#: selection:l10n_nl.report.intrastat,state:0 +msgid "Done" +msgstr "" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 +msgid "Cancel" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,partner_id:0 +msgid "Partner" +msgstr "" + +#. module: l10n_nl_intrastat +#: model:ir.actions.act_window,name:l10n_nl_intrastat.l10n_nl_intrastat_tree_action +#: model:ir.ui.menu,name:l10n_nl_intrastat.l10n_nl_intrastat_report_menu +msgid "ICP Report" +msgstr "" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,date_done:0 +msgid "Date done" +msgstr "" diff --git a/l10n_nl_intrastat/i18n/nl.po b/l10n_nl_intrastat/i18n/nl.po new file mode 100644 index 000000000..c2bf38289 --- /dev/null +++ b/l10n_nl_intrastat/i18n/nl.po @@ -0,0 +1,172 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_nl_intrastat +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-12-04 11:31+0000\n" +"PO-Revision-Date: 2012-12-04 11:31+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: l10n_nl_intrastat +#: model:ir.model,name:l10n_nl_intrastat.model_l10n_nl_report_intrastat +msgid "Declaration of intracommunautary transactions (ICP)" +msgstr "Opgaaf Intracommunautaire Prestaties (ICP)" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,amount_service:0 +msgid "Amount services" +msgstr "Totaalbedrag diensten" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,state:0 +msgid "State" +msgstr "Status" + +#. module: l10n_nl_intrastat +#: selection:l10n_nl.report.intrastat,state:0 +msgid "Draft" +msgstr "Concept" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,amount_product:0 +msgid "Amount products" +msgstr "Totaalbedrag leveringen" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:144 +#, python-format +msgid "Missing country on the invoice addresses of the following partners:\n" +"%s" +msgstr "Ontbrekend land op het factuuradresvan de volgende partner:\n" +"%s" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,notes:0 +msgid "You can add some comments here if you want." +msgstr "Hier kunnen eventuele aantekeningen geplaatst worden." + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,company_id:0 +msgid "Related company." +msgstr "Bedrijf van deze aangifte." + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,date_done:0 +msgid "Last date when the intrastat declaration was converted to 'Done' state." +msgstr "Datum van de laatste statuswijziging naar 'Gereed'." + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,company_id:0 +msgid "Company" +msgstr "Bedrijf" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,vat:0 +msgid "VAT" +msgstr "BTW-nummer" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,total_amount:0 +msgid "Total amount" +msgstr "Totaalbedrag" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,country_code:0 +msgid "Country Code" +msgstr "Landcode" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 +#: field:l10n_nl.report.intrastat,notes:0 +msgid "Notes" +msgstr "Aantekeningen" + +#. module: l10n_nl_intrastat +#: model:ir.model,name:l10n_nl_intrastat.model_l10n_nl_report_intrastat_line +msgid "ICP report line" +msgstr "ICP aangifteregel" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:219 +#, python-format +msgid "Cannot remove IPC reports in a non-draft state" +msgstr "Alleen aangiften in concept-status kunnen worden verwijderd" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:119 +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:143 +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:218 +#, python-format +msgid "Error" +msgstr "Fout" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,state:0 +msgid "State of the declaration. When the state is set to 'Done', the parameters become read-only." +msgstr "Status van de aangifte. Wanneer de status op 'Gereed' staat, worden de gegevens alleen-lezen." + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,report_id:0 +msgid "ICP report" +msgstr "Aangifte ICP" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,line_ids:0 +msgid "ICP line" +msgstr "ICP-regel" + +#. module: l10n_nl_intrastat +#: help:l10n_nl.report.intrastat,total_amount:0 +msgid "Total amount in company currency of the declaration." +msgstr "Totaalbedrag van de aangifte in de bedrijfsvaluta" + +#. module: l10n_nl_intrastat +#: code:addons/l10n_nl_intrastat/model/l10n_nl_intrastat.py:120 +#, python-format +msgid "Cannot generate reports lines in a non-draft state" +msgstr "Kan alleen regels genereren voor een aangifte in concept-status" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,period_id:0 +msgid "Period" +msgstr "Periode" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 +msgid "Generate lines" +msgstr "Regels aanmaken" + +#. module: l10n_nl_intrastat +#: selection:l10n_nl.report.intrastat,state:0 +msgid "Done" +msgstr "Gereed" + +#. module: l10n_nl_intrastat +#: view:l10n_nl.report.intrastat:0 +msgid "Cancel" +msgstr "Annuleer" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat.line,partner_id:0 +msgid "Partner" +msgstr "Relatie" + +#. module: l10n_nl_intrastat +#: model:ir.actions.act_window,name:l10n_nl_intrastat.l10n_nl_intrastat_tree_action +#: model:ir.ui.menu,name:l10n_nl_intrastat.l10n_nl_intrastat_report_menu +msgid "ICP Report" +msgstr "Aangifte ICP" + +#. module: l10n_nl_intrastat +#: field:l10n_nl.report.intrastat,date_done:0 +msgid "Date done" +msgstr "Datum gereed" + diff --git a/l10n_nl_intrastat/models/__init__.py b/l10n_nl_intrastat/models/__init__.py new file mode 100644 index 000000000..0b408b742 --- /dev/null +++ b/l10n_nl_intrastat/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import l10n_nl_intrastat diff --git a/l10n_nl_intrastat/models/l10n_nl_intrastat.py b/l10n_nl_intrastat/models/l10n_nl_intrastat.py new file mode 100644 index 000000000..20a097034 --- /dev/null +++ b/l10n_nl_intrastat/models/l10n_nl_intrastat.py @@ -0,0 +1,277 @@ +# -*- coding: utf-8 -*- +"""Define intrastat report (ICP) for dutch tax authorities.""" +############################################################################## +# +# OpenERP Report intrastat for NL +# Copyright (C) 2012 - 2015 Therp BV +# +# Based on and containing code snippets from lp:new-report-intrastat +# by Alexis de Lattre , +# Copyright (C) 2010-2011 Akretion (http://www.akretion.com). +# All Rights Reserved +# +# 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 api, models, fields, _ +from openerp.exceptions import Warning +from datetime import datetime +from dateutil.relativedelta import relativedelta +from openerp.addons.decimal_precision import decimal_precision as dp + + +class ReportIntrastat(models.Model): + """Define intrastat report (ICP) for dutch tax authorities.""" + _name = "l10n_nl.report.intrastat" + _description = "Declaration of intracommunautary transactions (ICP)" + _order = "period_id desc" + _rec_name = 'period_id' + _inherit = ['intrastat.common'] + + def _default_period_id(self): + """ + By default, take the previous period relative to the + current date. Courtesy of Alexis. + """ + period_model = self.env['account.period'] + date = datetime.strftime( + datetime.today() + relativedelta(day=1, months=-1), '%Y-%m-%d') + period_ids = period_model.find(dt=date) + return period_ids and period_ids[0] or False + + def _default_company_id(self): + """Default company is active user company.""" + return self.env.user.company_id.id + + period_id = fields.Many2one( + string='Period', + comodel_name='account.period', + states={'done': [('readonly', True)]}, + default=_default_period_id, + ) + company_id = fields.Many2one( + string='Company', + comodel_name='res.company', + required=True, + states={'done': [('readonly', True)]}, + help="Related company.", + default=_default_company_id, + ) + total_amount = fields.Float( + string='Total amount', + readonly=True, + help="Total amount in company currency of the declaration.", + digits=dp.get_precision('Account'), + ) + state = fields.Selection( + string='State', + selection=[ + ('draft', 'Draft'), + ('done', 'Done'), + ], + default='draft', + readonly=True, + help=( + "State of the declaration. When the state is set to 'Done', " + "the parameters become read-only." + ), + ) + date_done = fields.Date( + string='Date done', + readonly=True, + help=( + "Last date when the intrastat declaration was converted to " + "'Done' state." + ), + ) + notes = fields.Text( + string='Notes', + help="You can add some comments here if you want.", + ) + line_ids = fields.One2many( + string='ICP line', + comodel_name='l10n_nl.report.intrastat.line', + inverse_name='report_id', + readonly=True, + ) + + @api.one + def set_draft(self): + """ + Reset report state to draft. + """ + return self.write({'state': 'draft'}) + + @api.one + def generate_lines(self): + """ + Collect the data lines for the given report. + Unlink any existing lines first. + """ + # Generating lines is only allowed for report in draft state: + if self.state != 'draft': + raise Warning(_( + 'Cannot generate reports lines in a non-draft state')) + # Other models: + report_line_model = self.env['l10n_nl.report.intrastat.line'] + invoice_model = self.env['account.invoice'] + invoice_line_model = self.env['account.invoice.line'] + + total_amount = 0.0 + partner_amounts_map = {} + # Check whether all configuration done to generate report + self._check_generate_lines() + + # Remove existing lines + for line_obj in self.line_ids: + line_obj.unlink() + # Define search for invoices for period and company: + company_obj = self.company_id # simplify access + invoice_domain = [ + ('type', 'in', ('out_invoice', 'out_refund')), + ('period_id', '=', self.period_id.id), + ('state', 'in', ('open', 'paid')), + ('company_id', '=', company_obj.id), + ] + # Signal invoices without a country + # (Should not happen, as country_id on parter is set to required) + invalid_invoices = invoice_model.search_read( + domain=invoice_domain + [('partner_id.country_id', '=', False)], + fields=['partner_id'] + ) + if invalid_invoices: + raise Warning( + _( + "Missing country on the invoice addresses of the" + " following partners:\n%s" + ) % "\n".join( + inv['partner_id'][1] for inv in invalid_invoices) + ) + # Search invoices that need intrastat reporting: + invoice_records = invoice_model.search( + invoice_domain + [ + ('partner_id.country_id.intrastat', '=', True), + ('partner_id.country_id.id', '!=', company_obj.country_id.id), + ] + ) + invoice_ids = [inv['id'] for inv in invoice_records] + invoice_line_records = invoice_line_model.search( + [('invoice_id', 'in', invoice_ids)]) + + # Gather amounts from invoice lines + for line in invoice_line_records: + # Ignore invoiceline if taxes should not be included in intrastat: + if any( + tax.exclude_from_intrastat_if_present + for tax in line.invoice_line_tax_id): + continue + # Report is per commercial partner: + commercial_partner_id = ( + line.invoice_id.partner_id.commercial_partner_id.id) + if commercial_partner_id not in partner_amounts_map: + partner_amounts_map[commercial_partner_id] = { + 'amount_product': 0.0, + 'amount_service': 0.0, + } + amounts = partner_amounts_map[commercial_partner_id] + # Determine product or service: + if (line.product_id and + (line.product_id.type == 'service' or + line.product_id.is_accessory_cost)): + amount_type = 'amount_service' + else: + amount_type = 'amount_product' + sign = line.invoice_id.type == 'out_refund' and -1 or 1 + amount = sign * line.price_subtotal + # Convert currency amount if necessary: + line_currency_obj = line.invoice_id.currency_id # simplify + invoice_date = line.invoice_id.date_invoice + if (line_currency_obj and + line_currency_obj.id != company_obj.currency_id.id): + amount = ( + line_currency_obj.with_context(date=invoice_date).compute( + amount, company_obj.currency_id, round=True) + ) + # Accumulate totals: + amounts[amount_type] += amount # per partner and type + total_amount += amount # grand total + + # Create report lines + for (partner_id, vals) in partner_amounts_map.items(): + if not (vals['amount_service'] or vals['amount_product']): + continue + vals.update({ + 'partner_id': partner_id, + 'report_id': self.id + }) + report_line_model.create(vals) + + return self.write({ + 'total_amount': total_amount, + 'date_done': fields.Date.today(), + 'state': 'done', + }) + + @api.multi + def unlink(self): + """ + Do not allow unlinking of confirmed reports + """ + if self.search([('state', '!=', 'draft')]): + raise Warning(_('Cannot remove IPC reports in a non-draft state')) + return super(ReportIntrastat, self).unlink() + + +class ReportIntrastatLine(models.Model): + """Lines for dutch ICP report.""" + _name = "l10n_nl.report.intrastat.line" + _description = "ICP report line" + _order = "report_id, country_code" + _rec_name = 'partner_id' + + report_id = fields.Many2one( + string='ICP report', + comodel_name='l10n_nl.report.intrastat', + readonly=True, + required=True, + ondelete="CASCADE" + ) + partner_id = fields.Many2one( + string='Partner', + comodel_name='res.partner', + readonly=True, + required=True, + ) + vat = fields.Char( + string='VAT', + related='partner_id.vat', + store=True, + readonly=True, + ) + country_code = fields.Char( + string='Country Code', + related='partner_id.country_id.code', + store=True, + readonly=True, + ) + amount_product = fields.Float( + string='Amount products', + readonly=True, + digits=dp.get_precision('Account'), + ) + amount_service = fields.Float( + string='Amount services', + readonly=True, + digits=dp.get_precision('Account'), + ) diff --git a/l10n_nl_intrastat/security/ir.model.access.csv b/l10n_nl_intrastat/security/ir.model.access.csv new file mode 100644 index 000000000..c850ace5d --- /dev/null +++ b/l10n_nl_intrastat/security/ir.model.access.csv @@ -0,0 +1,3 @@ +"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" +"access_l10n_nl_report_intrastat","Account manager can use ICP reports","model_l10n_nl_report_intrastat","account.group_account_manager",1,1,1,1 +"access_l10n_nl_report_intrastat_line","Account manager can use ICP report lines","model_l10n_nl_report_intrastat_line","account.group_account_manager",1,1,1,1 diff --git a/l10n_nl_intrastat/tests/__init__.py b/l10n_nl_intrastat/tests/__init__.py new file mode 100644 index 000000000..9818fd62f --- /dev/null +++ b/l10n_nl_intrastat/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import test_all diff --git a/l10n_nl_intrastat/tests/test_all.py b/l10n_nl_intrastat/tests/test_all.py new file mode 100644 index 000000000..c4320083f --- /dev/null +++ b/l10n_nl_intrastat/tests/test_all.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- + +from datetime import datetime +from dateutil.relativedelta import relativedelta + +from openerp.tests.common import TransactionCase + + +class TestIntrastatNL(TransactionCase): + """Tests for this module""" + + def setUp(self): + super(TestIntrastatNL, self).setUp() + self.intrastat_report = self.env['l10n_nl.report.intrastat'] + + def test_generate_report(self): + # Set our company's country to NL + company = self.env.ref('base.main_company') + company.country_id = self.env.ref('base.nl') + # Create an empty, draft intrastat report + report = self.intrastat_report.create({ + 'company_id': company.id + }) + self.assertEquals(report.state, 'draft') + # Check if the period has correctly defaulted to last month + a_date_in_last_month = datetime.today() \ + + relativedelta(day=1, months=-1) + period_name = datetime.strftime(a_date_in_last_month, 'X %m/%Y') + self.assertEquals(report.period_id.name, period_name) + # Generate lines and store initial total + report.generate_lines() + total = report.total_amount + # Product: On site Monitoring, a service + product = self.env.ref('product.product_product_1') + # Create a new invoice to MediaPole (de), dated last month. + # Total price: 250 + invoice = self.env['account.invoice'].create({ + 'account_id': self.env.ref('account.a_recv').id, + 'date_invoice': a_date_in_last_month, + 'partner_id': self.env.ref('base.res_partner_8').id, + 'invoice_line': [ + (0, False, { + 'name': 'Test sale', + 'account_id': self.env.ref('account.a_sale').id, + 'price_unit': 50.0, + 'product_id': product.id, + 'quantity': 5.0, + 'uos_id': self.env.ref('product.product_uom_unit').id + }) + ] + }) + # validate the invoice + invoice.signal_workflow('invoice_open') + # generate lines again + report.set_draft() + report.generate_lines() + # Test if the difference between the previous and current amount is 250 + self.assertEquals(report.total_amount - total, 250.0) diff --git a/l10n_nl_intrastat/views/l10n_nl_intrastat.xml b/l10n_nl_intrastat/views/l10n_nl_intrastat.xml new file mode 100644 index 000000000..ebb874c9e --- /dev/null +++ b/l10n_nl_intrastat/views/l10n_nl_intrastat.xml @@ -0,0 +1,74 @@ + + + + + + l10n_nl.intrastat.report.form + l10n_nl.report.intrastat + +
+ + + + + +