mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[IMP] intrastat_product: Several things:
* Update README.rst and translation files * Add index=True on some fields on which we often search, as suggested by Yannick * Remove description in __openerp__.py * Move ACL from l10n_fr_intrastat_product module to intrastat_product module * Large code re-engineering following the Akretion-Noviat code sprint on intrastat This code has been written both by Luc de Meyer and myself. * Add first draft of code to generate decl lines
This commit is contained in:
committed by
João Marques
parent
8a21ba50c3
commit
56eee3721f
41
intrastat_product/README.rst
Normal file
41
intrastat_product/README.rst
Normal file
@@ -0,0 +1,41 @@
|
||||
Intrastat Product Module
|
||||
========================
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. image:: http://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: http://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 http://odoo-community.org.
|
||||
@@ -1,23 +1,7 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat product module for OpenERP
|
||||
# Copyright (C) 2011-2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from . import res_company
|
||||
from . import intrastat
|
||||
from . import intrastat_declaration
|
||||
from . import stock
|
||||
from . import account_invoice
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-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 <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
|
||||
@@ -22,23 +24,27 @@
|
||||
|
||||
{
|
||||
'name': 'Intrastat Product',
|
||||
'version': '1.1',
|
||||
'category': 'Localisation/Report Intrastat',
|
||||
'version': '1.3',
|
||||
'category': 'Intrastat',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Base module for Intrastat Product',
|
||||
'description': """
|
||||
This module contains the common objects for the Intrastat Product.
|
||||
This module is country-independant.
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion
|
||||
<alexis.delattre@akretion.com>
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['intrastat_base'],
|
||||
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
|
||||
'depends': [
|
||||
'intrastat_base',
|
||||
'product_harmonized_system',
|
||||
'stock',
|
||||
],
|
||||
'conflicts': ['report_intrastat'],
|
||||
'data': [
|
||||
'intrastat_view.xml',
|
||||
'intrastat_declaration_view.xml',
|
||||
'res_company_view.xml',
|
||||
'account_invoice_view.xml',
|
||||
'stock_view.xml',
|
||||
'security/intrastat_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'data/intrastat_transport_mode.xml',
|
||||
'data/intrastat_unit.xml',
|
||||
],
|
||||
'demo': ['intrastat_demo.xml'],
|
||||
'installable': True,
|
||||
|
||||
88
intrastat_product/account_invoice.py
Normal file
88
intrastat_product/account_invoice.py
Normal file
@@ -0,0 +1,88 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2012-2015 Noviat nv/sa (www.noviat.com)
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class AccountInvoice(models.Model):
|
||||
_inherit = 'account.invoice'
|
||||
|
||||
@api.model
|
||||
def _default_intrastat_transaction(self):
|
||||
""" placeholder for localisation modules """
|
||||
return self.env['intrastat.transaction'].browse([])
|
||||
|
||||
intrastat_transaction_id = fields.Many2one(
|
||||
'intrastat.transaction', string='Intrastat Transaction Type',
|
||||
default=_default_intrastat_transaction, 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')
|
||||
intrastat_country = fields.Boolean(
|
||||
related='src_dest_country_id.intrastat',
|
||||
store=True, string='Intrastat Country', readonly=True)
|
||||
intrastat = fields.Char(
|
||||
string='Intrastat Declaration',
|
||||
related='company_id.intrastat', store=True, readonly=True)
|
||||
|
||||
@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.get_hs_code_recursively()
|
||||
if hs_code:
|
||||
res['value']['hs_code_id'] = hs_code.id
|
||||
return res
|
||||
44
intrastat_product/account_invoice_view.xml
Normal file
44
intrastat_product/account_invoice_view.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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='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"/>
|
||||
</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='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 Country"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='invoice_line']//field[@name='account_id']" position="after">
|
||||
<field name="hs_code_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
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>
|
||||
@@ -6,8 +6,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 8.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2014-11-28 22:48+0000\n"
|
||||
"PO-Revision-Date: 2014-11-28 22:48+0000\n"
|
||||
"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"
|
||||
@@ -15,6 +15,11 @@ msgstr ""
|
||||
"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."
|
||||
@@ -25,6 +30,21 @@ msgstr ""
|
||||
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"
|
||||
@@ -40,6 +60,16 @@ msgstr ""
|
||||
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"
|
||||
@@ -56,7 +86,7 @@ msgid "H.S. code"
|
||||
msgstr ""
|
||||
|
||||
#. module: intrastat_product
|
||||
#: code:addons/intrastat_product/intrastat.py:56
|
||||
#: 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 ""
|
||||
@@ -95,6 +125,12 @@ msgstr ""
|
||||
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"
|
||||
@@ -105,18 +141,46 @@ msgstr ""
|
||||
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 ""
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for OpenERP
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (http://tiny.be)
|
||||
# Copyright (C) 2010-2014 Akretion (http://www.akretion.com)
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-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 <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
|
||||
@@ -25,108 +26,97 @@ from openerp import models, fields, api, _
|
||||
from openerp.exceptions import ValidationError
|
||||
|
||||
|
||||
class ReportIntrastatCode(models.Model):
|
||||
_name = "report.intrastat.code"
|
||||
_description = "H.S. Code"
|
||||
_order = "name"
|
||||
_rec_name = "display_name"
|
||||
|
||||
@api.one
|
||||
@api.depends('name', 'description')
|
||||
def _compute_display_name(self):
|
||||
display_name = self.name or ''
|
||||
if self.description:
|
||||
display_name += ' ' + self.description
|
||||
self.display_name = display_name
|
||||
class IntrastatUnit(models.Model):
|
||||
_name = 'intrastat.unit'
|
||||
_description = 'Intrastat Supplementary Units'
|
||||
|
||||
name = fields.Char(
|
||||
string='H.S. code',
|
||||
help="Full length Harmonized System code (digits only). Full list is "
|
||||
"available from the World Customs Organisation, see "
|
||||
"http://www.wcoomd.org")
|
||||
string='Name', required=True)
|
||||
description = fields.Char(
|
||||
'Description', help="Short text description of the H.S. category")
|
||||
display_name = fields.Char(
|
||||
compute='_compute_display_name', string="Display Name", readonly=True,
|
||||
store=True)
|
||||
intrastat_code = fields.Char(
|
||||
string='European Intrastat Code', size=9, required=True,
|
||||
help="Code used for the Intrastat declaration. Must be part "
|
||||
"of the 'Combined Nomenclature' (CN), cf "
|
||||
"http://en.wikipedia.org/wiki/Combined_Nomenclature"
|
||||
"Must have 8 digits with sometimes a 9th digit.")
|
||||
intrastat_uom_id = fields.Many2one(
|
||||
'product.uom', string='UoM for Intrastat Report',
|
||||
help="Select the unit of measure if one is required for "
|
||||
"this particular Intrastat Code (other than the weight in Kg). "
|
||||
"If no particular unit of measure is required, leave empty.")
|
||||
active = fields.Boolean(default=True)
|
||||
product_categ_ids = fields.One2many(
|
||||
'product.category', 'intrastat_id', string='Product Categories')
|
||||
product_tmpl_ids = fields.One2many(
|
||||
'product.template', 'intrastat_id', string='Products')
|
||||
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)
|
||||
|
||||
@api.constrains('name', 'intrastat_code')
|
||||
|
||||
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.name and not self.name.isdigit():
|
||||
raise ValidationError(
|
||||
_("H.S. codes should only contain digits. It is not the case "
|
||||
"of H.S. code '%s'.") % self.name)
|
||||
if self.intrastat_code and not self.intrastat_code.isdigit():
|
||||
raise ValidationError(
|
||||
_("The field Intrastat Code should only contain digits. "
|
||||
"It is not the case of Intrastat Code '%s'.")
|
||||
% self.intrastat_code)
|
||||
if self.intrastat_code and len(self.intrastat_code) not in (8, 9):
|
||||
raise ValidationError(
|
||||
_("The field Intrastat Code should "
|
||||
"contain 8 or 9 digits. It is not the case of "
|
||||
"Intrastat Code '%s'.")
|
||||
% self.intrastat_code)
|
||||
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)))
|
||||
|
||||
|
||||
class IntrastatTransaction(models.Model):
|
||||
_name = 'intrastat.transaction'
|
||||
_description = "Intrastat Transaction"
|
||||
_order = 'code'
|
||||
_rec_name = 'display_name'
|
||||
|
||||
@api.one
|
||||
@api.depends('code', 'description')
|
||||
def _compute_display_name(self):
|
||||
display_name = self.code
|
||||
if self.description:
|
||||
display_name += ' ' + self.description
|
||||
self.display_name = len(display_name) > 55 \
|
||||
and display_name[:55] + '...' \
|
||||
or 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)
|
||||
company_id = fields.Many2one(
|
||||
'res.company', string='Company',
|
||||
default=lambda self: self.env['res.company']._company_default_get(
|
||||
'intrastat.transaction'))
|
||||
|
||||
_sql_constraints = [(
|
||||
'hs_code_uniq',
|
||||
'unique(name)',
|
||||
'This H.S. code already exists in Odoo !'
|
||||
)]
|
||||
|
||||
@api.model
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def create(self, vals):
|
||||
if vals.get('intrastat_code'):
|
||||
vals['intrastat_code'] = vals['intrastat_code'].replace(' ', '')
|
||||
return super(ReportIntrastatCode, self).create(vals)
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if vals.get('intrastat_code'):
|
||||
vals['intrastat_code'] = vals['intrastat_code'].replace(' ', '')
|
||||
return super(ReportIntrastatCode, self).write(vals)
|
||||
'intrastat_transaction_code_unique',
|
||||
'UNIQUE(code, company_id)',
|
||||
'Code must be unique.')]
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = "product.template"
|
||||
class IntrastatTransportMode(models.Model):
|
||||
_name = 'intrastat.transport_mode'
|
||||
_description = "Intrastat Transport Mode"
|
||||
_rec_name = 'display_name'
|
||||
_order = 'code'
|
||||
|
||||
intrastat_id = fields.Many2one(
|
||||
'report.intrastat.code', string='Intrastat Code',
|
||||
help="Code from the Harmonised System. Nomenclature is "
|
||||
"available from the World Customs Organisation, see "
|
||||
"http://www.wcoomd.org/. Some countries have made their own "
|
||||
"extensions to this nomenclature.")
|
||||
origin_country_id = fields.Many2one(
|
||||
'res.country', string='Country of Origin',
|
||||
help="Country of origin of the product i.e. product "
|
||||
"'made in ____'. If you have different countries of origin "
|
||||
"depending on the supplier from which you purchased the product, "
|
||||
"leave this field empty and use the equivalent field on the "
|
||||
"'product supplier info' form.")
|
||||
@api.one
|
||||
@api.depends('name', 'code')
|
||||
def _display_name(self):
|
||||
print "display_name self=", self
|
||||
print "self.code=", self.code
|
||||
print "self.name=", self.name
|
||||
self.display_name = '%s. %s' % (self.code, self.name)
|
||||
|
||||
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)
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = "product.category"
|
||||
|
||||
intrastat_id = fields.Many2one(
|
||||
'report.intrastat.code', string='Intrastat Code',
|
||||
help="Code from the Harmonised System. If this code is not "
|
||||
"set on the product itself, it will be read here, on the "
|
||||
"related product category.")
|
||||
_sql_constraints = [(
|
||||
'intrastat_transport_code_unique',
|
||||
'UNIQUE(code)',
|
||||
'Code must be unique.')]
|
||||
|
||||
724
intrastat_product/intrastat_declaration.py
Normal file
724
intrastat_product/intrastat_declaration.py
Normal file
@@ -0,0 +1,724 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Intrastat Product module for Odoo
|
||||
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
|
||||
# Copyright (C) 2011-2015 Noviat (http://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, _
|
||||
from openerp.exceptions import Warning, RedirectWarning, ValidationError
|
||||
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'))
|
||||
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='Month', readonly=True,
|
||||
track_visibility='always', store=True,
|
||||
help="Year and month of the declaration.")
|
||||
type = fields.Selection(
|
||||
'_get_type', string='Type', required=True,
|
||||
states={'done': [('readonly', True)]},
|
||||
track_visibility='always', 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.Float(
|
||||
compute='_compute_numbers', digits=dp.get_precision('Account'),
|
||||
string='Total Amount', store=True,
|
||||
help="Total 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.one
|
||||
@api.constrains('year')
|
||||
def _check_year(self):
|
||||
s = str(self.year)
|
||||
if len(s) != 4 or s[0] != '2':
|
||||
raise ValidationError(
|
||||
_("Invalid Year !"))
|
||||
|
||||
_sql_constraints = [
|
||||
('date_uniq',
|
||||
'unique(year_month, company_id, type)',
|
||||
"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.one
|
||||
@api.depends('year', 'month')
|
||||
def _compute_year_month(self):
|
||||
if self.year and self.month:
|
||||
self.year_month = '-'.join(
|
||||
[str(self.year), format(self.month, '02')])
|
||||
|
||||
@api.one
|
||||
@api.depends('month')
|
||||
def _check_validity(self):
|
||||
""" TO DO: logic based upon computation lines """
|
||||
self.valid = True
|
||||
|
||||
@api.one
|
||||
@api.returns('self', lambda value: value.id)
|
||||
def copy(self, default=None):
|
||||
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.intrastat_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):
|
||||
if inv_line.invoice_id.intrastat_transaction_id:
|
||||
tr = inv_line.invoice_id.intrastat_transaction_id.code
|
||||
else:
|
||||
tr = self.env.ref(
|
||||
'l10n_be_intrastat_advanced.intrastat_transaction_1')
|
||||
return tr
|
||||
|
||||
def _get_region(self, inv_line):
|
||||
"""
|
||||
Logic copied from standard addons, l10n_be_intrastat module:
|
||||
If purchase, comes from purchase order, linked to a location,
|
||||
which is linked to the warehouse.
|
||||
|
||||
If sales, the sale order is linked to the warehouse.
|
||||
If sales, from a delivery order, linked to a location,
|
||||
which is linked to the warehouse.
|
||||
If none found, get the company one.
|
||||
"""
|
||||
region = False
|
||||
if inv_line.invoice_id.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 = self.env['stock.warehouse'].get_region_from_location(
|
||||
po.location_id)
|
||||
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
|
||||
else:
|
||||
msg = _(
|
||||
"The Intrastat Region of the Company is not set, "
|
||||
"please configure it first.")
|
||||
self._company_warning(msg)
|
||||
return region
|
||||
|
||||
def _get_weight_and_supplunits(self, inv_line):
|
||||
line_qty = inv_line.quantity
|
||||
product = inv_line.product_id
|
||||
invoice = inv_line.invoice_id
|
||||
intrastat_unit_id = inv_line.intrastat_id.intrastat_unit_id
|
||||
source_uom = inv_line.uos_id
|
||||
weight_uom_categ = self._uom_refs['weight_uom_categ']
|
||||
kg_uom = self._uom_refs['kg_uom']
|
||||
pce_uom_categ = self._uom_refs['pce_uom_categ']
|
||||
pce_uom = self._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, 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 "
|
||||
"settingsand regenerate the lines or adjust the lines "
|
||||
"with Intrastat Code '%s' manually"
|
||||
) % intrastat_code
|
||||
self._note += note
|
||||
return weight, suppl_unit_qty
|
||||
if target_uom.categ_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
|
||||
|
||||
else:
|
||||
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
|
||||
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."
|
||||
) % source_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
|
||||
|
||||
return weight, suppl_unit_qty
|
||||
|
||||
def _get_amount(self, inv_line):
|
||||
invoice = inv_line.invoice_id
|
||||
amount = inv_line.price_subtotal
|
||||
if invoice.currency_id.name != 'EUR':
|
||||
amount = self.env['res.currency'].with_context(
|
||||
date=invoice.date_invoice).compute(
|
||||
invoice.currency_id,
|
||||
self.company_id.currency_id,
|
||||
amount)
|
||||
return amount
|
||||
|
||||
def _get_transport(self, inv_line):
|
||||
transport = inv_line.invoice.transport_mode_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.incoterm_id \
|
||||
or self.company_id.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 _gather_invoices(self):
|
||||
|
||||
decl_lines = []
|
||||
start_date = date(self.year, self.month, 1)
|
||||
end_date = start_date + relativedelta(day=1, months=+1, days=-1)
|
||||
|
||||
invoices = self.env['account.invoice'].search([
|
||||
('date_invoice', '>=', start_date),
|
||||
('date_invoice', '<=', end_date),
|
||||
('state', 'in', ['open', 'paid']),
|
||||
('intrastat_country', '=', True),
|
||||
('company_id', '=', self.company_id.id)])
|
||||
|
||||
for invoice in invoices:
|
||||
|
||||
if self.type == 'arrivals':
|
||||
if invoice.type in ['out_invoice', 'in_refund']:
|
||||
continue
|
||||
else:
|
||||
if invoice.type in ['in_invoice', 'out_refund']:
|
||||
continue
|
||||
|
||||
for inv_line in invoice.invoice_line:
|
||||
|
||||
intrastat = inv_line.intrastat_id
|
||||
if not intrastat:
|
||||
continue
|
||||
if not inv_line.quantity:
|
||||
continue
|
||||
|
||||
partner_country = self._get_partner_country(inv_line)
|
||||
if not partner_country:
|
||||
continue
|
||||
|
||||
intrastat_transaction = \
|
||||
self._get_intrastat_transaction(inv_line)
|
||||
|
||||
region = self._get_region(inv_line)
|
||||
|
||||
weight, suppl_unit_qty = self._get_weight_and_supplunits(
|
||||
inv_line)
|
||||
|
||||
amount_company_currency = self._get_amount(inv_line)
|
||||
|
||||
line_vals = {
|
||||
'parent_id': self.id,
|
||||
'invoice_line_id': inv_line.id,
|
||||
'partner_country_id': partner_country.id,
|
||||
'product_id': inv_line.product_id.id,
|
||||
'intrastat_code_id': intrastat.id,
|
||||
'weight': weight,
|
||||
'suppl_unit_qty': suppl_unit_qty,
|
||||
'amount_company_currency': amount_company_currency,
|
||||
'transaction_id': intrastat_transaction.id,
|
||||
'region_id': region.id,
|
||||
'extended': self._extended,
|
||||
}
|
||||
|
||||
# extended declaration
|
||||
if self._extended:
|
||||
transport = self._get_transport(inv_line)
|
||||
incoterm = self._get_incoterm(inv_line)
|
||||
line_vals.update({
|
||||
'transport_id': transport.id,
|
||||
'incoterm_id': incoterm.id,
|
||||
})
|
||||
|
||||
decl_lines.append((0, 0, line_vals))
|
||||
|
||||
return decl_lines
|
||||
|
||||
@api.multi
|
||||
def action_gather(self):
|
||||
self.ensure_one()
|
||||
self._note = ''
|
||||
self._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')
|
||||
}
|
||||
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
|
||||
|
||||
decl_lines_init = [(6, 0, [])]
|
||||
decl_lines = decl_lines_init[:]
|
||||
|
||||
decl_lines += self._gather_invoices()
|
||||
|
||||
if decl_lines == decl_lines_init:
|
||||
self.action = 'nihil'
|
||||
note = "\n" + \
|
||||
_("No records found for the selected period !") + '\n' + \
|
||||
_("The Declaration Action has been set to 'nihil'.")
|
||||
self._note += note
|
||||
|
||||
# To DO: add check on tax cases 46, 48, 84, 86
|
||||
|
||||
self.write({'intrastat_line_ids': decl_lines})
|
||||
|
||||
if self._note:
|
||||
note_header = '\n\n>>> ' + str(date.today()) + '\n'
|
||||
self.note = (self.note or '') + note_header + self._note
|
||||
result_view = self.env.ref(
|
||||
'l10n_be_intrastat_advanced.intrastat_result_view')
|
||||
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(self, computation_line):
|
||||
hashcode = "%s-%s-%s-%s-%s" % (
|
||||
computation_line.src_dest_country_id.id or False,
|
||||
computation_line.hs_code or False,
|
||||
computation_line.intrastat_unit_id.id or False,
|
||||
computation_line.transaction_id.id or False,
|
||||
computation_line.transport_id.id or False
|
||||
)
|
||||
return hashcode
|
||||
|
||||
@api.multi
|
||||
def generate_declaration(self):
|
||||
""" generate declaration lines """
|
||||
self.ensure_one()
|
||||
assert self.valid, 'Computation lines are not valid'
|
||||
# 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]
|
||||
ipdlo = self.pool['intrastat.product.declaration.line']
|
||||
for cl_lines in dl_group.values():
|
||||
vals = ipdlo._prepare_declaration_line(cl_lines)
|
||||
declaration_line = ipdlo.create(vals)
|
||||
cl_lines.write({'declaration_line_id': declaration_line.id})
|
||||
return True
|
||||
|
||||
|
||||
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 (Kg)',
|
||||
digits=dp.get_precision('Stock Weight'))
|
||||
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.")
|
||||
transaction_id = fields.Many2one(
|
||||
'intrastat.transaction',
|
||||
string='Intrastat Transaction')
|
||||
# extended declaration
|
||||
transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode',
|
||||
string='Transport Mode')
|
||||
|
||||
@api.one
|
||||
@api.depends('transport_id')
|
||||
def _check_validity(self):
|
||||
""" TO DO: logic based upon fields """
|
||||
self.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 (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')
|
||||
# extended declaration
|
||||
transport_id = fields.Many2one(
|
||||
'intrastat.transport_mode',
|
||||
string='Transport Mode')
|
||||
|
||||
@api.model
|
||||
def _prepare_grouped_fields(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': computation_line.hs_code_id.local_code,
|
||||
'transaction_id': computation_line.transaction_id.id,
|
||||
'transport_id': computation_line.transport_id.id,
|
||||
'parent_id': computation_line.parent_id.id,
|
||||
}
|
||||
for field in fields_to_sum:
|
||||
vals[field] = 0.0
|
||||
return vals
|
||||
|
||||
def _fields_to_sum():
|
||||
fields_to_sum = [
|
||||
'weight',
|
||||
'suppl_unit_qty',
|
||||
'amount_company_currency',
|
||||
]
|
||||
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]
|
||||
return vals
|
||||
177
intrastat_product/intrastat_declaration_view.xml
Normal file
177
intrastat_product/intrastat_declaration_view.xml
Normal file
@@ -0,0 +1,177 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="intrastat_product_declaration_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" string="Generate Declaration" type="object"/>
|
||||
<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"/>
|
||||
</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="currency_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Transactions">
|
||||
<group name="computation_lines">
|
||||
<field name="computation_line_ids" nolabel="1">
|
||||
<tree string="Transactions">
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="product_id"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="amount_company_currency"/>
|
||||
<field name="weight" attrs="{'invisible': [('intrastat_unit_id', '!=', False)], 'required': [('intrastat_unit_id', '=', False)]}"/>
|
||||
<field name="suppl_unit_qty" attrs="{'invisible': [('intrastat_unit_id', '=', False)], 'required': [('intrastat_unit_id', '!=', False)]}"/>
|
||||
<field name="transaction_id"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Transactions">
|
||||
<group col="4" string="Transaction" colspan="4">
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="product_id"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="amount_company_currency" widget="monetary" options="{'currency_field': 'company_currency_id'}"/>
|
||||
<field name="company_currency_id" invisible="1"/>
|
||||
<field name="weight"/>
|
||||
<field name="suppl_unit_qty"/>
|
||||
<field name="transaction_id"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
<field name="transport_id"
|
||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Declaration Lines">
|
||||
<group name="declaration_lines">
|
||||
<field name="declaration_line_ids" nolabel="1">
|
||||
<tree string="Intrastat Declaration Lines" editable="bottom">
|
||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||
<field name="hs_code_id"/>
|
||||
<field name="intrastat_unit_id"/>
|
||||
<field name="amount_company_currency"/>
|
||||
<field name="weight"/>
|
||||
<field name="suppl_unit_qty"/>
|
||||
<field name="transaction_id"/>
|
||||
<field name="reporting_level" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</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_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.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_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.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', 'like', 'EX19')]" />
|
||||
<filter name="dispatches" string="Dispatches" domain="[('type', 'like', 'EX29')]" />
|
||||
<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_graph" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.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>
|
||||
|
||||
<record id="intrastat_product_tree_action" model="ir.actions.act_window">
|
||||
<field name="name">Intrastat Product Declaration</field>
|
||||
<field name="res_model">intrastat.product.declaration</field>
|
||||
<field name="view_mode">tree,form,graph</field>
|
||||
</record>
|
||||
|
||||
<!-- TO BE REMOVED -->
|
||||
<menuitem id="intrastat_product_menu"
|
||||
parent="intrastat_base.menu_intrastat_base_root"
|
||||
action="intrastat_product_tree_action"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2011-2014 Akretion (http://www.akretion.com/)
|
||||
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
|
||||
-->
|
||||
@@ -9,80 +9,13 @@
|
||||
<openerp>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="84715000" model="report.intrastat.code">
|
||||
<field name="name">84715000</field>
|
||||
<field name="intrastat_code">84715000</field>
|
||||
<field name="intrastat_uom_id" ref="product.product_uom_unit"/>
|
||||
<field name="description">Automatic data-processing machines (computers)</field>
|
||||
<record id="product_harmonized_system.84715000" model="hs.code">
|
||||
<field name="intrastat_unit_id" ref="intrastat_unit_pce"/>
|
||||
</record>
|
||||
|
||||
<record id="84717050" model="report.intrastat.code">
|
||||
<field name="name">84717050</field>
|
||||
<field name="intrastat_code">84717050</field>
|
||||
<field name="intrastat_uom_id" ref="product.product_uom_unit"/>
|
||||
<field name="description">Storage units</field>
|
||||
<record id="product_harmonized_system.84717050" model="hs.code">
|
||||
<field name="intrastat_unit_id" ref="intrastat_unit_pce"/>
|
||||
</record>
|
||||
|
||||
<record id="85340090" model="report.intrastat.code">
|
||||
<field name="name">85340090</field>
|
||||
<field name="intrastat_code">85340090</field>
|
||||
<field name="description">Printed circuits</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_3" model="product.product">
|
||||
<field name="intrastat_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight_net">5</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_4" model="product.product">
|
||||
<field name="intrastat_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.cn" />
|
||||
<field name="weight_net">6</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_5" model="product.product">
|
||||
<field name="intrastat_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.cn" />
|
||||
<field name="weight_net">6.5</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_17" model="product.product">
|
||||
<field name="intrastat_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight_net">0.5</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_18" model="product.product">
|
||||
<field name="intrastat_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight_net">0.5</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_19" model="product.product">
|
||||
<field name="intrastat_id" ref="84717050" />
|
||||
<field name="origin_country_id" ref="base.sg" />
|
||||
<field name="weight_net">0.5</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_20" model="product.product">
|
||||
<field name="intrastat_id" ref="85340090" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight_net">0.7</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_21" model="product.product">
|
||||
<field name="intrastat_id" ref="85340090" />
|
||||
<field name="origin_country_id" ref="base.tw" />
|
||||
<field name="weight_net">0.8</field>
|
||||
</record>
|
||||
|
||||
<record id="product.product_product_25" model="product.product">
|
||||
<field name="intrastat_id" ref="84715000" />
|
||||
<field name="origin_country_id" ref="base.be" />
|
||||
<field name="weight_net">2</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -1,101 +1,203 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2010-2014 Akretion (http://www.akretion.com/)
|
||||
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>
|
||||
<data>
|
||||
|
||||
<!-- product.template form view -->
|
||||
<record id="product_template_form_view" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.template.form</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="intrastat_base.product_template_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="exclude_from_intrastat" position="before">
|
||||
<field name="intrastat_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
|
||||
<field name="origin_country_id" attrs="{'invisible': [('type', '=', 'service')]}"/>
|
||||
<!-- 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_tree"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="local_code" position="after">
|
||||
<field name="intrastat_unit_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Product category form view -->
|
||||
<record id="product_category_form_view" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.category.form</field>
|
||||
<field name="model">product.category</field>
|
||||
<field name="inherit_id" ref="product.product_category_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='parent']" position="inside">
|
||||
<group name="intrastat" string="Intrastat Properties" colspan="2">
|
||||
<field name="intrastat_id" />
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<!-- 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_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="local_code" position="after">
|
||||
<field name="intrastat_unit_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add search view for H.S. code -->
|
||||
<record id="product_intrastat_code_search" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.intrastat.code.search</field>
|
||||
<field name="model">report.intrastat.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Intrastat Codes">
|
||||
<field name="name"
|
||||
filter_domain="['|', '|', ('name', 'like', self), ('intrastat_code', 'like', self), ('description', 'ilike', self)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add tree view for H.S. code -->
|
||||
<record id="product_intrastat_code_tree" model="ir.ui.view">
|
||||
<field name="name">intrastat.product.intrastat.code.tree</field>
|
||||
<field name="model">report.intrastat.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Intrastat Codes">
|
||||
<!-- 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="intrastat_code" />
|
||||
<field name="intrastat_uom_id"/>
|
||||
<field name="uom_id" required="1"/>
|
||||
<field name="description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Add form view for H.S. code -->
|
||||
<record id="product_intrastat_code_form" model="ir.ui.view">
|
||||
<field name="name">fr.intrastat.product.intrastat.code.form</field>
|
||||
<field name="model">report.intrastat.code</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Intrastat Code">
|
||||
<group name="main">
|
||||
<field name="name" />
|
||||
<field name="intrastat_code"/>
|
||||
<field name="intrastat_uom_id"/>
|
||||
<field name="description" />
|
||||
<field name="active"/>
|
||||
</group>
|
||||
<group name="products" string="Products">
|
||||
<field name="product_tmpl_ids" nolabel="1"/>
|
||||
</group>
|
||||
<group name="categ" string="Product Categories">
|
||||
<field name="product_categ_ids" nolabel="1"/>
|
||||
</group>
|
||||
<field name="active"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Action for H.S. code -->
|
||||
<record id="product_intrastat_code_act" model="ir.actions.act_window">
|
||||
<field name="name">Intrastat Code</field>
|
||||
<field name="res_model">report.intrastat.code</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<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>
|
||||
|
||||
<!-- Menu entry for H.S. code -->
|
||||
<menuitem id="product_intrastat_code_menu"
|
||||
action="product_intrastat_code_act"
|
||||
parent="product.prod_config_main" />
|
||||
<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>
|
||||
|
||||
</data>
|
||||
|
||||
<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"/>
|
||||
|
||||
<!-- 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"/>
|
||||
|
||||
|
||||
<!-- 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>
|
||||
|
||||
67
intrastat_product/res_company.py
Normal file
67
intrastat_product/res_company.py
Normal file
@@ -0,0 +1,67 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2012-2015 Noviat nv/sa (www.noviat.com)
|
||||
# Copyright (C) 2015 Akretion (http://www.akretion.com)
|
||||
# @author Luc de Meyer <info@noviat.com>
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class ResCompany(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
@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.one
|
||||
@api.depends('intrastat_arrivals', 'intrastat_dispatches')
|
||||
def _compute_intrastat(self):
|
||||
if self.intrastat_arrivals == 'exempt' \
|
||||
and self.intrastat_dispatches == 'exempt':
|
||||
self.intrastat = 'exempt'
|
||||
elif self.intrastat_arrivals == 'extended' \
|
||||
or self.intrastat_dispatches == 'extended':
|
||||
self.intrastat = 'extended'
|
||||
else:
|
||||
self.intrastat = 'standard'
|
||||
|
||||
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')
|
||||
21
intrastat_product/res_company_view.xml
Normal file
21
intrastat_product/res_company_view.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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_transport_id"
|
||||
attrs="{'required': [('intrastat', '=', 'extended')], 'invisible': [('intrastat', '!=', 'extended')]}"/>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
12
intrastat_product/security/intrastat_security.xml
Normal file
12
intrastat_product/security/intrastat_security.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?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>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,3 +1,10 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_report_intrastat_code_sale_manager,Full access on report.intrastat.code to sale manager,model_report_intrastat_code,base.group_sale_manager,1,1,1,1
|
||||
access_report_intrastat_code_employee,Read access on report.intrastat.code to employee,model_report_intrastat_code,base.group_user,1,0,0,0
|
||||
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_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
|
||||
|
||||
|
40
intrastat_product/stock.py
Normal file
40
intrastat_product/stock.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# 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, 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 transport and department 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
|
||||
return super(StockPicking, self)._create_invoice_from_picking(
|
||||
picking, vals)
|
||||
28
intrastat_product/stock_view.xml
Normal file
28
intrastat_product/stock_view.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>
|
||||
Reference in New Issue
Block a user