[ADD] intrastat_product

Rename report.intrastat.product to l10n.fr.report.intrastat.product (same for service and for lines) + migration scripts

Rename field country_id to origin_country_id (TODO : write mig script) and move this field from l10n_fr_intrastat_product to intrastat_product

Move intrastat_code and uom_id of report.intrastat.code from l10n_fr_intrastat_product to intrastat_product, as discussed with Luc de Meyer

Use display_name instead of an inherit of name_get (better use of new API) Inherit write and create of intrastat codes to remove spaces (patch by Luc De Meyer from Noviat) Add O2M fields from intrastat code to products and product categs
This commit is contained in:
Alexis de Lattre
2014-11-28 23:51:23 +01:00
committed by João Marques
parent e5c91e858b
commit 1103db84fc
7 changed files with 513 additions and 0 deletions

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import intrastat

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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
<alexis.delattre@akretion.com>
""",
'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,
}

View File

@@ -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 ""

View File

@@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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.")

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011-2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data noupdate="1">
<record id="84715000" model="report.intrastat.code">
<field name="name">84715000</field>
<field name="intrastat_code">84715000</field>
<field name="intrastat_uom_id" ref="product.product_uom_unit"/>
<field name="description">Automatic data-processing machines (computers)</field>
</record>
<record id="84717050" model="report.intrastat.code">
<field name="name">84717050</field>
<field name="intrastat_code">84717050</field>
<field name="intrastat_uom_id" ref="product.product_uom_unit"/>
<field name="description">Storage units</field>
</record>
<record id="85340090" model="report.intrastat.code">
<field name="name">85340090</field>
<field name="intrastat_code">85340090</field>
<field name="description">Printed circuits</field>
</record>
<record id="product.product_product_3" model="product.product">
<field name="intrastat_id" ref="84715000" />
<field name="origin_country_id" ref="base.tw" />
<field name="weight_net">5</field>
</record>
<record id="product.product_product_4" model="product.product">
<field name="intrastat_id" ref="84715000" />
<field name="origin_country_id" ref="base.cn" />
<field name="weight_net">6</field>
</record>
<record id="product.product_product_5" model="product.product">
<field name="intrastat_id" ref="84715000" />
<field name="origin_country_id" ref="base.cn" />
<field name="weight_net">6.5</field>
</record>
<record id="product.product_product_17" model="product.product">
<field name="intrastat_id" ref="84717050" />
<field name="origin_country_id" ref="base.sg" />
<field name="weight_net">0.5</field>
</record>
<record id="product.product_product_18" model="product.product">
<field name="intrastat_id" ref="84717050" />
<field name="origin_country_id" ref="base.sg" />
<field name="weight_net">0.5</field>
</record>
<record id="product.product_product_19" model="product.product">
<field name="intrastat_id" ref="84717050" />
<field name="origin_country_id" ref="base.sg" />
<field name="weight_net">0.5</field>
</record>
<record id="product.product_product_20" model="product.product">
<field name="intrastat_id" ref="85340090" />
<field name="origin_country_id" ref="base.tw" />
<field name="weight_net">0.7</field>
</record>
<record id="product.product_product_21" model="product.product">
<field name="intrastat_id" ref="85340090" />
<field name="origin_country_id" ref="base.tw" />
<field name="weight_net">0.8</field>
</record>
<record id="product.product_product_25" model="product.product">
<field name="intrastat_id" ref="84715000" />
<field name="origin_country_id" ref="base.be" />
<field name="weight_net">2</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- product.template form view -->
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">intrastat.product.template.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="intrastat_base.product_template_form_view" />
<field name="arch" type="xml">
<field name="exclude_from_intrastat" position="before">
<field name="intrastat_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
<field name="origin_country_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
</field>
</field>
</record>
<!-- Product category form view -->
<record id="product_category_form_view" model="ir.ui.view">
<field name="name">intrastat.product.category.form</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='parent']" position="inside">
<group name="intrastat" string="Intrastat Properties" colspan="2">
<field name="intrastat_id" />
</group>
</xpath>
</field>
</record>
<!-- Add search view for H.S. code -->
<record id="product_intrastat_code_search" model="ir.ui.view">
<field name="name">intrastat.product.intrastat.code.search</field>
<field name="model">report.intrastat.code</field>
<field name="arch" type="xml">
<search string="Search Intrastat Codes">
<field name="name"
filter_domain="['|', '|', ('name', 'like', self), ('intrastat_code', 'like', self), ('description', 'ilike', self)]"/>
</search>
</field>
</record>
<!-- Add tree view for H.S. code -->
<record id="product_intrastat_code_tree" model="ir.ui.view">
<field name="name">intrastat.product.intrastat.code.tree</field>
<field name="model">report.intrastat.code</field>
<field name="arch" type="xml">
<tree string="Intrastat Codes">
<field name="name"/>
<field name="intrastat_code" />
<field name="intrastat_uom_id"/>
<field name="description"/>
</tree>
</field>
</record>
<!-- Add form view for H.S. code -->
<record id="product_intrastat_code_form" model="ir.ui.view">
<field name="name">fr.intrastat.product.intrastat.code.form</field>
<field name="model">report.intrastat.code</field>
<field name="arch" type="xml">
<form string="Intrastat Code">
<group name="main">
<field name="name" />
<field name="intrastat_code"/>
<field name="intrastat_uom_id"/>
<field name="description" />
<field name="active"/>
</group>
<group name="products" string="Products">
<field name="product_tmpl_ids" nolabel="1"/>
</group>
<group name="categ" string="Product Categories">
<field name="product_categ_ids" nolabel="1"/>
</group>
</form>
</field>
</record>
<!-- Action for H.S. code -->
<record id="product_intrastat_code_act" model="ir.actions.act_window">
<field name="name">Intrastat Code</field>
<field name="res_model">report.intrastat.code</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Menu entry for H.S. code -->
<menuitem id="product_intrastat_code_menu"
action="product_intrastat_code_act"
parent="product.prod_config_main" />
</data>
</openerp>

View File

@@ -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
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 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
3 access_report_intrastat_code_employee Read access on report.intrastat.code to employee model_report_intrastat_code base.group_user 1 0 0 0