Port intrastat_product to v10.0

intrastat_base: Move company view params to account config page
This commit is contained in:
Alexis de Lattre
2017-03-06 00:17:26 +01:00
parent 4d5456be03
commit c0443da565
36 changed files with 277 additions and 555 deletions

View File

@@ -18,7 +18,7 @@
'views/res_partner.xml',
'views/res_country.xml',
'views/account_tax.xml',
'views/res_company.xml',
'views/account_config_settings.xml',
'views/intrastat.xml',
],
'demo': [

View File

@@ -4,4 +4,5 @@ from . import res_country
from . import product_template
from . import account_tax
from . import res_company
from . import account_config_settings
from . import intrastat_common

View File

@@ -0,0 +1,12 @@
# -*- 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_remind_user_ids = fields.Many2many(
related='company_id.intrastat_remind_user_ids')

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# © 2013-2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields, api, _

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<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="account.view_account_config_settings" />
<field name="arch" type="xml">
<xpath expr="//field[@name='overdue_msg']/.." position="after">
<group name="intrastat" string="Intrastat">
<field name="intrastat_remind_user_ids" widget="many2many_tags" />
</group>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<!-- TODO: move to res.config page -->
<record id="view_company_form" model="ir.ui.view">
<field name="name">intrastat.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page name="intrastat" string="Intrastat">
<group name="intrastat-common" string="Intrastat Settings">
<field name="intrastat_remind_user_ids" widget="many2many_tags" />
</group>
</page>
</notebook>
</field>
</record>
</odoo>

View File

@@ -57,7 +57,7 @@ and adapt the code for the specific needs of your country.
Create also new objects inheriting from the Computation and Declaration Line Objects
so that you can add methods or customise the methods from the base modules (make a PR when
the customization or new method is required for multiple countries).
Adapt also the parent_id fields of the newly created objects
(cf. l10n_be_intrastat_product as example).
@@ -68,7 +68,7 @@ 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/227/8.0
:target: https://runbot.odoo-community.org/runbot/227/10.0
Bug Tracker
===========

View File

@@ -1,30 +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>
{
'name': 'Intrastat Product',
'version': '8.0.1.4.1',
'version': '10.0.1.0.0',
'category': 'Intrastat',
'license': 'AGPL-3',
'summary': 'Base module for Intrastat Product',
@@ -32,7 +14,6 @@
'depends': [
'intrastat_base',
'product_harmonized_system',
'stock_picking_invoice_link',
'sale_stock',
'purchase',
],
@@ -44,9 +25,9 @@
'views/intrastat_transaction.xml',
'views/intrastat_transport_mode.xml',
'views/intrastat_product_declaration.xml',
'views/res_company.xml',
'views/account_config_settings.xml',
'views/account_invoice.xml',
'views/stock_picking.xml',
'views/sale_order.xml',
'views/stock_warehouse.xml',
'security/intrastat_security.xml',
'security/ir.model.access.csv',
@@ -54,5 +35,5 @@
'data/intrastat_unit.xml',
],
'demo': ['demo/intrastat_demo.xml'],
'installable': False,
'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
@@ -84,23 +69,9 @@ class AccountInvoice(models.Model):
@api.model
def _default_src_dest_region_id(self):
rco = self.env['res.company']
company_id = rco._company_default_get('account.invoice')
company = rco.browse(company_id)
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):
@@ -410,7 +385,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 = _(

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>
@@ -13,6 +12,11 @@
<field name="model_id" ref="model_intrastat_region"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</data>
</openerp>
<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>