mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
Merge pull request #3 from akretion/10-intrastat-v3
[ADD] migrate intrastat_base, product_harmonized_system
This commit is contained in:
@@ -32,7 +32,7 @@ addons:
|
||||
|
||||
env:
|
||||
global:
|
||||
- VERSION="8.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
|
||||
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
|
||||
- TRANSIFEX_USER='transbot@odoo-community.org'
|
||||
# This line contains the encrypted transifex password
|
||||
# To encrypt transifex password, install travis ruby utils with:
|
||||
|
||||
79
intrastat_base/README.rst
Normal file
79
intrastat_base/README.rst
Normal file
@@ -0,0 +1,79 @@
|
||||
.. 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 Base
|
||||
==============
|
||||
|
||||
This module contains common functions for the intrastat reporting and
|
||||
should be used in combination with the generic reporting module
|
||||
*intrastat_product* and with the country-specific reporting modules such
|
||||
as:
|
||||
|
||||
- *l10n_fr_intrastat_service*:
|
||||
the module for the *Déclaration Européenne des Services* (DES) for France
|
||||
- *l10n_fr_intrastat_product*:
|
||||
the module for the *Déclaration d'Echange de Biens* (DEB) for France
|
||||
- *l10n_be_intrastat_product*:
|
||||
the module for the Intrastat Declaration for Belgium.
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
WARNING:
|
||||
|
||||
This module conflicts with the module *report_intrastat* from the official addons.
|
||||
If you have already installed the module *report_intrastat*,
|
||||
you should uninstall it first before installing this module.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
This module adds an intrastat property on countries and activates this property
|
||||
on the 28 countries of the European Union.
|
||||
|
||||
With this module, the country field on partners becomes a required field.
|
||||
|
||||
It adds an option *Exclude invoice line from intrastat if this tax is present*
|
||||
on taxes.
|
||||
|
||||
It adds a tab *Intrastat* on the company form view.
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/227/10.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/intrastat/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
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
|
||||
* Luc De Meyer, Noviat <info@noviat.com>
|
||||
|
||||
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.
|
||||
2
intrastat_base/__init__.py
Normal file
2
intrastat_base/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
28
intrastat_base/__manifest__.py
Normal file
28
intrastat_base/__manifest__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Intrastat Reporting Base',
|
||||
'version': '10.0.1.0.0',
|
||||
'category': 'Intrastat',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Intrastat reporting',
|
||||
'author': 'Akretion,Odoo Community Association (OCA)',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['base_vat'],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'data/country_data.xml',
|
||||
'views/product_template.xml',
|
||||
'views/res_partner.xml',
|
||||
'views/res_country.xml',
|
||||
'views/account_tax.xml',
|
||||
'views/res_company.xml',
|
||||
'views/intrastat.xml',
|
||||
],
|
||||
'demo': [
|
||||
'demo/intrastat_demo.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
89
intrastat_base/data/country_data.xml
Normal file
89
intrastat_base/data/country_data.xml
Normal file
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="base.fr" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.de" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.at" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.cy" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.dk" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.es" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.ee" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.fi" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.gr" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.hu" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.ie" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.it" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.lv" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.lt" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.lu" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.mt" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.nl" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.pl" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.pt" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.sk" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.cz" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.uk" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.si" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.se" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.ro" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.bg" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.be" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
<record id="base.hr" model="res.country">
|
||||
<field name="intrastat" eval="True"/>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
27
intrastat_base/demo/intrastat_demo.xml
Normal file
27
intrastat_base/demo/intrastat_demo.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2011-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="base.main_partner" model="res.partner">
|
||||
<field name="vat">FR58441019213</field>
|
||||
</record>
|
||||
|
||||
<record id="base.res_partner_2" model="res.partner"> <!-- Agrolait -->
|
||||
<field name="vat">BE0884025633</field>
|
||||
<field name="supplier">True</field>
|
||||
</record>
|
||||
|
||||
<record id="shipping_costs_exclude" model="product.product">
|
||||
<field name="name">Shipping costs</field>
|
||||
<field name="default_code">SHIP</field>
|
||||
<field name="type">service</field>
|
||||
<field name="categ_id" ref="product.product_category_all"/>
|
||||
<field name="list_price">30</field>
|
||||
<field name="is_accessory_cost">True</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
182
intrastat_base/i18n/intrastat_base.pot
Normal file
182
intrastat_base/i18n/intrastat_base.pot
Normal file
@@ -0,0 +1,182 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * intrastat_base
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-05-27 18:43+0000\n"
|
||||
"PO-Revision-Date: 2015-05-27 18:43+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_base
|
||||
#: help:product.template,is_accessory_cost:0
|
||||
msgid "Activate this option for shipping costs, packaging costs and all services related to the sale of products. This option is used for Intrastat reports."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:165
|
||||
#, python-format
|
||||
msgid "Cannot delete the declaration %s because it is in Done state"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: view:res.company:intrastat_base.view_company_form
|
||||
msgid "Common Intrastat Settings"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.model,name:intrastat_base.model_report_intrastat_common
|
||||
msgid "Common functions for intrastat reports for products "
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.model,name:intrastat_base.model_res_company
|
||||
msgid "Companies"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:68
|
||||
#, python-format
|
||||
msgid "Company not yet set on intrastat report."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.model,name:intrastat_base.model_res_country
|
||||
msgid "Country"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: view:res.country:intrastat_base.view_country_search
|
||||
#: field:res.country,intrastat:0
|
||||
msgid "EU Country"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: field:product.template,exclude_from_intrastat:0
|
||||
msgid "Exclude from Intrastat reports"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: field:account.tax,exclude_from_intrastat_if_present:0
|
||||
msgid "Exclude invoice line from intrastat if this tax is present"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: field:report.intrastat.common,id:0
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: help:product.template,exclude_from_intrastat:0
|
||||
msgid "If set to True, the product or service will not be taken into account for Intrastat Product or Service reports. So you should leave this field to False unless you have a very good reason."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: help:account.tax,exclude_from_intrastat_if_present:0
|
||||
msgid "If this tax is present on an invoice line, this invoice line will be skipped when generating Intrastat Product or Service lines from invoices."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: view:product.template:intrastat_base.product_template_form_view
|
||||
msgid "Intrastat Properties"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.ui.menu,name:intrastat_base.menu_intrastat_base_root
|
||||
msgid "Intrastat Reporting"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: view:res.company:intrastat_base.view_company_form
|
||||
msgid "Intrastat Settings"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: field:product.template,is_accessory_cost:0
|
||||
msgid "Is accessory cost"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: help:res.company,intrastat_remind_user_ids:0
|
||||
msgid "List of OpenERP users who will receive a notification to remind them about the Intrastat declaration."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/company.py:55
|
||||
#, python-format
|
||||
msgid "Missing e-mail address on user '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.model,name:intrastat_base.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: view:res.country:intrastat_base.view_country_search
|
||||
msgid "Search Countries"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: help:res.country,intrastat:0
|
||||
msgid "Set to True for all European Union countries."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:product.template,name:intrastat_base.shipping_costs_exclude_product_template
|
||||
msgid "Shipping costs"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: model:ir.model,name:intrastat_base.model_account_tax
|
||||
msgid "Tax"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:84
|
||||
#, python-format
|
||||
msgid "The VAT number is not set for the partner '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:76
|
||||
#, python-format
|
||||
msgid "The company currency must be 'EUR', but is currently '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:72
|
||||
#, python-format
|
||||
msgid "The country is not set on the company '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:105
|
||||
#, python-format
|
||||
msgid "The generated XML file is not valid against the official XML Schema Definition. The generated XML file and the full error have been written in the server logs. Here is the error, which may give you an idea on the cause of the problem : %s."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/product.py:51
|
||||
#, python-format
|
||||
msgid "The option 'Is accessory cost?' should only be activated on 'Service' products. You have activated this option for the product '%s' which is of type '%s'"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: code:addons/intrastat_base/intrastat_common.py:62
|
||||
#, python-format
|
||||
msgid "The start date must be the first day of the month"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_base
|
||||
#: field:res.company,intrastat_remind_user_ids:0
|
||||
msgid "Users Receiving the Intrastat Reminder"
|
||||
msgstr ""
|
||||
|
||||
7
intrastat_base/models/__init__.py
Normal file
7
intrastat_base/models/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import res_country
|
||||
from . import product_template
|
||||
from . import account_tax
|
||||
from . import res_company
|
||||
from . import intrastat_common
|
||||
15
intrastat_base/models/account_tax.py
Normal file
15
intrastat_base/models/account_tax.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com).
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class AccountTax(models.Model):
|
||||
_inherit = "account.tax"
|
||||
|
||||
exclude_from_intrastat_if_present = fields.Boolean(
|
||||
string='Exclude invoice line from intrastat if this tax is present',
|
||||
help="If this tax is present on an invoice line, this invoice "
|
||||
"line will be skipped when generating Intrastat Product or "
|
||||
"Service lines from invoices.")
|
||||
168
intrastat_base/models/intrastat_common.py
Normal file
168
intrastat_base/models/intrastat_common.py
Normal file
@@ -0,0 +1,168 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api, tools, _
|
||||
from odoo.exceptions import UserError
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IntrastatCommon(models.AbstractModel):
|
||||
_name = "intrastat.common"
|
||||
_description = "Common functions for intrastat reports for products "
|
||||
"and services"
|
||||
|
||||
@api.multi
|
||||
@api.depends('declaration_line_ids.amount_company_currency')
|
||||
def _compute_numbers(self):
|
||||
for this in self:
|
||||
total_amount = 0 # it is an integer
|
||||
num_lines = 0
|
||||
for line in this.declaration_line_ids:
|
||||
total_amount += line.amount_company_currency
|
||||
num_lines += 1
|
||||
this.num_decl_lines = num_lines
|
||||
this.total_amount = total_amount
|
||||
|
||||
@api.multi
|
||||
def _check_generate_lines(self):
|
||||
"""Check wether all requirements are met for generating lines."""
|
||||
for this in self:
|
||||
if not this.company_id:
|
||||
raise UserError(_("Company not yet set on intrastat report."))
|
||||
company = this.company_id
|
||||
if not company.country_id:
|
||||
raise UserError(
|
||||
_("The country is not set on the company '%s'.")
|
||||
% company.name)
|
||||
if company.currency_id.name != 'EUR':
|
||||
raise UserError(
|
||||
_("The company currency must be 'EUR', but is currently "
|
||||
"'%s'.")
|
||||
% company.currency_id.name)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _check_generate_xml(self):
|
||||
for this in self:
|
||||
if not this.company_id.partner_id.vat:
|
||||
raise UserError(
|
||||
_("The VAT number is not set for the partner '%s'.")
|
||||
% this.company_id.partner_id.name)
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def _check_xml_schema(self, xml_string, xsd_file):
|
||||
'''Validate the XML file against the XSD'''
|
||||
from lxml import etree
|
||||
from StringIO import StringIO
|
||||
xsd_etree_obj = etree.parse(
|
||||
tools.file_open(xsd_file))
|
||||
official_schema = etree.XMLSchema(xsd_etree_obj)
|
||||
try:
|
||||
t = etree.parse(StringIO(xml_string))
|
||||
official_schema.assertValid(t)
|
||||
except Exception, e:
|
||||
# if the validation of the XSD fails, we arrive here
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.warning(
|
||||
"The XML file is invalid against the XML Schema Definition")
|
||||
logger.warning(xml_string)
|
||||
logger.warning(e)
|
||||
raise UserError(
|
||||
_("The generated XML file is not valid against the official "
|
||||
"XML Schema Definition. The generated XML file and the "
|
||||
"full error have been written in the server logs. "
|
||||
"Here is the error, which may give you an idea on the "
|
||||
"cause of the problem : %s.")
|
||||
% str(e))
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _attach_xml_file(self, xml_string, declaration_name):
|
||||
'''Attach the XML file to the report_intrastat_product/service
|
||||
object'''
|
||||
self.ensure_one()
|
||||
import base64
|
||||
filename = '%s_%s.xml' % (self.year_month, declaration_name)
|
||||
attach = self.env['ir.attachment'].create({
|
||||
'name': filename,
|
||||
'res_id': self.id,
|
||||
'res_model': self._name,
|
||||
'datas': base64.encodestring(xml_string),
|
||||
'datas_fname': filename})
|
||||
return attach.id
|
||||
|
||||
@api.multi
|
||||
def _unlink_attachments(self):
|
||||
atts = self.env['ir.attachment'].search(
|
||||
[('res_model', '=', self._name),
|
||||
('res_id', '=', self.id)])
|
||||
atts.unlink()
|
||||
|
||||
@api.model
|
||||
def _open_attach_view(self, attach_id, title='XML file'):
|
||||
'''Returns an action which opens the form view of the
|
||||
corresponding attachement'''
|
||||
action = {
|
||||
'name': title,
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'ir.attachment',
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
'res_id': attach_id,
|
||||
}
|
||||
return action
|
||||
|
||||
@api.multi
|
||||
def _generate_xml(self):
|
||||
"""
|
||||
Inherit this method in the localization module
|
||||
to generate the INTRASTAT Declaration XML file
|
||||
|
||||
Returns:
|
||||
string with XML data
|
||||
|
||||
Call the _check_xml_schema() method
|
||||
before returning the XML string.
|
||||
"""
|
||||
return False
|
||||
|
||||
@api.multi
|
||||
def send_reminder_email(self, mail_template_xmlid):
|
||||
mail_template = self.env.ref(mail_template_xmlid)
|
||||
for this in self:
|
||||
if this.company_id.intrastat_remind_user_ids:
|
||||
mail_template.send_mail(this.id)
|
||||
logger.info(
|
||||
'Intrastat Reminder email has been sent (XMLID: %s).'
|
||||
% mail_template_xmlid)
|
||||
else:
|
||||
logger.warning(
|
||||
'The list of users receiving the Intrastat Reminder is '
|
||||
'empty on company %s' % this.company_id.name)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
for intrastat in self:
|
||||
if intrastat.state == 'done':
|
||||
raise UserError(
|
||||
_('Cannot delete the declaration %s '
|
||||
'because it is in Done state') % self.year_month)
|
||||
return super(IntrastatCommon, self).unlink()
|
||||
|
||||
|
||||
class IntrastatResultView(models.TransientModel):
|
||||
"""
|
||||
Transient Model to display Intrastat Report results
|
||||
"""
|
||||
_name = 'intrastat.result.view'
|
||||
|
||||
note = fields.Text(
|
||||
string='Notes', readonly=True,
|
||||
default=lambda self: self._context.get('note'))
|
||||
28
intrastat_base/models/product_template.py
Normal file
28
intrastat_base/models/product_template.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
is_accessory_cost = fields.Boolean(
|
||||
string='Is accessory cost',
|
||||
help="Activate this option for shipping costs, packaging "
|
||||
"costs and all services related to the sale of products. "
|
||||
"This option is used for Intrastat reports.")
|
||||
|
||||
@api.multi
|
||||
@api.constrains('type', 'is_accessory_cost')
|
||||
def _check_accessory_cost(self):
|
||||
for this in self:
|
||||
if this.is_accessory_cost and this.type != 'service':
|
||||
raise ValidationError(
|
||||
_("The option 'Is accessory cost?' should only be "
|
||||
"activated on 'Service' products. You have activated "
|
||||
"this option for the product '%s' which is of type "
|
||||
"'%s'") %
|
||||
(this.name, this.type))
|
||||
40
intrastat_base/models/res_company.py
Normal file
40
intrastat_base/models/res_company.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = "res.company"
|
||||
|
||||
intrastat_remind_user_ids = fields.Many2many(
|
||||
'res.users', column1='company_id', column2='user_id',
|
||||
string="Users Receiving the Intrastat Reminder",
|
||||
help="List of Odoo users who will receive a notification to "
|
||||
"remind them about the Intrastat declaration.")
|
||||
intrastat_email_list = fields.Char(
|
||||
compute='_compute_intrastat_email_list',
|
||||
string='List of emails of Users Receiving the Intrastat Reminder')
|
||||
|
||||
@api.multi
|
||||
@api.depends(
|
||||
'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email')
|
||||
def _compute_intrastat_email_list(self):
|
||||
for this in self:
|
||||
emails = []
|
||||
for user in this.intrastat_remind_user_ids:
|
||||
if user.email:
|
||||
emails.append(user.email)
|
||||
this.intrastat_email_list = ','.join(emails)
|
||||
|
||||
@api.multi
|
||||
@api.constrains('intrastat_remind_user_ids')
|
||||
def _check_intrastat_remind_users(self):
|
||||
for this in self:
|
||||
for user in this.intrastat_remind_user_ids:
|
||||
if not user.email:
|
||||
raise ValidationError(
|
||||
_("Missing e-mail address on user '%s'.") %
|
||||
(user.name))
|
||||
13
intrastat_base/models/res_country.py
Normal file
13
intrastat_base/models/res_country.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2014 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ResCountry(models.Model):
|
||||
_inherit = 'res.country'
|
||||
|
||||
intrastat = fields.Boolean(
|
||||
string='EU Country',
|
||||
help="Set to True for all European Union countries.")
|
||||
21
intrastat_base/views/account_tax.xml
Normal file
21
intrastat_base/views/account_tax.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2011-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Add 'exclude_from_intrastat_if_present' on tax form view -->
|
||||
<record id="view_tax_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.base.tax</field>
|
||||
<field name="model">account.tax</field>
|
||||
<field name="inherit_id" ref="account.view_tax_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="active" position="before">
|
||||
<field name="exclude_from_intrastat_if_present"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
33
intrastat_base/views/intrastat.xml
Normal file
33
intrastat_base/views/intrastat.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2011-2016 Akretion (http://www.akretion.com/)
|
||||
© 2015-2016 Noviat (http://www.noviat.com/)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Menu entries for Intrastat -->
|
||||
<menuitem id="menu_intrastat_base_root"
|
||||
name="Intrastat"
|
||||
parent="account.menu_finance_legal_statement"/>
|
||||
<menuitem id="menu_intrastat_config_root" name="Intrastat"
|
||||
parent="account.menu_finance_configuration" sequence="50"/>
|
||||
|
||||
|
||||
<record id="intrastat_result_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.result_view_form</field>
|
||||
<field name="model">intrastat.result.view</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Result View">
|
||||
<group name="main">
|
||||
<field name="note" nolabel="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Ok" class="oe_highlight" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
28
intrastat_base/views/product_template.xml
Normal file
28
intrastat_base/views/product_template.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2010-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">intrastat.base.product.template.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="account.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="properties" position="after">
|
||||
<group string="Intrastat Properties" name="intrastat">
|
||||
<!-- If you need this field, inherit this view in a
|
||||
localisation module to set invisible="0" -->
|
||||
<field name="is_accessory_cost"
|
||||
attrs="{'invisible': [('type', '!=', 'service')]}"
|
||||
invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
26
intrastat_base/views/res_company.xml
Normal file
26
intrastat_base/views/res_company.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- TODO: move to res.config page -->
|
||||
<record id="view_company_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="base.view_company_form" />
|
||||
<field name="arch" type="xml">
|
||||
<notebook position="inside">
|
||||
<page name="intrastat" string="Intrastat">
|
||||
<group name="intrastat-common" string="Intrastat Settings">
|
||||
<field name="intrastat_remind_user_ids" widget="many2many_tags" />
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
48
intrastat_base/views/res_country.xml
Normal file
48
intrastat_base/views/res_country.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2011-2016 Akretion (http://www.akretion.com)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
|
||||
<!-- Add intrastat field on res_country -->
|
||||
<record id="view_country_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.base.country.tree</field>
|
||||
<field name="model">res.country</field>
|
||||
<field name="inherit_id" ref="base.view_country_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="code" position="after">
|
||||
<field name="intrastat" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_country_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.base.country.form</field>
|
||||
<field name="model">res.country</field>
|
||||
<field name="inherit_id" ref="base.view_country_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="code" position="after">
|
||||
<field name="intrastat" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- there is no native search view, so I can't inherit -->
|
||||
<record id="res_country_view_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.base.country.search</field>
|
||||
<field name="model">res.country</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Countries">
|
||||
<field name="name" />
|
||||
<field name="code" />
|
||||
<filter name="intrastat" string="EU Country"
|
||||
domain="[('intrastat', '=', True)]" />
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
25
intrastat_base/views/res_partner.xml
Normal file
25
intrastat_base/views/res_partner.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2010-2016 Akretion (http://www.akretion.com/)
|
||||
@author David BEAL <david.beal@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Set country_id field to required on partner form view -->
|
||||
<record id="view_partner_form" model="ir.ui.view">
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='country_id']" position="attributes">
|
||||
<attribute name="required">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='child_ids']/form//field[@name='country_id']"
|
||||
position="attributes">
|
||||
<attribute name="required">1</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
104
intrastat_product/README.rst
Normal file
104
intrastat_product/README.rst
Normal file
@@ -0,0 +1,104 @@
|
||||
.. 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 Product
|
||||
=================
|
||||
|
||||
This module contains common objects and fields for the Intrastat Product reporting, such as the *H.S. codes* (if you are not familiar with H.S. codes, read `Wikipedia <http://en.wikipedia.org/wiki/Harmonized_System>`) and the *country of origin* on the products.
|
||||
|
||||
It should be used in combination with country-specific Intrastat Product reporting modules
|
||||
such as:
|
||||
|
||||
- *l10n_fr_intrastat_product*:
|
||||
the module for the *Déclaration d'Echange de Biens* (DEB) for France
|
||||
- *l10n_be_intrastat_product*:
|
||||
the module for the Intrastat Product Declaration for Belgium
|
||||
|
||||
These country-specific modules can be found in the OCA localization for those countries.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
WARNING:
|
||||
|
||||
This module conflicts with the module *report_intrastat* from the official addons.
|
||||
If you have already installed the module *report_intrastat*,
|
||||
you should uninstall it before installing this module.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
This module is used in combination with the country-specific
|
||||
localization module(s).
|
||||
|
||||
Coding guidelines for localization module:
|
||||
------------------------------------------
|
||||
|
||||
We recommend to start by copying an existing module, e.g. l10n_be_intrastat_product
|
||||
and adapt the code for the specific needs of your country.
|
||||
|
||||
* Declaration Object
|
||||
|
||||
Create a new class as follows:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class L10nCcIntrastatProductDeclaration(models.Model):
|
||||
_name = 'l10n.cc.intrastat.product.declaration'
|
||||
_description = "Intrastat Product Declaration for YourCountry"
|
||||
_inherit = ['intrastat.product.declaration', 'mail.thread']
|
||||
|
||||
whereby cc = your country code
|
||||
|
||||
* Computation & Declaration Lines
|
||||
|
||||
Create also new objects inheriting from the Computation and Declaration Line Objects
|
||||
so that you can add methods or customise the methods from the base modules (make a PR when
|
||||
the customization or new method is required for multiple countries).
|
||||
|
||||
Adapt also the parent_id fields of the newly created objects
|
||||
(cf. l10n_be_intrastat_product as example).
|
||||
|
||||
* XML Files: Menu, Action, Views
|
||||
|
||||
Cf. l10n_be_istrastat_product as example, replace "be" by your Country Code.
|
||||
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/227/8.0
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/intrastat/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
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
|
||||
* Luc De Meyer, Noviat <info@noviat.com>
|
||||
|
||||
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.
|
||||
3
intrastat_product/__init__.py
Normal file
3
intrastat_product/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
58
intrastat_product/__manifest__.py
Normal file
58
intrastat_product/__manifest__.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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': '8.0.1.4.1',
|
||||
'category': 'Intrastat',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Intrastat Product',
|
||||
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
|
||||
'depends': [
|
||||
'intrastat_base',
|
||||
'product_harmonized_system',
|
||||
'stock_picking_invoice_link',
|
||||
'sale_stock',
|
||||
'purchase',
|
||||
],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'views/hs_code.xml',
|
||||
'views/intrastat_region.xml',
|
||||
'views/intrastat_unit.xml',
|
||||
'views/intrastat_transaction.xml',
|
||||
'views/intrastat_transport_mode.xml',
|
||||
'views/intrastat_product_declaration.xml',
|
||||
'views/res_company.xml',
|
||||
'views/account_invoice.xml',
|
||||
'views/stock_picking.xml',
|
||||
'views/stock_warehouse.xml',
|
||||
'security/intrastat_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'data/intrastat_transport_mode.xml',
|
||||
'data/intrastat_unit.xml',
|
||||
],
|
||||
'demo': ['demo/intrastat_demo.xml'],
|
||||
'installable': False,
|
||||
}
|
||||
53
intrastat_product/data/intrastat_transport_mode.xml
Normal file
53
intrastat_product/data/intrastat_transport_mode.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="intrastat_transport_1" model="intrastat.transport_mode">
|
||||
<field name="code">1</field>
|
||||
<field name="name">Sea</field>
|
||||
<field name="description">Sea Transport (including wagons, motor vehicles, trailers, semi-trailers and lighters on board of a ship)</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_2" model="intrastat.transport_mode">
|
||||
<field name="code">2</field>
|
||||
<field name="name">Rail</field>
|
||||
<field name="description">Railway transport (including lorries on railway wagons)</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_3" model="intrastat.transport_mode">
|
||||
<field name="code">3</field>
|
||||
<field name="name">Road</field>
|
||||
<field name="description">Road Transport</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_4" model="intrastat.transport_mode">
|
||||
<field name="code">4</field>
|
||||
<field name="name">Air</field>
|
||||
<field name="description">Air Transport</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_5" model="intrastat.transport_mode">
|
||||
<field name="code">5</field>
|
||||
<field name="name">Post</field>
|
||||
<field name="description">Postal consignments</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_7" model="intrastat.transport_mode">
|
||||
<field name="code">7</field>
|
||||
<field name="name">Fixed installations</field>
|
||||
<field name="description">Fixed transport installations (e.g. pipelines, high-tension cables)</field>
|
||||
<field name="description"></field>
|
||||
</record>
|
||||
<record id="intrastat_transport_8" model="intrastat.transport_mode">
|
||||
<field name="code">8</field>
|
||||
<field name="name">Inland waterway</field>
|
||||
<field name="description">Inland waterway transport</field>
|
||||
</record>
|
||||
<record id="intrastat_transport_9" model="intrastat.transport_mode">
|
||||
<field name="code">9</field>
|
||||
<field name="name">Own propulsion</field>
|
||||
<field name="description">Own propulsion (imported or exported means of transport crossing the border under their own power, e.g. aircraft, lorries, boats, etc.)</field>
|
||||
</record>
|
||||
|
||||
<!-- Set default value to Road trp on main company -->
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="intrastat_transport_id" ref="intrastat_transport_3"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
125
intrastat_product/data/intrastat_unit.xml
Normal file
125
intrastat_product/data/intrastat_unit.xml
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<!-- Extracted from the Official Journal of the European Union -->
|
||||
|
||||
<record id="intrastat_unit_c_k" model="intrastat.unit">
|
||||
<field name="name">c/k</field>
|
||||
<field name="description">Carats - 1 metric carat = 2 × 10exp(–4) kg</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_ce_el" model="intrastat.unit">
|
||||
<field name="name">ce/el</field>
|
||||
<field name="description">Number of cells</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_ct_l" model="intrastat.unit">
|
||||
<field name="name">ct/l</field>
|
||||
<field name="description">Carrying capacity in tonnes</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_g" model="intrastat.unit">
|
||||
<field name="name">g</field>
|
||||
<field name="description">Gram</field>
|
||||
<field name="uom_id" ref="product.product_uom_gram"/>
|
||||
</record>
|
||||
<record id="intrastat_unit_gi_FS" model="intrastat.unit">
|
||||
<field name="name">gi F/S</field>
|
||||
<field name="description">Gram of fissile isotopes</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_H2O2" model="intrastat.unit">
|
||||
<field name="name">kg H2O2</field>
|
||||
<field name="description">Kilogram of hydrogen peroxide</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_K2O" model="intrastat.unit">
|
||||
<field name="name">kg K2O</field>
|
||||
<field name="description">Kilogram of potassium oxide</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_KOH" model="intrastat.unit">
|
||||
<field name="name">kg KOH</field>
|
||||
<field name="description">Kilogram of potassium hydroxide (caustic potash)</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_ma" model="intrastat.unit">
|
||||
<field name="name">kg met.am.</field>
|
||||
<field name="description">Kilogram of methylamines</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_N" model="intrastat.unit">
|
||||
<field name="name">kg N</field>
|
||||
<field name="description">Kilogram of nitrogen</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_NaOH" model="intrastat.unit">
|
||||
<field name="name">kg NaOH</field>
|
||||
<field name="description">Kilogram of sodium hydroxide (caustic soda)</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_net_eda" model="intrastat.unit">
|
||||
<field name="name">kg/net eda</field>
|
||||
<field name="description">Kilogram drained net weight</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_P2O5" model="intrastat.unit">
|
||||
<field name="name">kg P2O5</field>
|
||||
<field name="description">Kilogram of diphosphorus pentaoxide</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_90_pct_sdt" model="intrastat.unit">
|
||||
<field name="name">kg 90 pct sdt</field>
|
||||
<field name="description">Kilogram of substance 90 % dry</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_kg_U" model="intrastat.unit">
|
||||
<field name="name">kg U</field>
|
||||
<field name="description">Kilogram of uranium</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_1000_kWh" model="intrastat.unit">
|
||||
<field name="name">1000 kWh</field>
|
||||
<field name="description">Thousand kilowatt hours</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_l" model="intrastat.unit">
|
||||
<field name="name">l</field>
|
||||
<field name="description">Litre</field>
|
||||
<field name="uom_id" ref="product.product_uom_litre"/>
|
||||
</record>
|
||||
<record id="intrastat_unit_1000l" model="intrastat.unit">
|
||||
<field name="name">1000 l</field>
|
||||
<field name="description">Thousand litres</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_l_alc_100_pct" model="intrastat.unit">
|
||||
<field name="name">l alc. 100 pct</field>
|
||||
<field name="description">Litre pure (100 %) alcohol</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_m" model="intrastat.unit">
|
||||
<field name="name">m</field>
|
||||
<field name="description">Metre</field>
|
||||
<field name="uom_id" ref="product.product_uom_meter"/>
|
||||
</record>
|
||||
<record id="intrastat_unit_m2" model="intrastat.unit">
|
||||
<field name="name">m2</field>
|
||||
<field name="description">Square metre</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_m3" model="intrastat.unit">
|
||||
<field name="name">m3</field>
|
||||
<field name="description">Cubic metre</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_1000m3" model="intrastat.unit">
|
||||
<field name="name">1000 m3</field>
|
||||
<field name="description">Thousand cubic metres</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_pa" model="intrastat.unit">
|
||||
<field name="name">pa</field>
|
||||
<field name="description">Number of pairs</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_pce" model="intrastat.unit">
|
||||
<field name="name">items</field>
|
||||
<field name="description">Number of items</field>
|
||||
<field name="uom_id" ref="product.product_uom_unit"/>
|
||||
</record>
|
||||
<record id="intrastat_unit_100pce" model="intrastat.unit">
|
||||
<field name="name">100 items</field>
|
||||
<field name="description">Hundred items</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_1000pce" model="intrastat.unit">
|
||||
<field name="name">1000 items</field>
|
||||
<field name="description">Thousand items</field>
|
||||
</record>
|
||||
<record id="intrastat_unit_TJ" model="intrastat.unit">
|
||||
<field name="name">TJ</field>
|
||||
<field name="description">Terajoule (gross calorific value)</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
28
intrastat_product/demo/intrastat_demo.xml
Normal file
28
intrastat_product/demo/intrastat_demo.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2011-2015 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="product_harmonized_system.84715000" model="hs.code">
|
||||
<field name="intrastat_unit_id" ref="intrastat_unit_pce"/>
|
||||
</record>
|
||||
|
||||
<record id="product_harmonized_system.84717050" model="hs.code">
|
||||
<field name="intrastat_unit_id" ref="intrastat_unit_pce"/>
|
||||
</record>
|
||||
|
||||
<record id="base.main_company" model="res.company">
|
||||
<field name="intrastat_arrivals">extended</field>
|
||||
<field name="intrastat_dispatches">extended</field>
|
||||
<field name="intrastat_incoterm_id" ref="stock.incoterm_DDU"/>
|
||||
<field name="intrastat_transport_id" ref="intrastat_transport_3"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
186
intrastat_product/i18n/intrastat_product.pot
Normal file
186
intrastat_product/i18n/intrastat_product.pot
Normal file
@@ -0,0 +1,186 @@
|
||||
# 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: 2015-05-27 18:43+0000\n"
|
||||
"PO-Revision-Date: 2015-05-27 18:43+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
|
||||
#: field:report.intrastat.code,active:0
|
||||
msgid "Active"
|
||||
msgstr ""
|
||||
|
||||
#. 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
|
||||
#: help:report.intrastat.code,intrastat_code:0
|
||||
msgid "Code used for the Intrastat declaration. Must be part of the 'Combined Nomenclature' (CN), cf http://en.wikipedia.org/wiki/Combined_NomenclatureMust have 8 digits with sometimes a 9th digit."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: field:product.template,origin_country_id:0
|
||||
msgid "Country of Origin"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: help:product.template,origin_country_id:0
|
||||
msgid "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."
|
||||
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
|
||||
#: field:report.intrastat.code,display_name:0
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: field:report.intrastat.code,intrastat_code:0
|
||||
msgid "European Intrastat Code"
|
||||
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:73
|
||||
#, 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
|
||||
#: view:report.intrastat.code:intrastat_product.product_intrastat_code_form
|
||||
#: field:report.intrastat.code,product_categ_ids:0
|
||||
msgid "Product Categories"
|
||||
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_form
|
||||
#: field:report.intrastat.code,product_tmpl_ids:0
|
||||
msgid "Products"
|
||||
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,intrastat_uom_id:0
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: help:report.intrastat.code,description:0
|
||||
msgid "Short text description of the H.S. category"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: code:addons/intrastat_product/intrastat.py:82
|
||||
#, python-format
|
||||
msgid "The field Intrastat Code should contain 8 or 9 digits. It is not the case of Intrastat Code '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: code:addons/intrastat_product/intrastat.py:77
|
||||
#, python-format
|
||||
msgid "The field Intrastat Code should only contain digits. It is not the case of Intrastat Code '%s'."
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: sql_constraint:report.intrastat.code:0
|
||||
msgid "This H.S. code already exists in Odoo !"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: field:report.intrastat.code,intrastat_uom_id:0
|
||||
msgid "UoM for Intrastat Report"
|
||||
msgstr ""
|
||||
|
||||
12
intrastat_product/models/__init__.py
Normal file
12
intrastat_product/models/__init__.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from . import res_company
|
||||
from . import account_invoice
|
||||
from . import hs_code
|
||||
from . import intrastat_product_declaration
|
||||
from . import intrastat_region
|
||||
from . import intrastat_transaction
|
||||
from . import intrastat_transport_mode
|
||||
from . import intrastat_unit
|
||||
from . import sale_order
|
||||
from . import stock_picking
|
||||
from . import stock_warehouse
|
||||
129
intrastat_product/models/account_invoice.py
Normal file
129
intrastat_product/models/account_invoice.py
Normal file
@@ -0,0 +1,129 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2016 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2016 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
incoterm_id = fields.Many2one(
|
||||
'stock.incoterms', string='Incoterm',
|
||||
help="International Commercial Terms are a series of predefined "
|
||||
"commercial terms used in international transactions.")
|
||||
intrastat_transaction_id = fields.Many2one(
|
||||
'intrastat.transaction', string='Intrastat Transaction Type',
|
||||
default=lambda self: self._default_intrastat_transaction_id(),
|
||||
ondelete='restrict',
|
||||
help="Intrastat nature of transaction")
|
||||
intrastat_transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode', string='Intrastat Transport Mode',
|
||||
ondelete='restrict')
|
||||
src_dest_country_id = fields.Many2one(
|
||||
'res.country', string='Origin/Destination Country',
|
||||
ondelete='restrict')
|
||||
src_dest_region_id = fields.Many2one(
|
||||
'intrastat.region', string='Origin/Destination Region',
|
||||
default=lambda self: self._default_src_dest_region_id(),
|
||||
help="Origin/Destination Region."
|
||||
"\nThis field is used for the Intrastat Declaration.",
|
||||
ondelete='restrict')
|
||||
intrastat_country = fields.Boolean(
|
||||
compute='_compute_intrastat_country',
|
||||
store=True, string='Intrastat Country', readonly=True)
|
||||
intrastat = fields.Char(
|
||||
string='Intrastat Declaration',
|
||||
related='company_id.intrastat', readonly=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('src_dest_country_id', 'partner_id.country_id')
|
||||
def _compute_intrastat_country(self):
|
||||
for inv in self:
|
||||
country = inv.src_dest_country_id \
|
||||
or inv.partner_id.country_id
|
||||
inv.intrastat_country = country.intrastat
|
||||
|
||||
@api.model
|
||||
def _default_intrastat_transaction_id(self):
|
||||
company = self.env['res.company']
|
||||
company_id = company._company_default_get('account.invoice')
|
||||
company = company.browse(company_id)
|
||||
inv_type = self._context.get('type')
|
||||
if inv_type == 'out_invoice':
|
||||
return company.intrastat_transaction_out_invoice
|
||||
elif inv_type == 'out_refund':
|
||||
return company.intrastat_transaction_out_refund
|
||||
elif inv_type == 'in_invoice':
|
||||
return company.intrastat_transaction_in_invoice
|
||||
elif inv_type == 'in_refund':
|
||||
return company.intrastat_transaction_in_refund
|
||||
else:
|
||||
return self.env['intrastat.transaction']
|
||||
|
||||
@api.model
|
||||
def _default_src_dest_region_id(self):
|
||||
rco = self.env['res.company']
|
||||
company_id = rco._company_default_get('account.invoice')
|
||||
company = rco.browse(company_id)
|
||||
return company.intrastat_region_id
|
||||
|
||||
@api.multi
|
||||
def onchange_partner_id(
|
||||
self, type, partner_id, date_invoice=False,
|
||||
payment_term=False, partner_bank_id=False, company_id=False):
|
||||
res = super(AccountInvoice, self).onchange_partner_id(
|
||||
type, partner_id, date_invoice=date_invoice,
|
||||
payment_term=payment_term, partner_bank_id=partner_bank_id,
|
||||
company_id=company_id)
|
||||
if partner_id:
|
||||
partner = self.env['res.partner'].browse(partner_id)
|
||||
res['value']['src_dest_country_id'] = partner.country_id.id
|
||||
return res
|
||||
|
||||
|
||||
class AccountInvoiceLine(models.Model):
|
||||
_inherit = 'account.invoice.line'
|
||||
|
||||
hs_code_id = fields.Many2one(
|
||||
'hs.code', string='Intrastat Code', ondelete='restrict')
|
||||
|
||||
@api.multi
|
||||
def product_id_change(
|
||||
self, product, uom_id, qty=0, name='', type='out_invoice',
|
||||
partner_id=False, fposition_id=False, price_unit=False,
|
||||
currency_id=False, company_id=None):
|
||||
res = super(AccountInvoiceLine, self).product_id_change(
|
||||
product, uom_id, qty=qty, name=name, type=type,
|
||||
partner_id=partner_id, fposition_id=fposition_id,
|
||||
price_unit=price_unit, currency_id=currency_id,
|
||||
company_id=company_id)
|
||||
|
||||
if product:
|
||||
product = self.env['product.product'].browse(product)
|
||||
hs_code = product.product_tmpl_id.get_hs_code_recursively()
|
||||
if hs_code:
|
||||
res['value']['hs_code_id'] = hs_code.id
|
||||
else:
|
||||
res['value']['hs_code_id'] = False
|
||||
return res
|
||||
48
intrastat_product/models/hs_code.py
Normal file
48
intrastat_product/models/hs_code.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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 HSCode(models.Model):
|
||||
_inherit = "hs.code"
|
||||
|
||||
intrastat_unit_id = fields.Many2one(
|
||||
'intrastat.unit', string='Intrastat Supplementary Unit')
|
||||
|
||||
@api.constrains('local_code')
|
||||
def _hs_code(self):
|
||||
if self.company_id.country_id.intrastat:
|
||||
if not self.local_code.isdigit():
|
||||
raise ValidationError(
|
||||
_("Intrastat Codes should only contain digits. "
|
||||
"This is not the case for code '%s'.")
|
||||
% self.local_code)
|
||||
if len(self.local_code) != 8:
|
||||
raise ValidationError(
|
||||
_("Intrastat Codes should "
|
||||
"contain 8 digits. This is not the case for "
|
||||
"Intrastat Code '%s' which has %d digits.")
|
||||
% (self.local_code, len(self.local_code)))
|
||||
955
intrastat_product/models/intrastat_product_declaration.py
Normal file
955
intrastat_product/models/intrastat_product_declaration.py
Normal file
@@ -0,0 +1,955 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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 RedirectWarning, ValidationError
|
||||
from openerp.exceptions import Warning as UserError
|
||||
import openerp.addons.decimal_precision as dp
|
||||
from datetime import datetime, date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IntrastatProductDeclaration(models.Model):
|
||||
_name = 'intrastat.product.declaration'
|
||||
_description = "Intrastat Product Report Base Object"
|
||||
_rec_name = 'year_month'
|
||||
_inherit = ['mail.thread', 'intrastat.common']
|
||||
_order = 'year_month desc, type, revision'
|
||||
_track = {
|
||||
'state': {
|
||||
'intrastat_product.declaration_done':
|
||||
lambda self, cr, uid, obj, ctx=None: obj['state'] == 'done',
|
||||
}
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _get_type(self):
|
||||
res = []
|
||||
company = self.env.user.company_id
|
||||
arrivals = company.intrastat_arrivals
|
||||
dispatches = company.intrastat_dispatches
|
||||
if arrivals != 'exempt':
|
||||
res.append(('arrivals', _('Declaration for Arrivals')))
|
||||
if dispatches != 'exempt':
|
||||
res.append(('dispatches', _('Declaration for Dispatches')))
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _get_reporting_level(self):
|
||||
return [
|
||||
('standard', _('Standard')),
|
||||
('extended', _('Extended'))]
|
||||
|
||||
@api.onchange('type')
|
||||
def _onchange_type(self):
|
||||
if self.type == 'arrivals':
|
||||
self.reporting_level = \
|
||||
self.company_id.intrastat_arrivals == 'extended' \
|
||||
and 'extended' or 'standard'
|
||||
if self.type == 'dispatches':
|
||||
self.reporting_level = \
|
||||
self.company_id.intrastat_dispatches == 'extended' \
|
||||
and 'extended' or 'standard'
|
||||
|
||||
@api.model
|
||||
def _get_company(self):
|
||||
return self.env.user.company_id
|
||||
|
||||
@api.model
|
||||
def _get_year(self):
|
||||
if datetime.now().month == 1:
|
||||
return datetime.now().year - 1
|
||||
else:
|
||||
return datetime.now().year
|
||||
|
||||
@api.model
|
||||
def _get_month(self):
|
||||
if datetime.now().month == 1:
|
||||
return 12
|
||||
else:
|
||||
return datetime.now().month - 1
|
||||
|
||||
@api.model
|
||||
def _get_action(self):
|
||||
return [
|
||||
('replace', 'Replace'),
|
||||
('append', 'Append'),
|
||||
('nihil', 'Nihil')]
|
||||
|
||||
@api.model
|
||||
def _get_default_action(self):
|
||||
return 'replace'
|
||||
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company', readonly=True,
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'intrastat.product.declaration'))
|
||||
company_country_code = fields.Char(
|
||||
compute='_compute_company_country_code',
|
||||
string='Company Country Code', readonly=True, store=True,
|
||||
help="Used in views and methods of localization modules.")
|
||||
year = fields.Integer(
|
||||
string='Year', required=True,
|
||||
default=_get_year)
|
||||
month = fields.Selection([
|
||||
(1, '01'),
|
||||
(2, '02'),
|
||||
(3, '03'),
|
||||
(4, '04'),
|
||||
(5, '05'),
|
||||
(6, '06'),
|
||||
(7, '07'),
|
||||
(8, '08'),
|
||||
(9, '09'),
|
||||
(10, '10'),
|
||||
(11, '11'),
|
||||
(12, '12')
|
||||
], string='Month', required=True,
|
||||
default=_get_month)
|
||||
year_month = fields.Char(
|
||||
compute='_compute_year_month', string='Period', readonly=True,
|
||||
track_visibility='onchange', store=True,
|
||||
help="Year and month of the declaration.")
|
||||
type = fields.Selection(
|
||||
'_get_type', string='Type', required=True,
|
||||
states={'done': [('readonly', True)]},
|
||||
track_visibility='onchange', help="Select the declaration type.")
|
||||
action = fields.Selection(
|
||||
'_get_action',
|
||||
string='Action', required=True,
|
||||
default=_get_default_action,
|
||||
states={'done': [('readonly', True)]},
|
||||
track_visibility='onchange')
|
||||
revision = fields.Integer(
|
||||
string='Revision', default=1,
|
||||
states={'done': [('readonly', True)]},
|
||||
help="Used to keep track of changes")
|
||||
computation_line_ids = fields.One2many(
|
||||
'intrastat.product.computation.line',
|
||||
'parent_id', string='Intrastat Product Computation Lines',
|
||||
states={'done': [('readonly', True)]})
|
||||
declaration_line_ids = fields.One2many(
|
||||
'intrastat.product.declaration.line',
|
||||
'parent_id', string='Intrastat Product Declaration Lines',
|
||||
states={'done': [('readonly', True)]})
|
||||
num_decl_lines = fields.Integer(
|
||||
compute='_compute_numbers', string='Number of Declaration Lines',
|
||||
store=True, track_visibility='onchange')
|
||||
total_amount = fields.Integer(
|
||||
compute='_compute_numbers', string='Total Fiscal Amount', store=True,
|
||||
help="Total fiscal amount in company currency of the declaration.")
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency', related='company_id.currency_id', readonly=True,
|
||||
string='Currency')
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('done', 'Done'),
|
||||
], string='State', readonly=True, track_visibility='onchange',
|
||||
copy=False, default='draft',
|
||||
help="State of the declaration. When the state is set to 'Done', "
|
||||
"the parameters become read-only.")
|
||||
note = fields.Text(
|
||||
string='Notes',
|
||||
help="You can add some comments here if you want.")
|
||||
reporting_level = fields.Selection(
|
||||
'_get_reporting_level',
|
||||
string='Reporting Level')
|
||||
valid = fields.Boolean(
|
||||
compute='_check_validity',
|
||||
string='Valid')
|
||||
|
||||
@api.model
|
||||
@api.constrains('year')
|
||||
def _check_year(self):
|
||||
for this in self:
|
||||
s = str(this.year)
|
||||
if len(s) != 4 or s[0] != '2':
|
||||
raise ValidationError(_("Invalid Year !"))
|
||||
|
||||
_sql_constraints = [
|
||||
('date_uniq',
|
||||
'unique(year_month, company_id, type, revision)',
|
||||
"A declaration of the same type already exists for this month !"
|
||||
"\nYou should update the existing declaration "
|
||||
"or change the revision number of this one."),
|
||||
]
|
||||
|
||||
@api.multi
|
||||
@api.depends('company_id')
|
||||
def _compute_company_country_code(self):
|
||||
for this in self:
|
||||
if this.company_id:
|
||||
this.company_country_code = \
|
||||
this.company_id.country_id.code.lower()
|
||||
|
||||
@api.multi
|
||||
@api.depends('year', 'month')
|
||||
def _compute_year_month(self):
|
||||
for this in self:
|
||||
if this.year and this.month:
|
||||
this.year_month = '-'.join(
|
||||
[str(this.year), format(this.month, '02')])
|
||||
|
||||
@api.multi
|
||||
@api.depends('month')
|
||||
def _check_validity(self):
|
||||
""" TO DO: logic based upon computation lines """
|
||||
for this in self:
|
||||
this.valid = True
|
||||
|
||||
@api.multi
|
||||
def copy(self, default=None):
|
||||
self.ensure_one()
|
||||
default = default or {}
|
||||
default['revision'] = self.revision + 1
|
||||
return super(IntrastatProductDeclaration, self).copy(default)
|
||||
|
||||
def _company_warning(self, msg):
|
||||
action = self.env.ref('base.action_res_company_form')
|
||||
raise RedirectWarning(
|
||||
msg, action.id,
|
||||
_('Go to company configuration screen'))
|
||||
|
||||
def _get_partner_country(self, inv_line):
|
||||
country = inv_line.invoice_id.src_dest_country_id \
|
||||
or inv_line.invoice_id.partner_id.country_id
|
||||
if not country.intrastat:
|
||||
country = False
|
||||
elif country == self.company_id.country_id:
|
||||
country = False
|
||||
return country
|
||||
|
||||
def _get_intrastat_transaction(self, inv_line):
|
||||
invoice = inv_line.invoice_id
|
||||
if invoice.intrastat_transaction_id:
|
||||
return invoice.intrastat_transaction_id
|
||||
else:
|
||||
company = invoice.company_id
|
||||
if invoice.type == 'out_invoice':
|
||||
return company.intrastat_transaction_out_invoice
|
||||
elif invoice.type == 'out_refund':
|
||||
return company.intrastat_transaction_out_refund
|
||||
elif invoice.type == 'in_invoice':
|
||||
return company.intrastat_transaction_in_invoice
|
||||
elif invoice.type == 'in_refund':
|
||||
return company.intrastat_transaction_in_refund
|
||||
|
||||
def _get_weight_and_supplunits(self, inv_line, hs_code):
|
||||
line_qty = inv_line.quantity
|
||||
product = inv_line.product_id
|
||||
invoice = inv_line.invoice_id
|
||||
intrastat_unit_id = hs_code.intrastat_unit_id
|
||||
source_uom = inv_line.uos_id
|
||||
weight_uom_categ = self._get_uom_refs('weight_uom_categ')
|
||||
kg_uom = self._get_uom_refs('kg_uom')
|
||||
pce_uom_categ = self._get_uom_refs('pce_uom_categ')
|
||||
pce_uom = self._get_uom_refs('pce_uom')
|
||||
weight = suppl_unit_qty = 0.0
|
||||
|
||||
if not source_uom:
|
||||
note = "\n" + _(
|
||||
"Missing unit of measure on the line with %d "
|
||||
"product(s) '%s' on invoice '%s'."
|
||||
) % (line_qty, product.name_get()[0][1], invoice.number)
|
||||
note += "\n" + _(
|
||||
"Please adjust this line manually.")
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
|
||||
if intrastat_unit_id:
|
||||
target_uom = intrastat_unit_id.uom_id
|
||||
if not target_uom:
|
||||
note = "\n" + _(
|
||||
"Conversion from Intrastat Supplementary Unit '%s' to "
|
||||
"Unit of Measure is not implemented yet."
|
||||
) % intrastat_unit_id.name
|
||||
note += "\n" + _(
|
||||
"Please correct the Intrastat Supplementary Unit "
|
||||
"settings and regenerate the lines or adjust the lines "
|
||||
"with Intrastat Code '%s' manually"
|
||||
) % hs_code.display_name
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
if target_uom.category_id == source_uom.category_id:
|
||||
suppl_unit_qty = self.env['product.uom']._compute_qty_obj(
|
||||
source_uom, line_qty, target_uom)
|
||||
else:
|
||||
note = "\n" + _(
|
||||
"Conversion from unit of measure '%s' to '%s' "
|
||||
"is not implemented yet."
|
||||
) % (source_uom.name, target_uom.name)
|
||||
note += "\n" + _(
|
||||
"Please correct the unit of measure settings and "
|
||||
"regenerate the lines or adjust the impacted "
|
||||
"lines manually")
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
|
||||
if source_uom == kg_uom:
|
||||
weight = line_qty
|
||||
elif source_uom.category_id == weight_uom_categ:
|
||||
weight = self.env['product.uom']._compute_qty_obj(
|
||||
source_uom, line_qty, kg_uom)
|
||||
elif source_uom.category_id == pce_uom_categ:
|
||||
if not product.weight_net:
|
||||
note = "\n" + _(
|
||||
"Missing net weight on product %s."
|
||||
) % product.name_get()[0][1]
|
||||
note += "\n" + _(
|
||||
"Please correct the product record and regenerate "
|
||||
"the lines or adjust the impacted lines manually")
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
if source_uom == pce_uom:
|
||||
weight = product.weight_net * line_qty
|
||||
else:
|
||||
# Here, I suppose that, on the product, the
|
||||
# weight is per PCE and not per uom_id
|
||||
weight = product.weight_net * \
|
||||
self.env['product.uom']._compute_qty_obj(
|
||||
source_uom, line_qty, pce_uom)
|
||||
else:
|
||||
note = "\n" + _(
|
||||
"Conversion from unit of measure '%s' to 'Kg' "
|
||||
"is not implemented yet. It is needed for product '%s'."
|
||||
) % (source_uom.name, product.name_get()[0][1])
|
||||
note += "\n" + _(
|
||||
"Please correct the unit of measure settings and "
|
||||
"regenerate the lines or adjust the impacted lines "
|
||||
"manually")
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
|
||||
return weight, suppl_unit_qty
|
||||
|
||||
def _get_amount(self, inv_line):
|
||||
invoice = inv_line.invoice_id
|
||||
amount = invoice.currency_id.with_context(
|
||||
date=invoice.date_invoice).compute(
|
||||
inv_line.price_subtotal,
|
||||
self.company_id.currency_id)
|
||||
return amount
|
||||
|
||||
def _get_region(self, inv_line):
|
||||
"""
|
||||
For supplier invoices/refunds: if the invoice line is linked
|
||||
to a stock move, use the destination stock location ;
|
||||
otherwise, get the PO (which is linked to a stock location)
|
||||
and then get the warehouse.
|
||||
It is important to take into account the following scenario:
|
||||
I order a qty of 50 kg and my suppliers delivers and invoices 52 kg
|
||||
(quite common in some industries where the order qty cannot be exact
|
||||
due to some operational constraints) ; in this case, I have a qty of
|
||||
2 kg which is not linked to a PO, but it is linked to a stock move.
|
||||
|
||||
For customer invoices/refunds: if the invoice line is linked to a
|
||||
stock move, use the source stock location ;
|
||||
otherwise, get the sale order, which is linked to the warehouse.
|
||||
|
||||
If none found, get the company's default intrastat region.
|
||||
|
||||
"""
|
||||
region = False
|
||||
inv_type = inv_line.invoice_id.type
|
||||
if inv_line.move_line_ids:
|
||||
if inv_type in ('in_invoice', 'out_refund'):
|
||||
region = inv_line.move_line_ids[0].location_id.\
|
||||
get_intrastat_region()
|
||||
else:
|
||||
region = inv_line.move_line_ids[0].location_dest_id.\
|
||||
get_intrastat_region()
|
||||
elif inv_type in ('in_invoice', 'in_refund'):
|
||||
po_lines = self.env['purchase.order.line'].search(
|
||||
[('invoice_lines', 'in', inv_line.id)])
|
||||
if po_lines:
|
||||
po = po_lines.order_id
|
||||
region = po.location_id.get_intrastat_region()
|
||||
elif inv_line.invoice_id.type in ('out_invoice', 'out_refund'):
|
||||
so_lines = self.env['sale.order.line'].search(
|
||||
[('invoice_lines', 'in', inv_line.id)])
|
||||
if so_lines:
|
||||
so = so_lines.order_id
|
||||
region = so.warehouse_id.region_id
|
||||
if not region:
|
||||
if self.company_id.intrastat_region_id:
|
||||
region = self.company_id.intrastat_region_id
|
||||
return region
|
||||
|
||||
def _get_transport(self, inv_line):
|
||||
transport = inv_line.invoice_id.intrastat_transport_id \
|
||||
or self.company_id.intrastat_transport_id
|
||||
if not transport:
|
||||
msg = _(
|
||||
"The default Intrastat Transport Mode "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
return transport
|
||||
|
||||
def _get_incoterm(self, inv_line):
|
||||
incoterm = inv_line.invoice_id.incoterm_id \
|
||||
or self.company_id.intrastat_incoterm_id
|
||||
if not incoterm:
|
||||
msg = _(
|
||||
"The default Incoterm "
|
||||
"of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
return incoterm
|
||||
|
||||
def _get_product_origin_country(self, inv_line):
|
||||
return inv_line.product_id.origin_country_id
|
||||
|
||||
def _update_computation_line_vals(self, inv_line, line_vals):
|
||||
""" placeholder for localization modules """
|
||||
pass
|
||||
|
||||
def _handle_invoice_accessory_cost(
|
||||
self, invoice, lines_current_invoice,
|
||||
total_inv_accessory_costs_cc, total_inv_product_cc,
|
||||
total_inv_weight):
|
||||
"""
|
||||
Affect accessory costs pro-rata of the value
|
||||
(or pro-rata of the weight if the goods of the invoice
|
||||
have no value)
|
||||
|
||||
This method allows to implement a different logic
|
||||
in the localization modules.
|
||||
E.g. in Belgium accessory cost should not be added.
|
||||
"""
|
||||
if total_inv_accessory_costs_cc:
|
||||
if total_inv_product_cc:
|
||||
# pro-rata of the value
|
||||
for ac_line_vals in lines_current_invoice:
|
||||
ac_line_vals['amount_accessory_cost_company_currency'] = (
|
||||
total_inv_accessory_costs_cc *
|
||||
ac_line_vals['amount_company_currency'] /
|
||||
total_inv_product_cc)
|
||||
else:
|
||||
# pro-rata of the weight
|
||||
for ac_line_vals in lines_current_invoice:
|
||||
ac_line_vals['amount_accessory_cost_company_currency'] = (
|
||||
total_inv_accessory_costs_cc *
|
||||
ac_line_vals['weight'] /
|
||||
total_inv_weight)
|
||||
|
||||
def _prepare_invoice_domain(self):
|
||||
"""
|
||||
Complete this method in the localization module
|
||||
with the country-specific logic for arrivals and dispatches.
|
||||
Cf. l10n_be_intrastat_product_declaration for an example
|
||||
"""
|
||||
start_date = date(self.year, self.month, 1)
|
||||
end_date = start_date + relativedelta(day=1, months=+1, days=-1)
|
||||
domain = [
|
||||
('date_invoice', '>=', start_date),
|
||||
('date_invoice', '<=', end_date),
|
||||
('state', 'in', ['open', 'paid']),
|
||||
('intrastat_country', '=', True),
|
||||
('company_id', '=', self.company_id.id)]
|
||||
return domain
|
||||
|
||||
def _is_product(self, invoice_line):
|
||||
if (
|
||||
invoice_line.product_id and
|
||||
invoice_line.product_id.type in ('product', 'consu')):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def _gather_invoices_init(self):
|
||||
""" placeholder for localization modules """
|
||||
pass
|
||||
|
||||
def _gather_invoices(self):
|
||||
|
||||
lines = []
|
||||
accessory_costs = self.company_id.intrastat_accessory_costs
|
||||
|
||||
self._gather_invoices_init()
|
||||
domain = self._prepare_invoice_domain()
|
||||
invoices = self.env['account.invoice'].search(domain)
|
||||
|
||||
for invoice in invoices:
|
||||
|
||||
lines_current_invoice = []
|
||||
total_inv_accessory_costs_cc = 0.0 # in company currency
|
||||
total_inv_product_cc = 0.0 # in company currency
|
||||
total_inv_weight = 0.0
|
||||
for inv_line in invoice.invoice_line:
|
||||
|
||||
if (
|
||||
accessory_costs and
|
||||
inv_line.product_id and
|
||||
inv_line.product_id.is_accessory_cost):
|
||||
acost = invoice.currency_id.with_context(
|
||||
date=invoice.date_invoice).compute(
|
||||
inv_line.price_subtotal,
|
||||
self.company_id.currency_id)
|
||||
total_inv_accessory_costs_cc += acost
|
||||
|
||||
continue
|
||||
|
||||
if not inv_line.quantity:
|
||||
_logger.info(
|
||||
'Skipping invoice line %s qty %s '
|
||||
'of invoice %s. Reason: qty = 0'
|
||||
% (inv_line.name, inv_line.quantity, invoice.number))
|
||||
continue
|
||||
|
||||
partner_country = self._get_partner_country(inv_line)
|
||||
if not partner_country:
|
||||
_logger.info(
|
||||
'Skipping invoice line %s qty %s '
|
||||
'of invoice %s. Reason: no partner_country'
|
||||
% (inv_line.name, inv_line.quantity, invoice.number))
|
||||
continue
|
||||
|
||||
if any([
|
||||
tax.exclude_from_intrastat_if_present
|
||||
for tax in inv_line.invoice_line_tax_id]):
|
||||
_logger.info(
|
||||
'Skipping invoice line %s '
|
||||
'qty %s of invoice %s. Reason: '
|
||||
'tax.exclude_from_intrastat_if_present'
|
||||
% (inv_line.name, inv_line.quantity, invoice.number))
|
||||
continue
|
||||
|
||||
if inv_line.hs_code_id:
|
||||
hs_code = inv_line.hs_code_id
|
||||
elif inv_line.product_id and self._is_product(inv_line):
|
||||
hs_code = inv_line.product_id.product_tmpl_id.\
|
||||
get_hs_code_recursively()
|
||||
if not hs_code:
|
||||
note = "\n" + _(
|
||||
"Missing H.S. code on product %s. "
|
||||
"This product is present in invoice %s.") % (
|
||||
inv_line.product_id.name_get()[0][1],
|
||||
inv_line.invoice_id.number)
|
||||
self._note += note
|
||||
continue
|
||||
else:
|
||||
_logger.info(
|
||||
'Skipping invoice line %s qty %s'
|
||||
'of invoice %s. Reason: no product nor hs_code'
|
||||
% (inv_line.name, inv_line.quantity, invoice.number))
|
||||
continue
|
||||
|
||||
intrastat_transaction = \
|
||||
self._get_intrastat_transaction(inv_line)
|
||||
|
||||
weight, suppl_unit_qty = self._get_weight_and_supplunits(
|
||||
inv_line, hs_code)
|
||||
total_inv_weight += weight
|
||||
|
||||
amount_company_currency = self._get_amount(inv_line)
|
||||
total_inv_product_cc += amount_company_currency
|
||||
|
||||
product_origin_country = self._get_product_origin_country(
|
||||
inv_line)
|
||||
|
||||
region = self._get_region(inv_line)
|
||||
|
||||
line_vals = {
|
||||
'parent_id': self.id,
|
||||
'invoice_line_id': inv_line.id,
|
||||
'src_dest_country_id': partner_country.id,
|
||||
'product_id': inv_line.product_id.id,
|
||||
'hs_code_id': hs_code.id,
|
||||
'weight': weight,
|
||||
'suppl_unit_qty': suppl_unit_qty,
|
||||
'amount_company_currency': amount_company_currency,
|
||||
'amount_accessory_cost_company_currency': 0.0,
|
||||
'transaction_id': intrastat_transaction.id,
|
||||
'product_origin_country_id':
|
||||
product_origin_country.id or False,
|
||||
'region_id': region and region.id or False,
|
||||
}
|
||||
|
||||
# extended declaration
|
||||
if self._extended:
|
||||
transport = self._get_transport(inv_line)
|
||||
line_vals.update({
|
||||
'transport_id': transport.id,
|
||||
})
|
||||
|
||||
self._update_computation_line_vals(inv_line, line_vals)
|
||||
|
||||
if line_vals:
|
||||
lines_current_invoice.append((line_vals))
|
||||
|
||||
self._handle_invoice_accessory_cost(
|
||||
invoice, lines_current_invoice,
|
||||
total_inv_accessory_costs_cc, total_inv_product_cc,
|
||||
total_inv_weight)
|
||||
|
||||
for line_vals in lines_current_invoice:
|
||||
if (
|
||||
not line_vals['amount_company_currency'] and
|
||||
not
|
||||
line_vals['amount_accessory_cost_company_currency']):
|
||||
inv_line = self.env['account.invoice.line'].browse(
|
||||
line_vals['invoice_line_id'])
|
||||
_logger.info(
|
||||
'Skipping invoice line %s qty %s '
|
||||
'of invoice %s. Reason: price_subtotal = 0 '
|
||||
'and accessory costs = 0'
|
||||
% (inv_line.name, inv_line.quantity,
|
||||
inv_line.invoice_id.number))
|
||||
continue
|
||||
lines.append(line_vals)
|
||||
|
||||
return lines
|
||||
|
||||
def _get_uom_refs(self, ref):
|
||||
uom_refs = {
|
||||
'weight_uom_categ': self.env.ref('product.product_uom_categ_kgm'),
|
||||
'kg_uom': self.env.ref('product.product_uom_kgm'),
|
||||
'pce_uom_categ': self.env.ref('product.product_uom_categ_unit'),
|
||||
'pce_uom': self.env.ref('product.product_uom_unit')
|
||||
}
|
||||
return uom_refs[ref]
|
||||
|
||||
@api.multi
|
||||
def action_gather(self):
|
||||
self.ensure_one()
|
||||
self.message_post(_("Generate Lines from Invoices"))
|
||||
self._check_generate_lines()
|
||||
self._note = ''
|
||||
if (
|
||||
self.type == 'arrivals' and
|
||||
self.company_id.intrastat_arrivals == 'extended') or (
|
||||
self.type == 'dispatches' and
|
||||
self.company_id.intrastat_dispatches == 'extended'):
|
||||
self._extended = True
|
||||
else:
|
||||
self._extended = False
|
||||
|
||||
self.computation_line_ids.unlink()
|
||||
self.declaration_line_ids.unlink()
|
||||
lines = self._gather_invoices()
|
||||
|
||||
if not lines:
|
||||
self.action = 'nihil'
|
||||
note = "\n" + \
|
||||
_("No records found for the selected period !") + '\n' + \
|
||||
_("The Declaration Action has been set to 'nihil'.")
|
||||
self._note += note
|
||||
else:
|
||||
self.write({'computation_line_ids': [(0, 0, x) for x in lines]})
|
||||
|
||||
if self._note:
|
||||
note_header = '\n\n>>> ' + fields.Datetime.to_string(
|
||||
fields.Datetime.context_timestamp(self, datetime.now())) + '\n'
|
||||
self.note = note_header + self._note + (self.note or '')
|
||||
result_view = self.env.ref(
|
||||
'intrastat_base.intrastat_result_view_form')
|
||||
return {
|
||||
'name': _("Generate lines from invoices: results"),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'intrastat.result.view',
|
||||
'view_id': result_view.id,
|
||||
'target': 'new',
|
||||
'context': dict(self._context, note=self._note),
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def _group_line_hashcode_fields(self, computation_line):
|
||||
return {
|
||||
'country': computation_line.src_dest_country_id.id or False,
|
||||
'hs_code_id': computation_line.hs_code_id.id or False,
|
||||
'intrastat_unit': computation_line.intrastat_unit_id.id or False,
|
||||
'transaction': computation_line.transaction_id.id or False,
|
||||
'transport': computation_line.transport_id.id or False,
|
||||
'region': computation_line.region_id.id or False,
|
||||
'product_origin_country':
|
||||
computation_line.product_origin_country_id.id or False,
|
||||
}
|
||||
|
||||
def group_line_hashcode(self, computation_line):
|
||||
hc_fields = self._group_line_hashcode_fields(computation_line)
|
||||
hashcode = '-'.join([unicode(f) for f in hc_fields.itervalues()])
|
||||
return hashcode
|
||||
|
||||
@api.multi
|
||||
def generate_declaration(self):
|
||||
""" generate declaration lines """
|
||||
self.ensure_one()
|
||||
assert self.valid, 'Computation lines are not valid'
|
||||
self.message_post(_("Generate Declaration Lines"))
|
||||
# Delete existing declaration lines
|
||||
self.declaration_line_ids.unlink()
|
||||
# Regenerate declaration lines from computation lines
|
||||
dl_group = {}
|
||||
for cl in self.computation_line_ids:
|
||||
hashcode = self.group_line_hashcode(cl)
|
||||
if hashcode in dl_group:
|
||||
dl_group[hashcode].append(cl)
|
||||
else:
|
||||
dl_group[hashcode] = [cl]
|
||||
ipdl = self.declaration_line_ids
|
||||
for cl_lines in dl_group.values():
|
||||
vals = ipdl._prepare_declaration_line(cl_lines)
|
||||
declaration_line = ipdl.create(vals)
|
||||
for cl in cl_lines:
|
||||
cl.write({'declaration_line_id': declaration_line.id})
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def generate_xml(self):
|
||||
""" generate the INTRASTAT Declaration XML file """
|
||||
self.ensure_one()
|
||||
self.message_post(_("Generate XML Declaration File"))
|
||||
self._check_generate_xml()
|
||||
self._unlink_attachments()
|
||||
xml_string = self._generate_xml()
|
||||
if xml_string:
|
||||
attach_id = self._attach_xml_file(
|
||||
xml_string, '%s_%s' % (self.type, self.revision))
|
||||
return self._open_attach_view(attach_id)
|
||||
else:
|
||||
raise UserError(
|
||||
_("No XML File has been generated."))
|
||||
|
||||
@api.multi
|
||||
def done(self):
|
||||
self.write({'state': 'done'})
|
||||
|
||||
@api.multi
|
||||
def back2draft(self):
|
||||
self.write({'state': 'draft'})
|
||||
|
||||
|
||||
class IntrastatProductComputationLine(models.Model):
|
||||
_name = 'intrastat.product.computation.line'
|
||||
_description = "Intrastat Product Computataion Lines"
|
||||
|
||||
parent_id = fields.Many2one(
|
||||
'intrastat.product.declaration',
|
||||
string='Intrastat Product Declaration',
|
||||
ondelete='cascade', readonly=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', related='parent_id.company_id',
|
||||
string="Company", readonly=True)
|
||||
company_currency_id = fields.Many2one(
|
||||
'res.currency', related='company_id.currency_id',
|
||||
string="Company currency", readonly=True)
|
||||
type = fields.Selection(
|
||||
related='parent_id.type',
|
||||
string='Type',
|
||||
readonly=True)
|
||||
reporting_level = fields.Selection(
|
||||
related='parent_id.reporting_level',
|
||||
string='Reporting Level',
|
||||
readonly=True)
|
||||
valid = fields.Boolean(
|
||||
compute='_check_validity',
|
||||
string='Valid')
|
||||
invoice_line_id = fields.Many2one(
|
||||
'account.invoice.line', string='Invoice Line', readonly=True)
|
||||
invoice_id = fields.Many2one(
|
||||
'account.invoice', related='invoice_line_id.invoice_id',
|
||||
string='Invoice', readonly=True)
|
||||
declaration_line_id = fields.Many2one(
|
||||
'intrastat.product.declaration.line',
|
||||
string='Declaration Line', readonly=True)
|
||||
src_dest_country_id = fields.Many2one(
|
||||
'res.country', string='Country',
|
||||
help="Country of Origin/Destination",
|
||||
domain=[('intrastat', '=', True)])
|
||||
product_id = fields.Many2one(
|
||||
'product.product', related='invoice_line_id.product_id',
|
||||
string='Product', readonly=True)
|
||||
hs_code_id = fields.Many2one(
|
||||
'hs.code', string='Intrastat Code')
|
||||
intrastat_unit_id = fields.Many2one(
|
||||
'intrastat.unit', related='hs_code_id.intrastat_unit_id',
|
||||
string='Suppl. Unit', readonly=True,
|
||||
help="Intrastat Supplementary Unit")
|
||||
weight = fields.Float(
|
||||
string='Weight',
|
||||
digits=dp.get_precision('Stock Weight'), help="Net weight in Kg")
|
||||
suppl_unit_qty = fields.Float(
|
||||
string='Suppl. Unit Qty',
|
||||
digits=dp.get_precision('Product Unit of Measure'),
|
||||
help="Supplementary Units Quantity")
|
||||
amount_company_currency = fields.Float(
|
||||
string='Fiscal Value',
|
||||
digits=dp.get_precision('Account'), required=True,
|
||||
help="Amount in company currency to write in the declaration. "
|
||||
"Amount in company currency = amount in invoice currency "
|
||||
"converted to company currency with the rate of the invoice date.")
|
||||
amount_accessory_cost_company_currency = fields.Float(
|
||||
string='Accessory Costs',
|
||||
digits=dp.get_precision('Account'),
|
||||
help="Amount in company currency of the accessory costs related to "
|
||||
"this invoice line (by default, these accessory costs are computed "
|
||||
"at the pro-rata of the amount of each invoice line.")
|
||||
transaction_id = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Intrastat Transaction')
|
||||
region_id = fields.Many2one(
|
||||
'intrastat.region', string='Intrastat Region')
|
||||
# extended declaration
|
||||
incoterm_id = fields.Many2one(
|
||||
'stock.incoterms', string='Incoterm')
|
||||
transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode',
|
||||
string='Transport Mode')
|
||||
product_origin_country_id = fields.Many2one(
|
||||
'res.country', string='Country of Origin of the Product',
|
||||
help="Country of origin of the product i.e. product 'made in ____'")
|
||||
|
||||
@api.multi
|
||||
@api.depends('transport_id')
|
||||
def _check_validity(self):
|
||||
""" TO DO: logic based upon fields """
|
||||
for this in self:
|
||||
this.valid = True
|
||||
|
||||
@api.onchange('product_id')
|
||||
def _onchange_product(self):
|
||||
self.weight = 0.0
|
||||
self.suppl_unit_qty = 0.0
|
||||
self.intrastat_code_id = False
|
||||
self.intrastat_unit_id = False
|
||||
if self.product_id:
|
||||
self.intrastat_code_id = self.product_id.intrastat_id
|
||||
self.intrastat_unit_id =\
|
||||
self.product_id.intrastat_id.intrastat_unit_id
|
||||
if not self.intrastat_unit_id:
|
||||
self.weight = self.product_id.weight_net
|
||||
|
||||
|
||||
class IntrastatProductDeclarationLine(models.Model):
|
||||
_name = 'intrastat.product.declaration.line'
|
||||
_description = "Intrastat Product Declaration Lines"
|
||||
|
||||
parent_id = fields.Many2one(
|
||||
'intrastat.product.declaration',
|
||||
string='Intrastat Product Declaration',
|
||||
ondelete='cascade', readonly=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', related='parent_id.company_id',
|
||||
string="Company", readonly=True)
|
||||
company_currency_id = fields.Many2one(
|
||||
'res.currency', related='company_id.currency_id',
|
||||
string="Company currency", readonly=True)
|
||||
type = fields.Selection(
|
||||
related='parent_id.type',
|
||||
string='Type',
|
||||
readonly=True)
|
||||
reporting_level = fields.Selection(
|
||||
related='parent_id.reporting_level',
|
||||
string='Reporting Level',
|
||||
readonly=True)
|
||||
computation_line_ids = fields.One2many(
|
||||
'intrastat.product.computation.line', 'declaration_line_id',
|
||||
string='Computation Lines', readonly=True)
|
||||
src_dest_country_id = fields.Many2one(
|
||||
'res.country', string='Country',
|
||||
help="Country of Origin/Destination",
|
||||
domain=[('intrastat', '=', True)])
|
||||
hs_code_id = fields.Many2one(
|
||||
'hs.code',
|
||||
string='Intrastat Code')
|
||||
intrastat_unit_id = fields.Many2one(
|
||||
'intrastat.unit', related='hs_code_id.intrastat_unit_id',
|
||||
string='Suppl. Unit', readonly=True,
|
||||
help="Intrastat Supplementary Unit")
|
||||
weight = fields.Integer(
|
||||
string='Weight', help="Net weight in Kg")
|
||||
suppl_unit_qty = fields.Integer(
|
||||
string='Suppl. Unit Qty',
|
||||
help="Supplementary Units Quantity")
|
||||
amount_company_currency = fields.Integer(
|
||||
string='Fiscal Value',
|
||||
help="Amount in company currency to write in the declaration. "
|
||||
"Amount in company currency = amount in invoice currency "
|
||||
"converted to company currency with the rate of the invoice date.")
|
||||
transaction_id = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Intrastat Transaction')
|
||||
region_id = fields.Many2one(
|
||||
'intrastat.region', string='Intrastat Region')
|
||||
# extended declaration
|
||||
incoterm_id = fields.Many2one(
|
||||
'stock.incoterms', string='Incoterm')
|
||||
transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode',
|
||||
string='Transport Mode')
|
||||
product_origin_country_id = fields.Many2one(
|
||||
'res.country', string='Country of Origin of the Product',
|
||||
help="Country of origin of the product i.e. product 'made in ____'")
|
||||
|
||||
@api.model
|
||||
def _prepare_grouped_fields(self, computation_line, fields_to_sum):
|
||||
vals = {
|
||||
'src_dest_country_id': computation_line.src_dest_country_id.id,
|
||||
'intrastat_unit_id': computation_line.intrastat_unit_id.id,
|
||||
'hs_code_id': computation_line.hs_code_id.id,
|
||||
'transaction_id': computation_line.transaction_id.id,
|
||||
'transport_id': computation_line.transport_id.id,
|
||||
'region_id': computation_line.region_id.id,
|
||||
'parent_id': computation_line.parent_id.id,
|
||||
'product_origin_country_id':
|
||||
computation_line.product_origin_country_id.id,
|
||||
'amount_company_currency': 0.0,
|
||||
}
|
||||
for field in fields_to_sum:
|
||||
vals[field] = 0.0
|
||||
return vals
|
||||
|
||||
def _fields_to_sum(self):
|
||||
fields_to_sum = [
|
||||
'weight',
|
||||
'suppl_unit_qty',
|
||||
]
|
||||
return fields_to_sum
|
||||
|
||||
@api.model
|
||||
def _prepare_declaration_line(self, computation_lines):
|
||||
fields_to_sum = self._fields_to_sum()
|
||||
vals = self._prepare_grouped_fields(
|
||||
computation_lines[0], fields_to_sum)
|
||||
for computation_line in computation_lines:
|
||||
for field in fields_to_sum:
|
||||
vals[field] += computation_line[field]
|
||||
vals['amount_company_currency'] += (
|
||||
computation_line['amount_company_currency'] +
|
||||
computation_line['amount_accessory_cost_company_currency'])
|
||||
# round, otherwise odoo with truncate (6.7 -> 6... instead of 7 !)
|
||||
for field in fields_to_sum:
|
||||
vals[field] = int(round(vals[field]))
|
||||
if not vals['weight']:
|
||||
vals['weight'] = 1
|
||||
vals['amount_company_currency'] = int(round(
|
||||
vals['amount_company_currency']))
|
||||
return vals
|
||||
43
intrastat_product/models/intrastat_region.py
Normal file
43
intrastat_product/models/intrastat_region.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Odoo, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2009-2015 Noviat nv/sa (www.noviat.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
|
||||
|
||||
|
||||
class IntrastatRegion(models.Model):
|
||||
_name = 'intrastat.region'
|
||||
_description = "Intrastat Region"
|
||||
|
||||
code = fields.Char(string='Code', required=True)
|
||||
country_id = fields.Many2one(
|
||||
'res.country', string='Country', required=True)
|
||||
name = fields.Char(string='Name', translate=True)
|
||||
description = fields.Char(string='Description')
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'intrastat.region'))
|
||||
|
||||
_sql_constraints = [
|
||||
('intrastat_region_code_unique',
|
||||
'UNIQUE(code, country_id)',
|
||||
'Code must be unique.')]
|
||||
58
intrastat_product/models/intrastat_transaction.py
Normal file
58
intrastat_product/models/intrastat_transaction.py
Normal file
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class IntrastatTransaction(models.Model):
|
||||
_name = 'intrastat.transaction'
|
||||
_description = "Intrastat Transaction"
|
||||
_order = 'code'
|
||||
_rec_name = 'display_name'
|
||||
|
||||
code = fields.Char(string='Code', required=True)
|
||||
description = fields.Text(string='Description')
|
||||
display_name = fields.Char(
|
||||
compute='_compute_display_name', string="Display Name", readonly=True,
|
||||
store=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'intrastat.transaction'))
|
||||
|
||||
@api.multi
|
||||
@api.depends('code', 'description')
|
||||
def _compute_display_name(self):
|
||||
for this in self:
|
||||
display_name = this.code
|
||||
if this.description:
|
||||
display_name += ' ' + this.description
|
||||
this.display_name = len(display_name) > 55 \
|
||||
and display_name[:55] + '...' \
|
||||
or display_name
|
||||
|
||||
_sql_constraints = [(
|
||||
'intrastat_transaction_code_unique',
|
||||
'UNIQUE(code, company_id)',
|
||||
'Code must be unique.')]
|
||||
50
intrastat_product/models/intrastat_transport_mode.py
Normal file
50
intrastat_product/models/intrastat_transport_mode.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class IntrastatTransportMode(models.Model):
|
||||
_name = 'intrastat.transport_mode'
|
||||
_description = "Intrastat Transport Mode"
|
||||
_rec_name = 'display_name'
|
||||
_order = 'code'
|
||||
|
||||
display_name = fields.Char(
|
||||
string='Display Name', compute='_display_name', store=True,
|
||||
readonly=True)
|
||||
code = fields.Char(string='Code', required=True)
|
||||
name = fields.Char(string='Name', required=True, translate=True)
|
||||
description = fields.Char(string='Description', translate=True)
|
||||
|
||||
@api.multi
|
||||
@api.depends('name', 'code')
|
||||
def _display_name(self):
|
||||
for this in self:
|
||||
this.display_name = '%s. %s' % (this.code, this.name)
|
||||
|
||||
_sql_constraints = [(
|
||||
'intrastat_transport_code_unique',
|
||||
'UNIQUE(code)',
|
||||
'Code must be unique.')]
|
||||
41
intrastat_product/models/intrastat_unit.py
Normal file
41
intrastat_product/models/intrastat_unit.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class IntrastatUnit(models.Model):
|
||||
_name = 'intrastat.unit'
|
||||
_description = 'Intrastat Supplementary Units'
|
||||
|
||||
name = fields.Char(
|
||||
string='Name', required=True)
|
||||
description = fields.Char(
|
||||
string='Description', required=True)
|
||||
uom_id = fields.Many2one(
|
||||
'product.uom', string='Regular UoM',
|
||||
help="Select the regular Unit of Measure of Odoo that corresponds "
|
||||
"to this Intrastat Supplementary Unit.")
|
||||
active = fields.Boolean(
|
||||
string='Active', default=True)
|
||||
92
intrastat_product/models/res_company.py
Normal file
92
intrastat_product/models/res_company.py
Normal file
@@ -0,0 +1,92 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
intrastat_incoterm_id = fields.Many2one(
|
||||
'stock.incoterms',
|
||||
string='Default Incoterm for Intrastat',
|
||||
help="International Commercial Terms are a series of "
|
||||
"predefined commercial terms used in international "
|
||||
"transactions.")
|
||||
intrastat_arrivals = fields.Selection(
|
||||
'_intrastat_arrivals', string='Arrivals',
|
||||
default='extended', required=True)
|
||||
intrastat_dispatches = fields.Selection(
|
||||
'_intrastat_arrivals', string='Dispatches',
|
||||
default='extended', required=True)
|
||||
intrastat_transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode',
|
||||
string='Default Transport Mode', ondelete='restrict')
|
||||
intrastat = fields.Char(
|
||||
string='Intrastat Declaration', store=True, readonly=True,
|
||||
compute='_compute_intrastat')
|
||||
intrastat_region_id = fields.Many2one(
|
||||
'intrastat.region',
|
||||
string='Default Intrastat Region')
|
||||
intrastat_transaction_out_invoice = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Default Intrastat Transaction For Customer Invoice')
|
||||
intrastat_transaction_out_refund = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Default Intrastat Transaction for Customer Refunds')
|
||||
intrastat_transaction_in_invoice = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Default Intrastat Transaction For Supplier Invoices')
|
||||
intrastat_transaction_in_refund = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Default Intrastat Transaction For Supplier Refunds')
|
||||
intrastat_accessory_costs = fields.Boolean(
|
||||
string='Include Accessory Costs in Fiscal Value of Product')
|
||||
|
||||
@api.model
|
||||
def _intrastat_arrivals(self):
|
||||
return [
|
||||
('exempt', 'Exempt'),
|
||||
('standard', 'Standard'),
|
||||
('extended', 'Extended')]
|
||||
|
||||
@api.model
|
||||
def _intrastat_dispatches(self):
|
||||
return [
|
||||
('exempt', 'Exempt'),
|
||||
('standard', 'Standard'),
|
||||
('extended', 'Extended')]
|
||||
|
||||
@api.multi
|
||||
@api.depends('intrastat_arrivals', 'intrastat_dispatches')
|
||||
def _compute_intrastat(self):
|
||||
for this in self:
|
||||
if this.intrastat_arrivals == 'exempt' \
|
||||
and this.intrastat_dispatches == 'exempt':
|
||||
this.intrastat = 'exempt'
|
||||
elif this.intrastat_arrivals == 'extended' \
|
||||
or this.intrastat_dispatches == 'extended':
|
||||
this.intrastat = 'extended'
|
||||
else:
|
||||
this.intrastat = 'standard'
|
||||
37
intrastat_product/models/sale_order.py
Normal file
37
intrastat_product/models/sale_order.py
Normal file
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2010-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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, api
|
||||
|
||||
|
||||
class SaleOrder(models.Model):
|
||||
_inherit = "sale.order"
|
||||
|
||||
@api.model
|
||||
def _prepare_invoice(self, order, lines):
|
||||
'''Copy destination country to invoice'''
|
||||
invoice_vals = super(SaleOrder, self)._prepare_invoice(
|
||||
order, lines)
|
||||
invoice_vals['src_dest_country_id'] = \
|
||||
order.partner_shipping_id.country_id.id or False
|
||||
invoice_vals['incoterm_id'] = order.incoterm.id or False
|
||||
return invoice_vals
|
||||
46
intrastat_product/models/stock_picking.py
Normal file
46
intrastat_product/models/stock_picking.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.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
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
_inherit = "stock.picking"
|
||||
|
||||
intrastat_transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode', string='Transport Mode',
|
||||
help="This information is used in Intrastat reports")
|
||||
intrastat = fields.Char(related='company_id.intrastat')
|
||||
|
||||
@api.model
|
||||
def _create_invoice_from_picking(self, picking, vals):
|
||||
""" Copy data from picking to invoice. """
|
||||
vals['intrastat_transport_id'] = picking.intrastat_transport_id.id
|
||||
if picking.partner_id and picking.partner_id.country_id:
|
||||
vals['src_dest_country_id'] = picking.partner_id.country_id.id
|
||||
region = picking.location_id.get_intrastat_region()
|
||||
if region:
|
||||
vals['src_dest_region_id'] = region.id
|
||||
return super(StockPicking, self)._create_invoice_from_picking(
|
||||
picking, vals)
|
||||
48
intrastat_product/models/stock_warehouse.py
Normal file
48
intrastat_product/models/stock_warehouse.py
Normal file
@@ -0,0 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Odoo, Open Source Management Solution
|
||||
#
|
||||
# Copyright (c) 2009-2015 Noviat nv/sa (www.noviat.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
|
||||
|
||||
|
||||
class StockWarehouse(models.Model):
|
||||
_inherit = 'stock.warehouse'
|
||||
|
||||
region_id = fields.Many2one(
|
||||
'intrastat.region',
|
||||
string='Intrastat region')
|
||||
|
||||
|
||||
class StockLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
|
||||
@api.multi
|
||||
def get_intrastat_region(self):
|
||||
self.ensure_one()
|
||||
locations = self.search(
|
||||
[('parent_left', '<=', self.parent_left),
|
||||
('parent_right', '>=', self.parent_right)])
|
||||
warehouses = self.env['stock.warehouse'].search([
|
||||
('lot_stock_id', 'in', [x.id for x in locations]),
|
||||
('region_id', '!=', False)])
|
||||
if warehouses:
|
||||
return warehouses[0].region_id
|
||||
return None
|
||||
18
intrastat_product/security/intrastat_security.xml
Normal file
18
intrastat_product/security/intrastat_security.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="intrastat_transaction_company_rule" model="ir.rule">
|
||||
<field name="name">Intrastat Transaction Company rule</field>
|
||||
<field name="model_id" ref="model_intrastat_transaction"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_region_company_rule" model="ir.rule">
|
||||
<field name="name">Intrastat Region Company rule</field>
|
||||
<field name="model_id" ref="model_intrastat_region"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
13
intrastat_product/security/ir.model.access.csv
Normal file
13
intrastat_product/security/ir.model.access.csv
Normal file
@@ -0,0 +1,13 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_intrastat_unit_read,Read access on Intrastat Supplementary Units to everybody,model_intrastat_unit,,1,0,0,0
|
||||
access_intrastat_unit_full,Full access on Intrastat Supplementary Units to Finance manager,model_intrastat_unit,account.group_account_manager,1,1,1,1
|
||||
access_intrastat_transaction_read,Read access on Intrastat Transaction Types to everybody,model_intrastat_transaction,,1,0,0,0
|
||||
access_intrastat_transaction_full,Full access on Intrastat Transaction Types to Finance manager,model_intrastat_transaction,account.group_account_manager,1,1,1,1
|
||||
access_intrastat_transport_mode_read,Read access on Intrastat Transport Modes to everybody,model_intrastat_transport_mode,,1,0,0,0
|
||||
access_intrastat_transport_mode_full,Full access on Intrastat Transport Modes to Finance manager,model_intrastat_transport_mode,account.group_account_manager,1,1,1,1
|
||||
access_intrastat_region_read,Read access on Intrastat Regions,model_intrastat_region,,1,0,0,0
|
||||
access_intrastat_region_full,Full access on Intrastat Regions,model_intrastat_region,account.group_account_manager,1,1,1,1
|
||||
access_hs_code_financial_mgr_full,Full access on H.S. Code to financial mgr,product_harmonized_system.model_hs_code,account.group_account_manager,1,1,1,1
|
||||
access_intrastat_product_declaration,Full access on Intrastat Product Declarations to Accountant,model_intrastat_product_declaration,account.group_account_user,1,1,1,1
|
||||
access_intrastat_product_computation_line,Full access on Intrastat Product Computation Lines to Accountant,model_intrastat_product_computation_line,account.group_account_user,1,1,1,1
|
||||
access_intrastat_product_declaration_line,Full access on Intrastat Product Declaration Lines to Accountant,model_intrastat_product_declaration_line,account.group_account_user,1,1,1,1
|
||||
|
54
intrastat_product/views/account_invoice.xml
Normal file
54
intrastat_product/views/account_invoice.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="invoice_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.invoice.form</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='date_due']" position="after">
|
||||
<field name="incoterm_id"
|
||||
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='move_id']" position="after">
|
||||
<field name="intrastat_transaction_id"/>
|
||||
<field name="intrastat" invisible="1"/>
|
||||
<field name="intrastat_transport_id"
|
||||
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"
|
||||
widget="selection"/>
|
||||
<field name="src_dest_country_id" string="Destination Country"/>
|
||||
<field name="src_dest_region_id" string="Origin Region" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='invoice_line']//field[@name='account_id']" position="after">
|
||||
<field name="hs_code_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="invoice_supplier_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.invoice.supplier.form</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_supplier_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='payment_term']" position="after">
|
||||
<field name="incoterm_id"
|
||||
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='period_id']" position="after">
|
||||
<field name="intrastat_transaction_id"/>
|
||||
<field name="intrastat" invisible="1"/>
|
||||
<field name="intrastat_transport_id"
|
||||
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"
|
||||
widget="selection"/>
|
||||
<field name="src_dest_country_id" string="Origin/Destination Country"/>
|
||||
<field name="src_dest_region_id" string="Origin/Destination Region" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='invoice_line']//field[@name='account_id']" position="after">
|
||||
<field name="hs_code_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
45
intrastat_product/views/hs_code.xml
Normal file
45
intrastat_product/views/hs_code.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2015 Noviat (http://www.noviat.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
@author Luc De Meyer <luc.demeyer@noviat.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Add the H.S. code menu under the Intrastat Config menu -->
|
||||
<menuitem id="intrastat_code_menu"
|
||||
action="product_harmonized_system.hs_code_action"
|
||||
parent="intrastat_base.menu_intrastat_config_root"
|
||||
sequence="10"/>
|
||||
|
||||
<!-- Inherit tree view of H.S. code -->
|
||||
<record id="hs_code_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.hs.code.tree</field>
|
||||
<field name="model">hs.code</field>
|
||||
<field name="inherit_id" ref="product_harmonized_system.hs_code_view_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="local_code" position="after">
|
||||
<field name="intrastat_unit_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Inherit form view for H.S. code -->
|
||||
<record id="hs_code_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.hs.code.form</field>
|
||||
<field name="model">hs.code</field>
|
||||
<field name="inherit_id" ref="product_harmonized_system.hs_code_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="local_code" position="after">
|
||||
<field name="intrastat_unit_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
263
intrastat_product/views/intrastat_product_declaration.xml
Normal file
263
intrastat_product/views/intrastat_product_declaration.xml
Normal file
@@ -0,0 +1,263 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="intrastat_product_declaration_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.form</field>
|
||||
<field name="model">intrastat.product.declaration</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Product Declaration">
|
||||
<header>
|
||||
<button name="action_gather" type="object"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('action', '=', 'nihil')]}"
|
||||
string="Generate Lines from Invoices"
|
||||
class="oe_highlight"/>
|
||||
<button name="generate_declaration" type="object"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('action', '=', 'nihil')]}"
|
||||
string="Generate Declaration Lines"/>
|
||||
<button name="generate_xml"
|
||||
string="Generate XML Declaration File"
|
||||
type="object"
|
||||
attrs="{'invisible': [('state', '!=', 'draft')]}"/>
|
||||
<button name="done" string="Done" type="object" class="oe_highlight" states="draft"/>
|
||||
<button name="back2draft" string="Back to Draft" type="object" states="done"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet string="Intrastat Product Declaration">
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<label string="Intrastat Product Declaration"/>
|
||||
<field name="year_month" class="oe_inline"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group name="top-block">
|
||||
<group name="properties-1">
|
||||
<group col="4" colspan="2">
|
||||
<field name="year"/>
|
||||
<field name="month"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="type"/>
|
||||
<field name="action"/>
|
||||
<field name="revision"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<group name="properties-2">
|
||||
<field name="num_decl_lines"/>
|
||||
<field name="total_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
|
||||
<field name="company_country_code" invisible="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Transactions">
|
||||
<group name="computation_lines">
|
||||
<field name="computation_line_ids" nolabel="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Declaration Lines">
|
||||
<group name="declaration_lines">
|
||||
<field name="declaration_line_ids" nolabel="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Notes">
|
||||
<field name="note"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Notification in the chatter -->
|
||||
<record id="intrastat_product_declaration_done" model="mail.message.subtype">
|
||||
<field name="name">Intrastat Product Declaration Validated</field>
|
||||
<field name="res_model">intrastat.product.declaration</field>
|
||||
<field name="default" eval="False"/>
|
||||
<field name="description">Intrastat Product Declaration Validated</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_declaration_view_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.tree</field>
|
||||
<field name="model">intrastat.product.declaration</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Product Declarations" colors="blue:state=='draft'">
|
||||
<field name="year_month"/>
|
||||
<field name="revision"/>
|
||||
<field name="type"/>
|
||||
<field name="num_decl_lines"/>
|
||||
<field name="total_amount" sum="Total amount"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_declaration_view_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.search</field>
|
||||
<field name="model">intrastat.product.declaration</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Intrastat Product Declarations">
|
||||
<filter name="arrivals" string="Arrivals" domain="[('type', '=', 'arrivals')]"/>
|
||||
<filter name="dispatches" string="Dispatches" domain="[('type', '=', 'dispatches')]"/>
|
||||
<filter name="draft" string="Draft" domain="[('state', '=', 'draft')]" />
|
||||
<filter name="done" string="Done" domain="[('state', '=', 'done')]" />
|
||||
<group string="Group By" name="group_by">
|
||||
<filter name="date_group_by" string="Date" context="{'group_by': 'year_month'}" />
|
||||
<filter name="type_group_by" string="Type" context="{'group_by': 'type'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_declaration_view_graph" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.graph</field>
|
||||
<field name="model">intrastat.product.declaration</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Intrastat Product" type="bar">
|
||||
<field name="year_month" type="row"/>
|
||||
<field name="type" type="row"/>
|
||||
<field name="total_amount" type="measure"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- No menuitem nor action since these are provided by the localization modules -->
|
||||
|
||||
<record id="intrastat_product_computation_line_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.computation.line.form</field>
|
||||
<field name="model">intrastat.product.computation.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Transaction">
|
||||
<group string="Transaction" name="transaction">
|
||||
<field name="parent_id"
|
||||
invisible="not context.get('intrastat_product_computation_line_main_view')"/>
|
||||
<field name="product_id"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="amount_company_currency"
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'company_currency_id'}"/>
|
||||
<field name="amount_accessory_cost_company_currency"
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'company_currency_id'}"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="transaction_id"/>
|
||||
<label for="weight"/>
|
||||
<div>
|
||||
<field name="weight" class="oe_inline"/>
|
||||
<label string=" Kg" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="suppl_unit_qty"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
<field name="transport_id"
|
||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||
<field name="incoterm_id" invisible="1"/>
|
||||
<field name="region_id" invisible="1"/>
|
||||
<field name="product_origin_country_id" invisible="1"/>
|
||||
<field name="invoice_id"/>
|
||||
</group>
|
||||
<group string="Declaration" name="declaration">
|
||||
<field name="declaration_line_id"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_computation_line_view_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.computation.line.tree</field>
|
||||
<field name="model">intrastat.product.computation.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Transactions">
|
||||
<field name="parent_id"
|
||||
invisible="not context.get('intrastat_product_computation_line_main_view')"/>
|
||||
<field name="product_id"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="amount_company_currency"/>
|
||||
<field name="amount_accessory_cost_company_currency"/>
|
||||
<field name="transaction_id"/>
|
||||
<field name="weight"/>
|
||||
<field name="suppl_unit_qty"
|
||||
attrs="{'invisible': [('intrastat_unit_id', '=', False)], 'required': [('intrastat_unit_id', '!=', False)]}"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="transport_id"
|
||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||
<field name="region_id" invisible="1"/>
|
||||
<field name="product_origin_country_id" invisible="1" string="Product C/O"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_declaration_line_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.line.form</field>
|
||||
<field name="model">intrastat.product.declaration.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Declaration Line">
|
||||
<group name="declaration">
|
||||
<field name="parent_id"
|
||||
invisible="not context.get('intrastat_product_declaration_line_main_view')"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="amount_company_currency"
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'company_currency_id'}"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="transaction_id"/>
|
||||
<label for="weight"/>
|
||||
<div>
|
||||
<field name="weight" class="oe_inline"/>
|
||||
<label string=" Kg" class="oe_inline"/>
|
||||
</div>
|
||||
<field name="suppl_unit_qty"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
<field name="transport_id"
|
||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||
<field name="region_id" invisible="1"/>
|
||||
<field name="incoterm_id" invisible="1"/>
|
||||
<field name="product_origin_country_id" invisible="1"/>
|
||||
</group>
|
||||
<group name="computation" string="Related Transactions">
|
||||
<field name="computation_line_ids" nolabel="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_product_declaration_line_view_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.declaration.line.tree</field>
|
||||
<field name="model">intrastat.product.declaration.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Declaration Lines">
|
||||
<field name="parent_id"
|
||||
invisible="not context.get('intrastat_product_declaration_line_main_view')"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="amount_company_currency"/>
|
||||
<field name="transaction_id"/>
|
||||
<field name="weight"/>
|
||||
<field name="suppl_unit_qty"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
<field name="transport_id"
|
||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||
<field name="region_id" invisible="1"/>
|
||||
<field name="incoterm_id" invisible="1"/>
|
||||
<field name="product_origin_country_id" invisible="1" string="Product C/O"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
46
intrastat_product/views/intrastat_region.xml
Normal file
46
intrastat_product/views/intrastat_region.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="intrastat_region_view_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.region.form</field>
|
||||
<field name="model">intrastat.region</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Region">
|
||||
<group>
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
<field name="country_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_region_view_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.region.tree</field>
|
||||
<field name="model">intrastat.region</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Region">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
<field name="country_id"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_region_action" model="ir.actions.act_window">
|
||||
<field name="name">Intrastat Regions</field>
|
||||
<field name="res_model">intrastat.region</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="intrastat_region_menu"
|
||||
action="intrastat_region_action"
|
||||
parent="intrastat_base.menu_intrastat_config_root"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
68
intrastat_product/views/intrastat_transaction.xml
Normal file
68
intrastat_product/views/intrastat_transaction.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2015 Noviat (http://www.noviat.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
@author Luc De Meyer <luc.demeyer@noviat.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Intrastat Transaction Type -->
|
||||
<record id="intrastat_transaction_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.transaction_form</field>
|
||||
<field name="model">intrastat.transaction</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Transaction Type">
|
||||
<group>
|
||||
<field name="code"/>
|
||||
<field name="description"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transaction_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.transaction_tree</field>
|
||||
<field name="model">intrastat.transaction</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Transaction Types">
|
||||
<field name="code"/>
|
||||
<field name="description"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transaction_mode_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.transaction.mode.search</field>
|
||||
<field name="model">intrastat.transaction</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Intrastat Transaction Types">
|
||||
<field name="description" string="Code or Description"
|
||||
filter_domain="['|', ('code', 'ilike', self), ('description', 'ilike', self)]"/>
|
||||
<group string="Group By" name="groupby">
|
||||
<filter name="company_groupby" string="Company"
|
||||
context="{'group_by': 'company_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transaction_action" model="ir.actions.act_window">
|
||||
<field name="name">Transaction Types</field>
|
||||
<field name="res_model">intrastat.transaction</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="intrastat_transaction_menu"
|
||||
action="intrastat_transaction_action"
|
||||
parent="intrastat_base.menu_intrastat_config_root"
|
||||
sequence="20"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
64
intrastat_product/views/intrastat_transport_mode.xml
Normal file
64
intrastat_product/views/intrastat_transport_mode.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2015 Noviat (http://www.noviat.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
@author Luc De Meyer <luc.demeyer@noviat.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Intrastat Transport Mode -->
|
||||
<record id="intrastat_transport_mode_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.transport.mode.form</field>
|
||||
<field name="model">intrastat.transport_mode</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Transport Mode">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="description"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transport_mode_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.transport.mode.tree</field>
|
||||
<field name="model">intrastat.transport_mode</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Transportat Modes">
|
||||
<field name="code"/>
|
||||
<field name="name"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transport_mode_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.transport.mode.search</field>
|
||||
<field name="model">intrastat.transport_mode</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Intrastat Transport Modes">
|
||||
<field name="name" string="Name, Code or Description"
|
||||
filter_domain="['|', '|', ('name', 'ilike', self), ('description', 'ilike', self), ('code', 'ilike', self)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_transport_action" model="ir.actions.act_window">
|
||||
<field name="name">Transport Modes</field>
|
||||
<field name="res_model">intrastat.transport_mode</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="intrastat_transport_menu"
|
||||
action="intrastat_transport_action"
|
||||
parent="intrastat_base.menu_intrastat_config_root"
|
||||
sequence="30"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
70
intrastat_product/views/intrastat_unit.xml
Normal file
70
intrastat_product/views/intrastat_unit.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
|
||||
Copyright (C) 2015 Noviat (http://www.noviat.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
@author Luc De Meyer <luc.demeyer@noviat.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Intrastat Supplementary Unit -->
|
||||
<record id="intrastat_unit_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.unit.form</field>
|
||||
<field name="model">intrastat.unit</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Supplementary Unit">
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="uom_id" required="1"/>
|
||||
<field name="description"/>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_unit_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.unit.tree</field>
|
||||
<field name="model">intrastat.unit</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Supplementary Units">
|
||||
<field name="name"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="intrastat_unit_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.unit.search</field>
|
||||
<field name="model">intrastat.unit</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Intrastat Supplementary Units">
|
||||
<field name="name"
|
||||
filter_domain="['|', ('name', 'ilike', self), ('description', 'ilike', self)]"/>
|
||||
<group string="Group By" name="groupby">
|
||||
<filter name="uom_groupby" string="Regular UoM"
|
||||
context="{'group_by': 'uom_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="intrastat_unit_action" model="ir.actions.act_window">
|
||||
<field name="name">Supplementary Units</field>
|
||||
<field name="res_model">intrastat.unit</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="intrastat_unit_menu"
|
||||
action="intrastat_unit_action"
|
||||
parent="intrastat_base.menu_intrastat_config_root"
|
||||
sequence="40"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
28
intrastat_product/views/res_company.xml
Normal file
28
intrastat_product/views/res_company.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_company_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.company.form</field>
|
||||
<field name="model">res.company</field>
|
||||
<field name="inherit_id" ref="intrastat_base.view_company_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<group name="intrastat-common" position="inside">
|
||||
<field name="intrastat" invisible="1"/>
|
||||
<field name="intrastat_arrivals"/>
|
||||
<field name="intrastat_dispatches"/>
|
||||
<field name="intrastat_transaction_out_invoice"/>
|
||||
<field name="intrastat_transaction_out_refund"/>
|
||||
<field name="intrastat_transaction_in_invoice"/>
|
||||
<field name="intrastat_transaction_in_refund"/>
|
||||
<field name="intrastat_region_id" domain="[('country_id','=', country_id)]" invisible="1"/>
|
||||
<field name="intrastat_transport_id"
|
||||
attrs="{'required': [('intrastat', '=', 'extended')], 'invisible': [('intrastat', '!=', 'extended')]}"/>
|
||||
<field name="intrastat_incoterm_id" invisible="1"/>
|
||||
<field name="intrastat_accessory_costs" invisible="1"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
28
intrastat_product/views/stock_picking.xml
Normal file
28
intrastat_product/views/stock_picking.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Add transport mode on picking form view -->
|
||||
<record id="view_picking_form" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.picking.form</field>
|
||||
<field name="model">stock.picking</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="backorder_id" position="after">
|
||||
<field name="intrastat_transport_id"
|
||||
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"
|
||||
widget="selection"/>
|
||||
<field name="intrastat" invisible="1"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
17
intrastat_product/views/stock_warehouse.xml
Normal file
17
intrastat_product/views/stock_warehouse.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_warehouse" model="ir.ui.view">
|
||||
<field name="name">intrastat.stock.warehouse.form</field>
|
||||
<field name="model">stock.warehouse</field>
|
||||
<field name="inherit_id" ref="stock.view_warehouse"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="region_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -13,3 +13,4 @@
|
||||
#
|
||||
# To provide both the URL and a branch, use:
|
||||
# sale-workflow https://github.com/OCA/sale-workflow branchname
|
||||
stock-logistics-workflow
|
||||
|
||||
68
product_harmonized_system/README.rst
Normal file
68
product_harmonized_system/README.rst
Normal file
@@ -0,0 +1,68 @@
|
||||
.. 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
|
||||
|
||||
|
||||
============================================
|
||||
Harmonized System Codes (and National Codes)
|
||||
============================================
|
||||
|
||||
This module contains the objects for Harmonised System Codes (H.S. codes). The full nomenclature is available from the `World Customs Organisation <http://www.wcoomd.org/>`. These code are usually required on the Proforma invoices that are attached to the packages that are shipped abroad.
|
||||
|
||||
This module also handle the local/national extensions to the H.S. codes. The import of the full nomenclature is not provided by this module ; it should be provided by localization modules.
|
||||
|
||||
You will also be able to configure the country of origin of a product, which is often required on the proforma invoice for the customs.
|
||||
|
||||
This module should be usefull for all companies that export physical goods abroad. This module is also used by the Intrastat modules for the European Union, cf the *intrastat_product* module.
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
This module is NOT compatible with the *report_intrastat* module from the official addons.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To create H.S. codes, go to the menu *Sales > Configuration > Product Categories and Attributes > H.S. Codes*.
|
||||
|
||||
Then you will be able to set the H.S. code on an product (under the *Information* tab) or on a product category. On the product form, you will also be able to set the *Country of Origin* of a product (for example, if the product is *made in China*, select *China* as *Country of Origin*).
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/227/10.0
|
||||
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues
|
||||
<https://github.com/OCA/intrastat/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
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
|
||||
* Luc De Meyer, Noviat <info@noviat.com>
|
||||
|
||||
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.
|
||||
3
product_harmonized_system/__init__.py
Normal file
3
product_harmonized_system/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
28
product_harmonized_system/__manifest__.py
Normal file
28
product_harmonized_system/__manifest__.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com)
|
||||
# © 2009-2016 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Product Harmonized System Codes',
|
||||
'version': '10.0.1.0.0',
|
||||
'category': 'Reporting',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Product Import/Export reports',
|
||||
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
|
||||
'depends': ['product'],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'security/product_hs_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'views/hs_code.xml',
|
||||
'views/product_category.xml',
|
||||
'views/product_template.xml',
|
||||
],
|
||||
'demo': [
|
||||
'demo/product_demo.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
81
product_harmonized_system/demo/product_demo.xml
Normal file
81
product_harmonized_system/demo/product_demo.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2011-2016 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo noupdate="1">
|
||||
|
||||
|
||||
<record id="84715000" model="hs.code">
|
||||
<field name="local_code">84715000</field>
|
||||
<field name="description">Automatic data-processing machines (computers)</field>
|
||||
</record>
|
||||
|
||||
<record id="84717050" model="hs.code">
|
||||
<field name="local_code">84717050</field>
|
||||
<field name="description">Storage units</field>
|
||||
</record>
|
||||
|
||||
<record id="85340090" model="hs.code">
|
||||
<field name="local_code">85340090</field>
|
||||
<field name="description">Printed circuits</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_3" model="product.product">
|
||||
<field name="hs_code_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight">8.7</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_4" model="product.product">
|
||||
<field name="hs_code_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.cn" />
|
||||
<field name="weight">1.1</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_5" model="product.product">
|
||||
<field name="hs_code_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.cn" />
|
||||
<field name="weight">8.2</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_13" model="product.product">
|
||||
<field name="hs_code_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight">0.01</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_16" model="product.product">
|
||||
<field name="hs_code_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight">0.67</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_17" model="product.product">
|
||||
<field name="hs_code_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight">0.75</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_20" model="product.product">
|
||||
<field name="hs_code_id" ref="85340090" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight">1.05</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_22" model="product.product">
|
||||
<field name="hs_code_id" ref="85340090" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight">0.3</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_25" model="product.product">
|
||||
<field name="hs_code_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.be" />
|
||||
<field name="weight">3.3</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
156
product_harmonized_system/i18n/fr.po
Normal file
156
product_harmonized_system/i18n/fr.po
Normal file
@@ -0,0 +1,156 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * product_harmonized_system
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-07-16 13:11+0000\n"
|
||||
"PO-Revision-Date: 2015-07-16 13:11+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: product_harmonized_system
|
||||
#: field:hs.code,active:0
|
||||
msgid "Active"
|
||||
msgstr "Actif"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.84715000
|
||||
msgid "Automatic data-processing machines (computers)"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:hs.code,local_code:0
|
||||
msgid "Code used for the national Import/Export declaration. e.g. Intrastat for the European Union"
|
||||
msgstr "Code utilisé pour la déclaration nationale d'import/export, par exemple la DEB pour la France"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,company_id:0
|
||||
msgid "Company"
|
||||
msgstr "Société"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:product.template,origin_country_id:0
|
||||
msgid "Country of Origin"
|
||||
msgstr "Pays d'origine"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.template,origin_country_id:0
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,create_uid:0
|
||||
msgid "Created by"
|
||||
msgstr "Créé par"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,create_date:0
|
||||
msgid "Created on"
|
||||
msgstr "Créé le"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,description:0
|
||||
msgid "Description"
|
||||
msgstr "Description"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,display_name:0
|
||||
msgid "Display Name"
|
||||
msgstr "Nom affiché"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_hs_code
|
||||
#: field:product.category,hs_code_id:0
|
||||
#: field:product.template,hs_code_id:0
|
||||
msgid "H.S. Code"
|
||||
msgstr "Code S.H."
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_form
|
||||
msgid "HS Code"
|
||||
msgstr "Code S.H."
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_tree
|
||||
#: model:ir.actions.act_window,name:product_harmonized_system.hs_code_act
|
||||
#: model:ir.ui.menu,name:product_harmonized_system.hs_code_menu
|
||||
msgid "HS Codes"
|
||||
msgstr "Codes S.H."
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.category,hs_code_id:0
|
||||
msgid "Harmonised System Code. If this code is not set on the product itself, it will be read here, on the related product category."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.template,hs_code_id:0
|
||||
msgid "Harmonised System Code. Nomenclature is available from the World Customs Organisation, see http://www.wcoomd.org/. You can leave this field empty and configure the H.S. code on the product category."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,id:0
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:product.category:product_harmonized_system.product_category_form_view
|
||||
msgid "Import/Export Properties"
|
||||
msgstr "Propriétés pour l'import/export"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,write_uid:0
|
||||
msgid "Last Updated by"
|
||||
msgstr "Dernière modification par"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,write_date:0
|
||||
msgid "Last Updated on"
|
||||
msgstr "Dernière modification le"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,local_code:0
|
||||
msgid "Local Code"
|
||||
msgstr "Code local"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.85340090
|
||||
msgid "Printed circuits"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_product_category
|
||||
msgid "Product Category"
|
||||
msgstr "Catégorie d'articles"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr "Modèle d'article"
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_search
|
||||
msgid "Search HS Codes"
|
||||
msgstr "Recherche dans les codes S.H."
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:hs.code,description:0
|
||||
msgid "Short text description of the H.S. category"
|
||||
msgstr "Courte description de la catégorie H.S."
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.84717050
|
||||
msgid "Storage units"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: sql_constraint:hs.code:0
|
||||
msgid "This code already exists for this company !"
|
||||
msgstr "Ce code existe déjà pour cette société !"
|
||||
|
||||
156
product_harmonized_system/i18n/product_harmonized_system.pot
Normal file
156
product_harmonized_system/i18n/product_harmonized_system.pot
Normal file
@@ -0,0 +1,156 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * product_harmonized_system
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-07-16 13:10+0000\n"
|
||||
"PO-Revision-Date: 2015-07-16 13:10+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: product_harmonized_system
|
||||
#: field:hs.code,active:0
|
||||
msgid "Active"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.84715000
|
||||
msgid "Automatic data-processing machines (computers)"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:hs.code,local_code:0
|
||||
msgid "Code used for the national Import/Export declaration. e.g. Intrastat for the European Union"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,company_id:0
|
||||
msgid "Company"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:product.template,origin_country_id:0
|
||||
msgid "Country of Origin"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.template,origin_country_id:0
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,create_uid:0
|
||||
msgid "Created by"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,create_date:0
|
||||
msgid "Created on"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,description:0
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,display_name:0
|
||||
msgid "Display Name"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_hs_code
|
||||
#: field:product.category,hs_code_id:0
|
||||
#: field:product.template,hs_code_id:0
|
||||
msgid "H.S. Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_form
|
||||
msgid "HS Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_tree
|
||||
#: model:ir.actions.act_window,name:product_harmonized_system.hs_code_act
|
||||
#: model:ir.ui.menu,name:product_harmonized_system.hs_code_menu
|
||||
msgid "HS Codes"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.category,hs_code_id:0
|
||||
msgid "Harmonised System Code. If this code is not set on the product itself, it will be read here, on the related product category."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:product.template,hs_code_id:0
|
||||
msgid "Harmonised System Code. Nomenclature is available from the World Customs Organisation, see http://www.wcoomd.org/. You can leave this field empty and configure the H.S. code on the product category."
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,id:0
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:product.category:product_harmonized_system.product_category_form_view
|
||||
msgid "Import/Export Properties"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,write_uid:0
|
||||
msgid "Last Updated by"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,write_date:0
|
||||
msgid "Last Updated on"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: field:hs.code,local_code:0
|
||||
msgid "Local Code"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.85340090
|
||||
msgid "Printed circuits"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_product_category
|
||||
msgid "Product Category"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:ir.model,name:product_harmonized_system.model_product_template
|
||||
msgid "Product Template"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: view:hs.code:product_harmonized_system.hs_code_search
|
||||
msgid "Search HS Codes"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: help:hs.code,description:0
|
||||
msgid "Short text description of the H.S. category"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: model:hs.code,description:product_harmonized_system.84717050
|
||||
msgid "Storage units"
|
||||
msgstr ""
|
||||
|
||||
#. module: product_harmonized_system
|
||||
#: sql_constraint:hs.code:0
|
||||
msgid "This code already exists for this company !"
|
||||
msgstr ""
|
||||
|
||||
5
product_harmonized_system/models/__init__.py
Normal file
5
product_harmonized_system/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import hs_code
|
||||
from . import product_category
|
||||
from . import product_template
|
||||
75
product_harmonized_system/models/hs_code.py
Normal file
75
product_harmonized_system/models/hs_code.py
Normal file
@@ -0,0 +1,75 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com)
|
||||
# © 2009-2016 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HSCode(models.Model):
|
||||
_name = "hs.code"
|
||||
_description = "H.S. Code"
|
||||
_order = "local_code"
|
||||
_rec_name = "display_name"
|
||||
|
||||
hs_code = fields.Char(
|
||||
string='H.S. Code', compute='_compute_hs_code', readonly=True,
|
||||
help="Harmonized System code (6 digits). Full list is "
|
||||
"available from the World Customs Organisation, see "
|
||||
"http://www.wcoomd.org")
|
||||
description = fields.Char(
|
||||
'Description', translate=True,
|
||||
help="Short text description of the H.S. category")
|
||||
display_name = fields.Char(
|
||||
compute='_compute_display_name_field', string="Display Name",
|
||||
store=True, readonly=True)
|
||||
local_code = fields.Char(
|
||||
string='Local Code', required=True,
|
||||
help="Code used for the national Import/Export declaration. "
|
||||
"The national code starts with the 6 digits of the H.S. and often "
|
||||
"has a few additional digits to extend the H.S. code.")
|
||||
active = fields.Boolean(default=True)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company', readonly=True, required=True,
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'hs.code'))
|
||||
product_categ_ids = fields.One2many(
|
||||
'product.category', 'hs_code_id', string='Product Categories')
|
||||
product_tmpl_ids = fields.One2many(
|
||||
'product.template', 'hs_code_id', string='Products')
|
||||
|
||||
@api.multi
|
||||
@api.depends('local_code')
|
||||
def _compute_hs_code(self):
|
||||
for this in self:
|
||||
this.hs_code = this.local_code and this.local_code[:6]
|
||||
|
||||
@api.multi
|
||||
@api.depends('local_code', 'description')
|
||||
def _compute_display_name_field(self):
|
||||
for this in self:
|
||||
display_name = this.local_code
|
||||
if this.description:
|
||||
display_name += ' ' + this.description
|
||||
this.display_name = len(display_name) > 55 \
|
||||
and display_name[:55] + '...' \
|
||||
or display_name
|
||||
|
||||
_sql_constraints = [
|
||||
('local_code_company_uniq', 'unique(local_code, company_id)',
|
||||
'This code already exists for this company !'),
|
||||
]
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('local_code'):
|
||||
vals['local_code'] = vals['local_code'].replace(' ', '')
|
||||
return super(HSCode, self).create(vals)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if vals.get('local_code'):
|
||||
vals['local_code'] = vals['local_code'].replace(' ', '')
|
||||
return super(HSCode, self).write(vals)
|
||||
30
product_harmonized_system/models/product_category.py
Normal file
30
product_harmonized_system/models/product_category.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com)
|
||||
# © 2009-2016 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
hs_code_id = fields.Many2one(
|
||||
'hs.code', string='H.S. Code',
|
||||
company_dependent=True, ondelete='restrict',
|
||||
help="Harmonised System Code. If this code is not "
|
||||
"set on the product itself, it will be read here, on the "
|
||||
"related product category.")
|
||||
|
||||
@api.multi
|
||||
def get_hs_code_recursively(self):
|
||||
self.ensure_one()
|
||||
if self.hs_code_id:
|
||||
res = self.hs_code_id
|
||||
elif self.parent_id:
|
||||
res = self.parent_id.get_hs_code_recursively()
|
||||
else:
|
||||
res = None
|
||||
return res
|
||||
35
product_harmonized_system/models/product_template.py
Normal file
35
product_harmonized_system/models/product_template.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2011-2016 Akretion (http://www.akretion.com)
|
||||
# © 2009-2016 Noviat (http://www.noviat.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
|
||||
hs_code_id = fields.Many2one(
|
||||
'hs.code', string='H.S. Code',
|
||||
company_dependent=True, ondelete='restrict',
|
||||
help="Harmonised System Code. Nomenclature is "
|
||||
"available from the World Customs Organisation, see "
|
||||
"http://www.wcoomd.org/. You can leave this field empty "
|
||||
"and configure the H.S. code on the product category.")
|
||||
origin_country_id = fields.Many2one(
|
||||
'res.country', string='Country of Origin',
|
||||
help="Country of origin of the product i.e. product "
|
||||
"'made in ____'.")
|
||||
|
||||
@api.multi
|
||||
def get_hs_code_recursively(self):
|
||||
self.ensure_one()
|
||||
if self.hs_code_id:
|
||||
res = self.hs_code_id
|
||||
elif self.categ_id:
|
||||
res = self.categ_id.get_hs_code_recursively()
|
||||
else:
|
||||
res = None
|
||||
return res
|
||||
3
product_harmonized_system/security/ir.model.access.csv
Normal file
3
product_harmonized_system/security/ir.model.access.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hs_code_group_system,Full access on hs.code to Settings group,model_hs_code,base.group_system,1,1,1,1
|
||||
access_hs_code_read,Read access on hs.code to everybody,model_hs_code,,1,0,0,0
|
||||
|
10
product_harmonized_system/security/product_hs_security.xml
Normal file
10
product_harmonized_system/security/product_hs_security.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record id="hs_code_company_rule" model="ir.rule">
|
||||
<field name="name">HS Code Company rule</field>
|
||||
<field name="model_id" ref="model_hs_code"/>
|
||||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
72
product_harmonized_system/views/hs_code.xml
Normal file
72
product_harmonized_system/views/hs_code.xml
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2010-2016 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Search view for H.S. code -->
|
||||
<record id="hs_code_view_search" model="ir.ui.view">
|
||||
<field name="name">hs.code.search</field>
|
||||
<field name="model">hs.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search H.S. Codes">
|
||||
<field name="local_code"
|
||||
filter_domain="['|', ('local_code', 'like', self), ('description', 'ilike', self)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree view for H.S. code -->
|
||||
<record id="hs_code_view_tree" model="ir.ui.view">
|
||||
<field name="name">hs.code.tree</field>
|
||||
<field name="model">hs.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="H.S. Codes">
|
||||
<field name="hs_code"/>
|
||||
<field name="local_code"/>
|
||||
<field name="description"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Form view for H.S. code -->
|
||||
<record id="hs_code_view_form" model="ir.ui.view">
|
||||
<field name="name">hs.code.form</field>
|
||||
<field name="model">hs.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="H.S. Code">
|
||||
<group name="main">
|
||||
<field name="local_code" />
|
||||
<field name="hs_code"/>
|
||||
<field name="description"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
<group name="product-categ" string="Product Categories">
|
||||
<field name="product_categ_ids" nolabel="1"/>
|
||||
</group>
|
||||
<group name="product-tmpl" string="Products">
|
||||
<field name="product_tmpl_ids" nolabel="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action for H.S. code -->
|
||||
<record id="hs_code_action" model="ir.actions.act_window">
|
||||
<field name="name">H.S. Codes</field>
|
||||
<field name="res_model">hs.code</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
<!-- Menu entry for H.S. code -->
|
||||
<!-- TODO: find a way to put a menu entry without depending on another module ?
|
||||
<menuitem id="hs_code_menu" action="hs_code_action"
|
||||
parent="product.prod_config_main" sequence="60"/>
|
||||
-->
|
||||
|
||||
</odoo>
|
||||
24
product_harmonized_system/views/product_category.xml
Normal file
24
product_harmonized_system/views/product_category.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2010-2016 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- Product category form view -->
|
||||
<record id="product_category_form_view" model="ir.ui.view">
|
||||
<field name="name">hs_code.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='first']" position="after">
|
||||
<group name="hs_code" string="Import/Export Properties" colspan="2">
|
||||
<field name="hs_code_id"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
23
product_harmonized_system/views/product_template.xml
Normal file
23
product_harmonized_system/views/product_template.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
© 2010-2016 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<odoo>
|
||||
|
||||
<!-- product.template form view -->
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">hs_code.product.template.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="list_price" position="after">
|
||||
<field name="hs_code_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
|
||||
<field name="origin_country_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user