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..6224d37 --- /dev/null +++ b/intrastat_product/__openerp__.py @@ -0,0 +1,45 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Intrastat Product module for Odoo +# Copyright (C) 2011-2015 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..efbfe37 --- /dev/null +++ b/intrastat_product/intrastat.py @@ -0,0 +1,131 @@ +# -*- 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 ValidationError + + +class ReportIntrastatCode(models.Model): + _name = "report.intrastat.code" + _description = "H.S. Code" + _order = "name" + _rec_name = "display_name" + + @api.one + @api.depends('name', 'description') + def _compute_display_name(self): + display_name = self.name or '' + if self.description: + display_name += ' ' + self.description + self.display_name = display_name + + name = fields.Char( + string='H.S. code', + 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") + display_name = fields.Char( + compute='_compute_display_name', string="Display Name", readonly=True) + intrastat_code = fields.Char( + string='European Intrastat Code', size=9, required=True, + help="Code used for the Intrastat declaration. Must be part " + "of the 'Combined Nomenclature' (CN), cf " + "http://en.wikipedia.org/wiki/Combined_Nomenclature" + "Must have 8 digits with sometimes a 9th digit.") + intrastat_uom_id = fields.Many2one( + 'product.uom', string='UoM for Intrastat Report', + help="Select the unit of measure if one is required for " + "this particular Intrastat Code (other than the weight in Kg). " + "If no particular unit of measure is required, leave empty.") + active = fields.Boolean(default=True) + product_categ_ids = fields.One2many( + 'product.category', 'intrastat_id', string='Product Categories') + product_tmpl_ids = fields.One2many( + 'product.template', 'intrastat_id', string='Products') + + @api.constrains('name', 'intrastat_code') + def _hs_code(self): + if self.name and not self.name.isdigit(): + raise ValidationError( + _("H.S. codes should only contain digits. It is not the case " + "of H.S. code '%s'.") % self.name) + if self.intrastat_code and not self.intrastat_code.isdigit(): + raise ValidationError( + _("The field Intrastat Code should only contain digits. " + "It is not the case of Intrastat Code '%s'.") + % self.intrastat_code) + if self.intrastat_code and len(self.intrastat_code) not in (8, 9): + raise ValidationError( + _("The field Intrastat Code should " + "contain 8 or 9 digits. It is not the case of " + "Intrastat Code '%s'.") + % self.intrastat_code) + + _sql_constraints = [( + 'hs_code_uniq', + 'unique(name)', + 'This H.S. code already exists in Odoo !' + )] + + @api.model + @api.returns('self', lambda value: value.id) + def create(self, vals): + if vals.get('intrastat_code'): + vals['intrastat_code'] = vals['intrastat_code'].replace(' ', '') + return super(ReportIntrastatCode, self).create(vals) + + @api.multi + def write(self, vals): + if vals.get('intrastat_code'): + vals['intrastat_code'] = vals['intrastat_code'].replace(' ', '') + return super(ReportIntrastatCode, self).write(vals) + + +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.") + origin_country_id = fields.Many2one( + 'res.country', string='Country of Origin', + help="Country of origin of the product i.e. product " + "'made in ____'. If you have different countries of origin " + "depending on the supplier from which you purchased the product, " + "leave this field empty and use the equivalent field on the " + "'product supplier info' form.") + + +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..b5ae41b --- /dev/null +++ b/intrastat_product/intrastat_demo.xml @@ -0,0 +1,88 @@ + + + + + + + + + 84715000 + 84715000 + + Automatic data-processing machines (computers) + + + + 84717050 + 84717050 + + Storage units + + + + 85340090 + 85340090 + Printed circuits + + + + + + 5 + + + + + + 6 + + + + + + 6.5 + + + + + + 0.5 + + + + + + 0.5 + + + + + + 0.5 + + + + + + 0.7 + + + + + + 0.8 + + + + + + 2 + + + + + diff --git a/intrastat_product/intrastat_view.xml b/intrastat_product/intrastat_view.xml new file mode 100644 index 0000000..b62c280 --- /dev/null +++ b/intrastat_product/intrastat_view.xml @@ -0,0 +1,101 @@ + + + + + + + + + + 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