From 505eb694201500f1e1784def9bdb30395fefb8d8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 28 Nov 2014 23:51:23 +0100 Subject: [PATCH] Add module intrastat_product. Rename report.intrastat.product to l10n.fr.report.intrastat.product (same for service and for lines) + migration scripts --- intrastat_base/__openerp__.py | 1 - intrastat_product/__init__.py | 23 ++++ intrastat_product/__openerp__.py | 46 +++++++ intrastat_product/i18n/intrastat_product.pot | 122 ++++++++++++++++++ intrastat_product/intrastat.py | 84 ++++++++++++ intrastat_product/intrastat_demo.xml | 64 +++++++++ intrastat_product/intrastat_view.xml | 89 +++++++++++++ .../security/ir.model.access.csv | 3 + 8 files changed, 431 insertions(+), 1 deletion(-) create mode 100644 intrastat_product/__init__.py create mode 100644 intrastat_product/__openerp__.py create mode 100644 intrastat_product/i18n/intrastat_product.pot create mode 100644 intrastat_product/intrastat.py create mode 100644 intrastat_product/intrastat_demo.xml create mode 100644 intrastat_product/intrastat_view.xml create mode 100644 intrastat_product/security/ir.model.access.csv diff --git a/intrastat_base/__openerp__.py b/intrastat_base/__openerp__.py index 9661bd8..c9dd90d 100644 --- a/intrastat_base/__openerp__.py +++ b/intrastat_base/__openerp__.py @@ -52,5 +52,4 @@ Please contact Alexis de Lattre from Akretion for ], 'demo': ['intrastat_demo.xml'], 'installable': True, - 'active': False, } diff --git a/intrastat_product/__init__.py b/intrastat_product/__init__.py new file mode 100644 index 0000000..64a3431 --- /dev/null +++ b/intrastat_product/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Intrastat product module for OpenERP +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# 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 intrastat diff --git a/intrastat_product/__openerp__.py b/intrastat_product/__openerp__.py new file mode 100644 index 0000000..5008ce6 --- /dev/null +++ b/intrastat_product/__openerp__.py @@ -0,0 +1,46 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Intrastat Product module for OpenERP +# Copyright (C) 2011-2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# 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': 'Intrastat Product', + 'version': '1.1', + 'category': 'Localisation/Report Intrastat', + 'license': 'AGPL-3', + 'summary': 'Base module for Intrastat Product', + 'description': """ +This module contains the common objects for the Intrastat Product. +This module is country-independant. + +This module has been written by Alexis de Lattre from Akretion + + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['intrastat_base'], + 'data': [ + 'intrastat_view.xml', + 'security/ir.model.access.csv', + ], + 'demo': ['intrastat_demo.xml'], + 'installable': True, +} diff --git a/intrastat_product/i18n/intrastat_product.pot b/intrastat_product/i18n/intrastat_product.pot new file mode 100644 index 0000000..15505ac --- /dev/null +++ b/intrastat_product/i18n/intrastat_product.pot @@ -0,0 +1,122 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * intrastat_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-11-28 22:48+0000\n" +"PO-Revision-Date: 2014-11-28 22: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: intrastat_product +#: help:product.category,intrastat_id:0 +msgid "Code from the Harmonised System. If this code is not set on the product itself, it will be read here, on the related product category." +msgstr "" + +#. module: intrastat_product +#: help:product.template,intrastat_id:0 +msgid "Code from the Harmonised System. Nomenclature is available from the World Customs Organisation, see http://www.wcoomd.org/. Some countries have made their own extensions to this nomenclature." +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,create_date:0 +msgid "Created on" +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,description:0 +msgid "Description" +msgstr "" + +#. module: intrastat_product +#: help:report.intrastat.code,name:0 +msgid "Full length Harmonized System code (digits only). Full list is available from the World Customs Organisation, see http://www.wcoomd.org" +msgstr "" + +#. module: intrastat_product +#: model:ir.model,name:intrastat_product.model_report_intrastat_code +msgid "H.S. Code" +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,name:0 +msgid "H.S. code" +msgstr "" + +#. module: intrastat_product +#: code:addons/intrastat_product/intrastat.py:56 +#, python-format +msgid "H.S. codes should only contain digits. It is not the case of H.S. code '%s'." +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,id:0 +msgid "ID" +msgstr "" + +#. module: intrastat_product +#: model:ir.actions.act_window,name:intrastat_product.product_intrastat_code_act +#: model:ir.ui.menu,name:intrastat_product.product_intrastat_code_menu +#: field:product.category,intrastat_id:0 +#: field:product.template,intrastat_id:0 +#: view:report.intrastat.code:intrastat_product.product_intrastat_code_form +msgid "Intrastat Code" +msgstr "" + +#. module: intrastat_product +#: view:report.intrastat.code:intrastat_product.product_intrastat_code_tree +msgid "Intrastat Codes" +msgstr "" + +#. module: intrastat_product +#: view:product.category:intrastat_product.product_category_form_view +msgid "Intrastat Properties" +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: intrastat_product +#: field:report.intrastat.code,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: intrastat_product +#: model:ir.model,name:intrastat_product.model_product_category +msgid "Product Category" +msgstr "" + +#. module: intrastat_product +#: model:ir.model,name:intrastat_product.model_product_template +msgid "Product Template" +msgstr "" + +#. module: intrastat_product +#: view:report.intrastat.code:intrastat_product.product_intrastat_code_search +msgid "Search Intrastat Codes" +msgstr "" + +#. module: intrastat_product +#: help:report.intrastat.code,description:0 +msgid "Short text description of the H.S. category" +msgstr "" + +#. module: intrastat_product +#: sql_constraint:report.intrastat.code:0 +msgid "This H.S. code already exists in Odoo !" +msgstr "" + diff --git a/intrastat_product/intrastat.py b/intrastat_product/intrastat.py new file mode 100644 index 0000000..11fd2f2 --- /dev/null +++ b/intrastat_product/intrastat.py @@ -0,0 +1,84 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Intrastat Product module for OpenERP +# Copyright (C) 2004-2009 Tiny SPRL (http://tiny.be) +# Copyright (C) 2010-2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# 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 models, fields, api, _ +from openerp.exceptions import Warning + + +class ReportIntrastatCode(models.Model): + _name = "report.intrastat.code" + _description = "H.S. Code" + _order = "name" + + name = fields.Char( + string='H.S. code', required=True, + help="Full length Harmonized System code (digits only). Full list is " + "available from the World Customs Organisation, see " + "http://www.wcoomd.org") + description = fields.Char( + 'Description', help="Short text description of the H.S. category") + + @api.multi + @api.depends('name', 'description') + def name_get(self): + res = [] + for code in self: + name = code.name + if code.description: + name = u'%s %s' % (name, code.description) + res.append((code.id, name)) + return res + + @api.constrains('name') + def _hs_code(self): + if self.name and not self.name.isdigit(): + raise Warning( + _("H.S. codes should only contain digits. It is not the case " + "of H.S. code '%s'.") % self.name) + + _sql_constraints = [( + 'hs_code_uniq', + 'unique(name)', + 'This H.S. code already exists in Odoo !' + )] + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + intrastat_id = fields.Many2one( + 'report.intrastat.code', string='Intrastat Code', + help="Code from the Harmonised System. Nomenclature is " + "available from the World Customs Organisation, see " + "http://www.wcoomd.org/. Some countries have made their own " + "extensions to this nomenclature.") + + +class ProductCategory(models.Model): + _inherit = "product.category" + + intrastat_id = fields.Many2one( + 'report.intrastat.code', string='Intrastat Code', + help="Code from the Harmonised System. If this code is not " + "set on the product itself, it will be read here, on the " + "related product category.") diff --git a/intrastat_product/intrastat_demo.xml b/intrastat_product/intrastat_demo.xml new file mode 100644 index 0000000..e831a6d --- /dev/null +++ b/intrastat_product/intrastat_demo.xml @@ -0,0 +1,64 @@ + + + + + + + + + 84715000 + Automatic data-processing machines (computers) + + + + 84717050 + Storage units + + + + 85340090 + Printed circuits + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/intrastat_product/intrastat_view.xml b/intrastat_product/intrastat_view.xml new file mode 100644 index 0000000..635724c --- /dev/null +++ b/intrastat_product/intrastat_view.xml @@ -0,0 +1,89 @@ + + + + + + + + + + intrastat.product.template.form + product.template + + + + + + + + + + + intrastat.product.category.form + product.category + + + + + + + + + + + + + intrastat.product.intrastat.code.search + report.intrastat.code + + + + + + + + + + intrastat.product.intrastat.code.tree + report.intrastat.code + + + + + + + + + + + fr.intrastat.product.intrastat.code.form + report.intrastat.code + +
+ + + + +
+
+
+ + + + Intrastat Code + report.intrastat.code + tree,form + + + + + +
+
diff --git a/intrastat_product/security/ir.model.access.csv b/intrastat_product/security/ir.model.access.csv new file mode 100644 index 0000000..1708adf --- /dev/null +++ b/intrastat_product/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_report_intrastat_code_sale_manager,Full access on report.intrastat.code to sale manager,model_report_intrastat_code,base.group_sale_manager,1,1,1,1 +access_report_intrastat_code_employee,Read access on report.intrastat.code to employee,model_report_intrastat_code,base.group_user,1,0,0,0