[MIG] intrastat_product: Migration to 10.0

intrastat_base: Move company view params to account config page
This commit is contained in:
Alexis de Lattre
2016-10-04 00:41:33 +02:00
committed by João Marques
parent 8bb9826df0
commit 4bbb1d7cda
31 changed files with 297 additions and 604 deletions

View File

@@ -2,9 +2,9 @@
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
========================
Intrastat Product Module
========================
=================
Intrastat Product
=================
This module contains common objects and fields for the Intrastat Product reporting, such as the *H.S. codes* (if you are not familiar with H.S. codes, read `Wikipedia <http://en.wikipedia.org/wiki/Harmonized_System>`) and the *country of origin* on the products.
@@ -27,7 +27,6 @@ This module conflicts with the module *report_intrastat* from the official addon
If you have already installed the module *report_intrastat*,
you should uninstall it before installing this module.
Usage
=====
@@ -69,26 +68,16 @@ and adapt the code for the specific needs of your country.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/8.0
Known issues / Roadmap
======================
Work is in progress to migrate the existing l10n_fr_intrastat_product module
to this new reporting framework, cf. Alexis de Lattre, Akretion <alexis.delattre@akretion.com>.
:target: https://runbot.odoo-community.org/runbot/227/10.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-reporting/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/
account-financial-reporting/issues/new?body=module:%20
intrastat_product%0Aversion:%20
8.0.1.4%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/intrastat/issues>`_. In case
of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed
and welcomed feedback.
Credits
=======
@@ -99,7 +88,6 @@ Contributors
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
* Luc De Meyer, Noviat <info@noviat.com>
Maintainer
----------
@@ -113,4 +101,4 @@ 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.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
{
'name': 'Intrastat Product',
'version': '10.0.1.0.0',
'category': 'Intrastat',
'license': 'AGPL-3',
'summary': 'Base module for Intrastat Product',
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
'depends': [
'intrastat_base',
'product_harmonized_system',
'sale_stock',
'purchase',
],
'conflicts': ['report_intrastat'],
'data': [
'views/hs_code.xml',
'views/intrastat_region.xml',
'views/intrastat_unit.xml',
'views/intrastat_transaction.xml',
'views/intrastat_transport_mode.xml',
'views/intrastat_product_declaration.xml',
'views/account_config_settings.xml',
'views/account_invoice.xml',
'views/sale_order.xml',
'views/stock_warehouse.xml',
'security/intrastat_security.xml',
'security/ir.model.access.csv',
'data/intrastat_transport_mode.xml',
'data/intrastat_unit.xml',
],
'demo': ['demo/intrastat_demo.xml'],
'installable': True,
}

View File

@@ -1,58 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Intrastat Product',
'version': '8.0.1.4.1',
'category': 'Intrastat',
'license': 'AGPL-3',
'summary': 'Base module for Intrastat Product',
'author': 'Akretion, Noviat, Odoo Community Association (OCA)',
'depends': [
'intrastat_base',
'product_harmonized_system',
'stock_picking_invoice_link',
'sale_stock',
'purchase',
],
'conflicts': ['report_intrastat'],
'data': [
'views/hs_code.xml',
'views/intrastat_region.xml',
'views/intrastat_unit.xml',
'views/intrastat_transaction.xml',
'views/intrastat_transport_mode.xml',
'views/intrastat_product_declaration.xml',
'views/res_company.xml',
'views/account_invoice.xml',
'views/stock_picking.xml',
'views/stock_warehouse.xml',
'security/intrastat_security.xml',
'security/ir.model.access.csv',
'data/intrastat_transport_mode.xml',
'data/intrastat_unit.xml',
],
'demo': ['demo/intrastat_demo.xml'],
'installable': True,
}

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<record id="intrastat_transport_1" model="intrastat.transport_mode">
<field name="code">1</field>
@@ -49,5 +48,4 @@
<field name="intrastat_transport_id" ref="intrastat_transport_3"/>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<!-- Extracted from the Official Journal of the European Union -->
@@ -121,5 +120,4 @@
<field name="description">Terajoule (gross calorific value)</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,13 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2011-2015 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
© 2011-2017 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<record id="product_harmonized_system.84715000" model="hs.code">
<field name="intrastat_unit_id" ref="intrastat_unit_pce"/>
@@ -24,5 +22,4 @@
<field name="intrastat_transport_id" ref="intrastat_transport_3"/>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from . import res_company
from . import account_config_settings
from . import account_invoice
from . import hs_code
from . import intrastat_product_declaration
@@ -8,5 +9,4 @@ from . import intrastat_transaction
from . import intrastat_transport_mode
from . import intrastat_unit
from . import sale_order
from . import stock_picking
from . import stock_warehouse

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
class AccountConfigSettings(models.TransientModel):
_inherit = 'account.config.settings'
intrastat_incoterm_id = fields.Many2one(
related='company_id.intrastat_incoterm_id')
intrastat_arrivals = fields.Selection(
related='company_id.intrastat_arrivals')
intrastat_dispatches = fields.Selection(
related='company_id.intrastat_dispatches')
intrastat = fields.Char(related='company_id.intrastat', readonly=True)
intrastat_transport_id = fields.Many2one(
related='company_id.intrastat_transport_id')
intrastat_region_id = fields.Many2one(
related='company_id.intrastat_region_id')
intrastat_transaction_out_invoice = fields.Many2one(
related='company_id.intrastat_transaction_out_invoice')
intrastat_transaction_out_refund = fields.Many2one(
related='company_id.intrastat_transaction_out_refund')
intrastat_transaction_in_invoice = fields.Many2one(
related='company_id.intrastat_transaction_in_invoice')
intrastat_transaction_in_refund = fields.Many2one(
related='company_id.intrastat_transaction_in_refund')
intrastat_accessory_costs = fields.Boolean(
related='company_id.intrastat_accessory_costs')

View File

@@ -1,37 +1,17 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2016 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2016 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api
from odoo import models, fields, api
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
incoterm_id = fields.Many2one(
'stock.incoterms', string='Incoterm',
help="International Commercial Terms are a series of predefined "
"commercial terms used in international transactions.")
# in v10, the sale_stock module defines an incoterms_id
# Odoo v8 name: incoterm_id
intrastat_transaction_id = fields.Many2one(
'intrastat.transaction', string='Intrastat Transaction Type',
default=lambda self: self._default_intrastat_transaction_id(),
@@ -42,33 +22,38 @@ class AccountInvoice(models.Model):
ondelete='restrict')
src_dest_country_id = fields.Many2one(
'res.country', string='Origin/Destination Country',
ondelete='restrict')
src_dest_region_id = fields.Many2one(
'intrastat.region', string='Origin/Destination Region',
default=lambda self: self._default_src_dest_region_id(),
help="Origin/Destination Region."
"\nThis field is used for the Intrastat Declaration.",
ondelete='restrict')
compute='_compute_intrastat_country',
store=True,
help="Destination country for dispatches. Origin country for "
"arrivals.")
intrastat_country = fields.Boolean(
compute='_compute_intrastat_country',
store=True, string='Intrastat Country', readonly=True)
src_dest_region_id = fields.Many2one(
'intrastat.region', string='Origin/Destination Region',
default=lambda self: self._default_src_dest_region_id(),
help="Origin region for dispatches, destination region for "
"arrivals. This field is used for the Intrastat Declaration.",
ondelete='restrict')
intrastat = fields.Char(
string='Intrastat Declaration',
related='company_id.intrastat', readonly=True)
@api.multi
@api.depends('src_dest_country_id', 'partner_id.country_id')
@api.depends('partner_shipping_id.country_id', 'partner_id.country_id')
def _compute_intrastat_country(self):
for inv in self:
country = inv.src_dest_country_id \
country = inv.partner_shipping_id.country_id\
or inv.partner_id.country_id
if not country:
country = inv.company_id.country_id
inv.src_dest_country_id = country.id
inv.intrastat_country = country.intrastat
@api.model
def _default_intrastat_transaction_id(self):
company = self.env['res.company']
company_id = company._company_default_get('account.invoice')
company = company.browse(company_id)
rco = self.env['res.company']
company = rco._company_default_get('account.invoice')
inv_type = self._context.get('type')
if inv_type == 'out_invoice':
return company.intrastat_transaction_out_invoice
@@ -83,24 +68,10 @@ class AccountInvoice(models.Model):
@api.model
def _default_src_dest_region_id(self):
company = self.env['res.company']
company_id = company._company_default_get('account.invoice')
company = company.browse(company_id)
rco = self.env['res.company']
company = rco._company_default_get('account.invoice')
return company.intrastat_region_id
@api.multi
def onchange_partner_id(
self, type, partner_id, date_invoice=False,
payment_term=False, partner_bank_id=False, company_id=False):
res = super(AccountInvoice, self).onchange_partner_id(
type, partner_id, date_invoice=date_invoice,
payment_term=payment_term, partner_bank_id=partner_bank_id,
company_id=company_id)
if partner_id:
partner = self.env['res.partner'].browse(partner_id)
res['value']['src_dest_country_id'] = partner.country_id.id
return res
class AccountInvoiceLine(models.Model):
_inherit = 'account.invoice.line'
@@ -108,22 +79,8 @@ class AccountInvoiceLine(models.Model):
hs_code_id = fields.Many2one(
'hs.code', string='Intrastat Code', ondelete='restrict')
@api.multi
def product_id_change(
self, product, uom_id, qty=0, name='', type='out_invoice',
partner_id=False, fposition_id=False, price_unit=False,
currency_id=False, company_id=None):
res = super(AccountInvoiceLine, self).product_id_change(
product, uom_id, qty=qty, name=name, type=type,
partner_id=partner_id, fposition_id=fposition_id,
price_unit=price_unit, currency_id=currency_id,
company_id=company_id)
if product:
product = self.env['product.product'].browse(product)
hs_code = product.product_tmpl_id.get_hs_code_recursively()
if hs_code:
res['value']['hs_code_id'] = hs_code.id
else:
res['value']['hs_code_id'] = False
return res
@api.onchange('product_id')
def intrastat_product_id_change(self):
if self.product_id:
hs_code = self.product_id.product_tmpl_id.get_hs_code_recursively()
self.hs_code_id = hs_code and hs_code.id or False

View File

@@ -1,29 +1,11 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api, _
from openerp.exceptions import ValidationError
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class HSCode(models.Model):
@@ -36,13 +18,13 @@ class HSCode(models.Model):
def _hs_code(self):
if self.company_id.country_id.intrastat:
if not self.local_code.isdigit():
raise ValidationError(
_("Intrastat Codes should only contain digits. "
"This is not the case for code '%s'.")
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.")
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)))

View File

@@ -1,31 +1,12 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api, _
from openerp.exceptions import RedirectWarning, ValidationError
from openerp.exceptions import Warning as UserError
import openerp.addons.decimal_precision as dp
from odoo import models, fields, api, _
from odoo.exceptions import RedirectWarning, ValidationError, UserError
import odoo.addons.decimal_precision as dp
from datetime import datetime, date
from dateutil.relativedelta import relativedelta
import logging
@@ -38,12 +19,6 @@ class IntrastatProductDeclaration(models.Model):
_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):
@@ -262,7 +237,7 @@ class IntrastatProductDeclaration(models.Model):
product = inv_line.product_id
invoice = inv_line.invoice_id
intrastat_unit_id = hs_code.intrastat_unit_id
source_uom = inv_line.uos_id
source_uom = inv_line.uom_id
weight_uom_categ = self._get_uom_refs('weight_uom_categ')
kg_uom = self._get_uom_refs('kg_uom')
pce_uom_categ = self._get_uom_refs('pce_uom_categ')
@@ -294,8 +269,8 @@ class IntrastatProductDeclaration(models.Model):
self._note += note
return weight, suppl_unit_qty
if target_uom.category_id == source_uom.category_id:
suppl_unit_qty = self.env['product.uom']._compute_qty_obj(
source_uom, line_qty, target_uom)
suppl_unit_qty = source_uom._compute_quantity(
line_qty, target_uom)
else:
note = "\n" + _(
"Conversion from unit of measure '%s' to '%s' "
@@ -311,10 +286,9 @@ class IntrastatProductDeclaration(models.Model):
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)
weight = source_uom._compute_quantity(line_qty, kg_uom)
elif source_uom.category_id == pce_uom_categ:
if not product.weight_net:
if not product.weight: # re-create weight_net ?
note = "\n" + _(
"Missing net weight on product %s."
) % product.name_get()[0][1]
@@ -324,13 +298,13 @@ class IntrastatProductDeclaration(models.Model):
self._note += note
return weight, suppl_unit_qty
if source_uom == pce_uom:
weight = product.weight_net * line_qty
weight = product.weight * line_qty # product.weight_net
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)
# product.weight_net
weight = product.weight * \
source_uom._compute_quantity(line_qty, pce_uom)
else:
note = "\n" + _(
"Conversion from unit of measure '%s' to 'Kg' "
@@ -374,24 +348,18 @@ class IntrastatProductDeclaration(models.Model):
"""
region = False
inv_type = inv_line.invoice_id.type
if inv_line.move_line_ids:
if inv_type in ('in_invoice', 'out_refund'):
region = inv_line.move_line_ids[0].location_id.\
get_intrastat_region()
else:
region = inv_line.move_line_ids[0].location_dest_id.\
get_intrastat_region()
elif inv_type in ('in_invoice', 'in_refund'):
if inv_type in ('in_invoice', 'in_refund'):
po_lines = self.env['purchase.order.line'].search(
[('invoice_lines', 'in', inv_line.id)])
if po_lines:
po = po_lines.order_id
region = po.location_id.get_intrastat_region()
elif inv_line.invoice_id.type in ('out_invoice', 'out_refund'):
if po_lines[0].move_ids:
region = po_lines[0].move_ids[0].location_id\
.get_intrastat_region()
elif inv_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
so = so_lines[0].order_id
region = so.warehouse_id.region_id
if not region:
if self.company_id.intrastat_region_id:
@@ -410,7 +378,7 @@ class IntrastatProductDeclaration(models.Model):
return transport
def _get_incoterm(self, inv_line):
incoterm = inv_line.invoice_id.incoterm_id \
incoterm = inv_line.invoice_id.incoterms_id \
or self.company_id.intrastat_incoterm_id
if not incoterm:
msg = _(
@@ -499,7 +467,7 @@ class IntrastatProductDeclaration(models.Model):
total_inv_accessory_costs_cc = 0.0 # in company currency
total_inv_product_cc = 0.0 # in company currency
total_inv_weight = 0.0
for inv_line in invoice.invoice_line:
for inv_line in invoice.invoice_line_ids:
if (
accessory_costs and
@@ -530,7 +498,7 @@ class IntrastatProductDeclaration(models.Model):
if any([
tax.exclude_from_intrastat_if_present
for tax in inv_line.invoice_line_tax_id]):
for tax in inv_line.invoice_line_tax_ids]):
_logger.info(
'Skipping invoice line %s '
'qty %s of invoice %s. Reason: '

View File

@@ -1,26 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
#
# Copyright (c) 2009-2015 Noviat nv/sa (www.noviat.com).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2009-2017 Noviat nv/sa (www.noviat.com).
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields
from odoo import models, fields
class IntrastatRegion(models.Model):
@@ -39,5 +21,5 @@ class IntrastatRegion(models.Model):
_sql_constraints = [
('intrastat_region_code_unique',
'UNIQUE(code, country_id)',
'UNIQUE(code, country_id)', # TODO add company_id ?
'Code must be unique.')]

View File

@@ -1,28 +1,10 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api
from odoo import models, fields, api
class IntrastatTransaction(models.Model):
@@ -34,8 +16,8 @@ class IntrastatTransaction(models.Model):
code = fields.Char(string='Code', required=True)
description = fields.Text(string='Description')
display_name = fields.Char(
compute='_compute_display_name', string="Display Name", readonly=True,
store=True)
compute='_compute_display_name_field', string="Display Name",
readonly=True, store=True)
company_id = fields.Many2one(
'res.company', string='Company',
default=lambda self: self.env['res.company']._company_default_get(
@@ -43,7 +25,7 @@ class IntrastatTransaction(models.Model):
@api.multi
@api.depends('code', 'description')
def _compute_display_name(self):
def _compute_display_name_field(self):
for this in self:
display_name = this.code
if this.description:

View File

@@ -1,28 +1,10 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api
from odoo import models, fields, api
class IntrastatTransportMode(models.Model):

View File

@@ -1,41 +1,20 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields
from odoo import models, fields
class IntrastatUnit(models.Model):
_name = 'intrastat.unit'
_description = 'Intrastat Supplementary Units'
name = fields.Char(
string='Name', required=True)
description = fields.Char(
string='Description', required=True)
name = fields.Char(string='Name', required=True)
description = fields.Char(string='Description', required=True)
uom_id = fields.Many2one(
'product.uom', string='Regular UoM',
help="Select the regular Unit of Measure of Odoo that corresponds "
"to this Intrastat Supplementary Unit.")
active = fields.Boolean(
string='Active', default=True)
active = fields.Boolean(string='Active', default=True)

View File

@@ -1,28 +1,10 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2011-2017 Akretion (http://www.akretion.com)
# © 2009-2017 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api
from odoo import models, fields, api
class ResCompany(models.Model):

View File

@@ -1,37 +1,26 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2010-2015 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2010-2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
from openerp import models, api
from odoo import models, fields, api
class SaleOrder(models.Model):
_inherit = "sale.order"
@api.model
def _prepare_invoice(self, order, lines):
intrastat_transport_id = fields.Many2one(
'intrastat.transport_mode', string='Transport Mode',
help="This information is used in Intrastat reports")
intrastat = fields.Selection(
string='Intrastat Declaration',
related='company_id.intrastat_dispatches', readonly=True)
@api.multi
def _prepare_invoice(self):
'''Copy destination country to invoice'''
invoice_vals = super(SaleOrder, self)._prepare_invoice(
order, lines)
invoice_vals['src_dest_country_id'] = \
order.partner_shipping_id.country_id.id or False
invoice_vals['incoterm_id'] = order.incoterm.id or False
return invoice_vals
vals = super(SaleOrder, self)._prepare_invoice()
if self.intrastat_transport_id:
vals['intrastat_transport_id'] = self.intrastat_transport_id.id
if self.warehouse_id.region_id:
vals['src_dest_region_id'] = self.warehouse_id.region_id.id
return vals

View File

@@ -1,46 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Intrastat Product module for Odoo
# Copyright (C) 2011-2015 Akretion (http://www.akretion.com)
# Copyright (C) 2009-2015 Noviat (http://www.noviat.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
class StockPicking(models.Model):
_inherit = "stock.picking"
intrastat_transport_id = fields.Many2one(
'intrastat.transport_mode', string='Transport Mode',
help="This information is used in Intrastat reports")
intrastat = fields.Char(related='company_id.intrastat')
@api.model
def _create_invoice_from_picking(self, picking, vals):
""" Copy data from picking to invoice. """
vals['intrastat_transport_id'] = picking.intrastat_transport_id.id
if picking.partner_id and picking.partner_id.country_id:
vals['src_dest_country_id'] = picking.partner_id.country_id.id
region = picking.location_id.get_intrastat_region()
if region:
vals['src_dest_region_id'] = region.id
return super(StockPicking, self)._create_invoice_from_picking(
picking, vals)

View File

@@ -1,34 +1,15 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Odoo, Open Source Management Solution
#
# Copyright (c) 2009-2015 Noviat nv/sa (www.noviat.com).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2009-2017 Noviat nv/sa (www.noviat.com).
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# @author Luc de Meyer <info@noviat.com>
from openerp import models, fields, api
from odoo import models, fields, api
class StockWarehouse(models.Model):
_inherit = 'stock.warehouse'
region_id = fields.Many2one(
'intrastat.region',
string='Intrastat region')
region_id = fields.Many2one('intrastat.region', string='Intrastat Region')
class StockLocation(models.Model):

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<record id="intrastat_transaction_company_rule" model="ir.rule">
<field name="name">Intrastat Transaction Company rule</field>
@@ -14,5 +13,10 @@
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</data>
</openerp>
<record id="intrastat_product_declaration_company_rule" model="ir.rule">
<field name="name">Intrastat Product Declaration Company rule</field>
<field name="model_id" ref="model_intrastat_product_declaration"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</odoo>

View File

@@ -1,13 +1,12 @@
<?xml version="1.0"?>
<openerp>
<data>
<odoo>
<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"/>
<record id="view_account_config_settings" model="ir.ui.view">
<field name="name">intrastat.account.config.settings.form</field>
<field name="model">account.config.settings</field>
<field name="inherit_id" ref="intrastat_base.view_account_config_settings"/>
<field name="arch" type="xml">
<group name="intrastat-common" position="inside">
<group name="intrastat" position="inside">
<field name="intrastat" invisible="1"/>
<field name="intrastat_arrivals"/>
<field name="intrastat_dispatches"/>
@@ -24,5 +23,4 @@
</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,17 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="invoice_form" model="ir.ui.view">
<field name="name">intrastat.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='date_due']" position="after">
<field name="incoterm_id"
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"/>
</xpath>
<xpath expr="//field[@name='move_id']" position="after">
<xpath expr="//page[@name='other_info']//field[@name='name']" position="after">
<field name="intrastat_transaction_id"/>
<field name="intrastat" invisible="1"/>
<field name="intrastat_transport_id"
@@ -20,8 +15,8 @@
<field name="src_dest_country_id" string="Destination Country"/>
<field name="src_dest_region_id" string="Origin Region" invisible="1"/>
</xpath>
<xpath expr="//field[@name='invoice_line']//field[@name='account_id']" position="after">
<field name="hs_code_id"/>
<xpath expr="//field[@name='invoice_line_ids']//field[@name='account_id']" position="after">
<field name="hs_code_id" invisible="1"/>
</xpath>
</field>
</record>
@@ -31,24 +26,23 @@
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_term']" position="after">
<field name="incoterm_id"
<xpath expr="//field[@name='payment_term_id']" position="after">
<field name="incoterms_id"
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"/>
</xpath>
<xpath expr="//field[@name='period_id']" position="after">
<xpath expr="//page/group/group/field[@name='company_id']" position="after">
<field name="intrastat_transaction_id"/>
<field name="intrastat" invisible="1"/>
<field name="intrastat_transport_id"
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"
widget="selection"/>
<field name="src_dest_country_id" string="Origin/Destination Country"/>
<field name="src_dest_region_id" string="Origin/Destination Region" invisible="1"/>
<field name="src_dest_country_id" string="Origin Country"/>
<field name="src_dest_region_id" string="Destination Region" invisible="1"/>
</xpath>
<xpath expr="//field[@name='invoice_line']//field[@name='account_id']" position="after">
<field name="hs_code_id"/>
<xpath expr="//field[@name='invoice_line_ids']//field[@name='account_id']" position="after">
<field name="hs_code_id" invisible="1"/>
</xpath>
</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
Copyright (C) 2015 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
The licence is in the file __openerp__.py
© 2010-2017 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<!-- Add the H.S. code menu under the Intrastat Config menu -->
<menuitem id="intrastat_code_menu"
@@ -41,5 +39,4 @@
</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<openerp>
<data>
<odoo>
<record id="intrastat_product_declaration_view_form" model="ir.ui.view">
<field name="name">intrastat.product.declaration.form</field>
@@ -75,14 +74,6 @@
</field>
</record>
<!-- Notification in the chatter -->
<record id="intrastat_product_declaration_done" model="mail.message.subtype">
<field name="name">Intrastat Product Declaration Validated</field>
<field name="res_model">intrastat.product.declaration</field>
<field name="default" eval="False"/>
<field name="description">Intrastat Product Declaration Validated</field>
</record>
<record id="intrastat_product_declaration_view_tree" model="ir.ui.view">
<field name="name">intrastat.product.declaration.tree</field>
<field name="model">intrastat.product.declaration</field>
@@ -259,5 +250,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="intrastat_region_view_form" model="ir.ui.view">
<field name="name">intrastat.region.form</field>
@@ -42,5 +41,4 @@
action="intrastat_region_action"
parent="intrastat_base.menu_intrastat_config_root"/>
</data>
</openerp>
</odoo>

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
Copyright (C) 2015 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
The licence is in the file __openerp__.py
© 2010-2017 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<!-- Intrastat Transaction Type -->
<record id="intrastat_transaction_form" model="ir.ui.view">
@@ -64,5 +62,4 @@
parent="intrastat_base.menu_intrastat_config_root"
sequence="20"/>
</data>
</openerp>
</odoo>

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
Copyright (C) 2015 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
The licence is in the file __openerp__.py
© 2010-2017 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<!-- Intrastat Transport Mode -->
<record id="intrastat_transport_mode_form" model="ir.ui.view">
@@ -60,5 +58,4 @@
parent="intrastat_base.menu_intrastat_config_root"
sequence="30"/>
</data>
</openerp>
</odoo>

View File

@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2010-2015 Akretion (http://www.akretion.com/)
Copyright (C) 2015 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
The licence is in the file __openerp__.py
© 2010-2017 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
@author Luc De Meyer <luc.demeyer@noviat.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<!-- Intrastat Supplementary Unit -->
<record id="intrastat_unit_form" model="ir.ui.view">
@@ -66,5 +64,4 @@
parent="intrastat_base.menu_intrastat_config_root"
sequence="40"/>
</data>
</openerp>
</odoo>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<odoo>
<record id="sale_order_form" model="ir.ui.view">
<field name="name">intrastat.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock"/>
<field name="arch" type="xml">
<field name="incoterm" position="after">
<field name="intrastat_transport_id"
attrs="{'invisible': [('intrastat', '!=', 'extended')]}"
widget="selection"/>
<field name="intrastat" invisible="1"/>
</field>
</field>
</record>
</odoo>

View File

@@ -1,28 +0,0 @@
<?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>

View File

@@ -1,17 +1,15 @@
<?xml version="1.0"?>
<openerp>
<data>
<odoo>
<record id="view_warehouse" model="ir.ui.view">
<field name="name">intrastat.stock.warehouse.form</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
<field name="partner_id" position="after">
<field name="region_id"/>
</xpath>
</field>
</field>
</record>
</data>
</openerp>
</odoo>