mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
[MIG] intrastat_product: Migration to 11.0
* Small fixes in intrastat_base * account_tax_template
This commit is contained in:
committed by
João Marques
parent
e6e95c04d2
commit
c33db334d7
@@ -1,3 +1,2 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import models
|
from . import models
|
||||||
|
from . import report
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2019 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
# Copyright 2018 brain-tec AG (http://www.braintec-group.com)
|
||||||
# © 2018 brain-tec AG (http://www.braintec-group.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
# @author Kumar Aberer <kumar.aberer@braintec-group.com>
|
# @author Kumar Aberer <kumar.aberer@braintec-group.com>
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Intrastat Product',
|
'name': 'Intrastat Product',
|
||||||
'version': '11.0.1.1.0',
|
'version': '11.0.1.2.0',
|
||||||
'category': 'Intrastat',
|
'category': 'Intrastat',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Base module for Intrastat Product',
|
'summary': 'Base module for Intrastat Product',
|
||||||
@@ -19,8 +18,9 @@
|
|||||||
'product_harmonized_system',
|
'product_harmonized_system',
|
||||||
'sale_stock',
|
'sale_stock',
|
||||||
'purchase',
|
'purchase',
|
||||||
|
'report_xlsx_helper',
|
||||||
],
|
],
|
||||||
'conflicts': ['report_intrastat'],
|
'excludes': ['report_intrastat'],
|
||||||
'data': [
|
'data': [
|
||||||
'views/hs_code.xml',
|
'views/hs_code.xml',
|
||||||
'views/intrastat_region.xml',
|
'views/intrastat_region.xml',
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
<field name="code">7</field>
|
<field name="code">7</field>
|
||||||
<field name="name">Fixed installations</field>
|
<field name="name">Fixed installations</field>
|
||||||
<field name="description">Fixed transport installations (e.g. pipelines, high-tension cables)</field>
|
<field name="description">Fixed transport installations (e.g. pipelines, high-tension cables)</field>
|
||||||
<field name="description"></field>
|
|
||||||
</record>
|
</record>
|
||||||
<record id="intrastat_transport_8" model="intrastat.transport_mode">
|
<record id="intrastat_transport_8" model="intrastat.transport_mode">
|
||||||
<field name="code">8</field>
|
<field name="code">8</field>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from . import res_company
|
from . import res_company
|
||||||
from . import res_config_settings
|
from . import res_config_settings
|
||||||
from . import account_invoice
|
from . import account_invoice
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountInvoice(models.Model):
|
||||||
@@ -13,31 +12,34 @@ class AccountInvoice(models.Model):
|
|||||||
# in v10, the sale_stock module defines an incoterms_id
|
# in v10, the sale_stock module defines an incoterms_id
|
||||||
# Odoo v8 name: incoterm_id
|
# Odoo v8 name: incoterm_id
|
||||||
intrastat_transaction_id = fields.Many2one(
|
intrastat_transaction_id = fields.Many2one(
|
||||||
'intrastat.transaction', string='Intrastat Transaction Type',
|
comodel_name='intrastat.transaction',
|
||||||
default=lambda self: self._default_intrastat_transaction_id(),
|
string='Intrastat Transaction Type',
|
||||||
ondelete='restrict',
|
ondelete='restrict', track_visibility='onchange',
|
||||||
help="Intrastat nature of transaction")
|
help="Intrastat nature of transaction")
|
||||||
intrastat_transport_id = fields.Many2one(
|
intrastat_transport_id = fields.Many2one(
|
||||||
'intrastat.transport_mode', string='Intrastat Transport Mode',
|
comodel_name='intrastat.transport_mode',
|
||||||
|
string='Intrastat Transport Mode',
|
||||||
ondelete='restrict')
|
ondelete='restrict')
|
||||||
src_dest_country_id = fields.Many2one(
|
src_dest_country_id = fields.Many2one(
|
||||||
'res.country', string='Origin/Destination Country',
|
comodel_name='res.country',
|
||||||
|
string='Origin/Destination Country',
|
||||||
compute='_compute_intrastat_country',
|
compute='_compute_intrastat_country',
|
||||||
store=True,
|
store=True, compute_sudo=True,
|
||||||
help="Destination country for dispatches. Origin country for "
|
help="Destination country for dispatches. Origin country for "
|
||||||
"arrivals.")
|
"arrivals.")
|
||||||
intrastat_country = fields.Boolean(
|
intrastat_country = fields.Boolean(
|
||||||
compute='_compute_intrastat_country',
|
compute='_compute_intrastat_country', string='Intrastat Country',
|
||||||
store=True, string='Intrastat Country', readonly=True)
|
store=True, readonly=True, compute_sudo=True)
|
||||||
src_dest_region_id = fields.Many2one(
|
src_dest_region_id = fields.Many2one(
|
||||||
'intrastat.region', string='Origin/Destination Region',
|
comodel_name='intrastat.region',
|
||||||
|
string='Origin/Destination Region',
|
||||||
default=lambda self: self._default_src_dest_region_id(),
|
default=lambda self: self._default_src_dest_region_id(),
|
||||||
help="Origin region for dispatches, destination region for "
|
help="Origin region for dispatches, destination region for "
|
||||||
"arrivals. This field is used for the Intrastat Declaration.",
|
"arrivals. This field is used for the Intrastat Declaration.",
|
||||||
ondelete='restrict')
|
ondelete='restrict')
|
||||||
intrastat = fields.Char(
|
intrastat = fields.Char(
|
||||||
string='Intrastat Declaration',
|
string='Intrastat Declaration',
|
||||||
related='company_id.intrastat', readonly=True)
|
related='company_id.intrastat', readonly=True, compute_sudo=True)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('partner_shipping_id.country_id', 'partner_id.country_id')
|
@api.depends('partner_shipping_id.country_id', 'partner_id.country_id')
|
||||||
@@ -50,26 +52,10 @@ class AccountInvoice(models.Model):
|
|||||||
inv.src_dest_country_id = country.id
|
inv.src_dest_country_id = country.id
|
||||||
inv.intrastat_country = country.intrastat
|
inv.intrastat_country = country.intrastat
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _default_intrastat_transaction_id(self):
|
|
||||||
rco = self.env['res.company']
|
|
||||||
company = rco._company_default_get()
|
|
||||||
inv_type = self._context.get('type')
|
|
||||||
if inv_type == 'out_invoice':
|
|
||||||
return company.intrastat_transaction_out_invoice
|
|
||||||
elif inv_type == 'out_refund':
|
|
||||||
return company.intrastat_transaction_out_refund
|
|
||||||
elif inv_type == 'in_invoice':
|
|
||||||
return company.intrastat_transaction_in_invoice
|
|
||||||
elif inv_type == 'in_refund':
|
|
||||||
return company.intrastat_transaction_in_refund
|
|
||||||
else:
|
|
||||||
return self.env['intrastat.transaction']
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _default_src_dest_region_id(self):
|
def _default_src_dest_region_id(self):
|
||||||
rco = self.env['res.company']
|
rco = self.env['res.company']
|
||||||
company = rco._company_default_get()
|
company = rco._company_default_get('account.invoice')
|
||||||
return company.intrastat_region_id
|
return company.intrastat_region_id
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +63,8 @@ class AccountInvoiceLine(models.Model):
|
|||||||
_inherit = 'account.invoice.line'
|
_inherit = 'account.invoice.line'
|
||||||
|
|
||||||
hs_code_id = fields.Many2one(
|
hs_code_id = fields.Many2one(
|
||||||
'hs.code', string='Intrastat Code', ondelete='restrict')
|
comodel_name='hs.code',
|
||||||
|
string='Intrastat Code', ondelete='restrict')
|
||||||
|
|
||||||
@api.onchange('product_id')
|
@api.onchange('product_id')
|
||||||
def intrastat_product_id_change(self):
|
def intrastat_product_id_change(self):
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@@ -12,7 +11,8 @@ class HSCode(models.Model):
|
|||||||
_inherit = "hs.code"
|
_inherit = "hs.code"
|
||||||
|
|
||||||
intrastat_unit_id = fields.Many2one(
|
intrastat_unit_id = fields.Many2one(
|
||||||
'intrastat.unit', string='Intrastat Supplementary Unit')
|
comodel_name='intrastat.unit',
|
||||||
|
string='Intrastat Supplementary Unit')
|
||||||
|
|
||||||
@api.constrains('local_code')
|
@api.constrains('local_code')
|
||||||
def _hs_code(self):
|
def _hs_code(self):
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import RedirectWarning, ValidationError, UserError
|
from odoo.exceptions import RedirectWarning, ValidationError, UserError
|
||||||
import odoo.addons.decimal_precision as dp
|
import odoo.addons.decimal_precision as dp
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
@@ -19,6 +18,114 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
_rec_name = 'year_month'
|
_rec_name = 'year_month'
|
||||||
_inherit = ['mail.thread', 'intrastat.common']
|
_inherit = ['mail.thread', 'intrastat.common']
|
||||||
_order = 'year_month desc, type, revision'
|
_order = 'year_month desc, type, revision'
|
||||||
|
_sql_constraints = [
|
||||||
|
('date_uniq',
|
||||||
|
'unique(year_month, company_id, type, revision)',
|
||||||
|
"A declaration of the same type already exists for this month !"
|
||||||
|
"\nYou should update the existing declaration "
|
||||||
|
"or change the revision number of this one."),
|
||||||
|
]
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_year(self):
|
||||||
|
if datetime.now().month == 1:
|
||||||
|
year = datetime.now().year - 1
|
||||||
|
else:
|
||||||
|
year = datetime.now().year
|
||||||
|
return str(year)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_month(self):
|
||||||
|
if datetime.now().month == 1:
|
||||||
|
return 12
|
||||||
|
else:
|
||||||
|
return datetime.now().month - 1
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _default_action(self):
|
||||||
|
return 'replace'
|
||||||
|
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
comodel_name='res.company', string='Company', readonly=True,
|
||||||
|
default=lambda self: self.env['res.company']._company_default_get(
|
||||||
|
'intrastat.product.declaration'))
|
||||||
|
company_country_code = fields.Char(
|
||||||
|
compute='_compute_company_country_code',
|
||||||
|
string='Company Country Code', readonly=True, store=True,
|
||||||
|
help="Used in views and methods of localization modules.")
|
||||||
|
year = fields.Char(
|
||||||
|
string='Year', required=True,
|
||||||
|
default=lambda self: self._default_year(),
|
||||||
|
states={'done': [('readonly', True)]})
|
||||||
|
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=lambda self: self._default_month(),
|
||||||
|
states={'done': [('readonly', True)]})
|
||||||
|
year_month = fields.Char(
|
||||||
|
compute='_compute_year_month', string='Period', readonly=True,
|
||||||
|
track_visibility='onchange', store=True,
|
||||||
|
help="Year and month of the declaration.")
|
||||||
|
type = fields.Selection(
|
||||||
|
selection='_get_type', string='Type', required=True,
|
||||||
|
states={'done': [('readonly', True)]},
|
||||||
|
track_visibility='onchange', help="Select the declaration type.")
|
||||||
|
action = fields.Selection(
|
||||||
|
selection='_get_action',
|
||||||
|
string='Action', required=True,
|
||||||
|
default=lambda self: self._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(
|
||||||
|
comodel_name='intrastat.product.computation.line',
|
||||||
|
inverse_name='parent_id',
|
||||||
|
string='Intrastat Product Computation Lines',
|
||||||
|
states={'done': [('readonly', True)]})
|
||||||
|
declaration_line_ids = fields.One2many(
|
||||||
|
comodel_name='intrastat.product.declaration.line',
|
||||||
|
inverse_name='parent_id', string='Intrastat Product Declaration Lines',
|
||||||
|
states={'done': [('readonly', True)]})
|
||||||
|
num_decl_lines = fields.Integer(
|
||||||
|
compute='_compute_numbers', string='Number of Declaration Lines',
|
||||||
|
store=True, track_visibility='onchange')
|
||||||
|
total_amount = fields.Integer(
|
||||||
|
compute='_compute_numbers', string='Total Fiscal Amount', store=True,
|
||||||
|
help="Total fiscal amount in company currency of the declaration.")
|
||||||
|
currency_id = fields.Many2one(
|
||||||
|
'res.currency', related='company_id.currency_id', readonly=True,
|
||||||
|
string='Currency')
|
||||||
|
state = fields.Selection(
|
||||||
|
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(
|
||||||
|
selection='_get_reporting_level',
|
||||||
|
string='Reporting Level',
|
||||||
|
states={'done': [('readonly', True)]})
|
||||||
|
valid = fields.Boolean(
|
||||||
|
compute='_compute_check_validity',
|
||||||
|
string='Valid')
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def _get_type(self):
|
def _get_type(self):
|
||||||
@@ -38,6 +145,46 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
('standard', _('Standard')),
|
('standard', _('Standard')),
|
||||||
('extended', _('Extended'))]
|
('extended', _('Extended'))]
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _get_action(self):
|
||||||
|
return [
|
||||||
|
('replace', 'Replace'),
|
||||||
|
('append', 'Append'),
|
||||||
|
('nihil', 'Nihil')]
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('company_id')
|
||||||
|
def _compute_company_country_code(self):
|
||||||
|
for this in self:
|
||||||
|
if this.company_id:
|
||||||
|
if not this.company_id.country_id:
|
||||||
|
raise ValidationError(
|
||||||
|
_("You must set company's country !"))
|
||||||
|
this.company_country_code = \
|
||||||
|
this.company_id.country_id.code.lower()
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('year', 'month')
|
||||||
|
def _compute_year_month(self):
|
||||||
|
for this in self:
|
||||||
|
if this.year and this.month:
|
||||||
|
this.year_month = '-'.join(
|
||||||
|
[this.year, format(this.month, '02')])
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
@api.depends('month')
|
||||||
|
def _compute_check_validity(self):
|
||||||
|
""" TO DO: logic based upon computation lines """
|
||||||
|
for this in self:
|
||||||
|
this.valid = True
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
@api.constrains('year')
|
||||||
|
def _check_year(self):
|
||||||
|
for this in self:
|
||||||
|
if len(this.year) != 4 or this.year[0] != '2':
|
||||||
|
raise ValidationError(_("Invalid Year !"))
|
||||||
|
|
||||||
@api.onchange('type')
|
@api.onchange('type')
|
||||||
def _onchange_type(self):
|
def _onchange_type(self):
|
||||||
if self.type == 'arrivals':
|
if self.type == 'arrivals':
|
||||||
@@ -49,152 +196,6 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
self.company_id.intrastat_dispatches == 'extended' \
|
self.company_id.intrastat_dispatches == 'extended' \
|
||||||
and 'extended' or 'standard'
|
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, required=True,
|
|
||||||
default=lambda self: self.env['res.company']._company_default_get())
|
|
||||||
company_country_code = fields.Char(
|
|
||||||
compute='_compute_company_country_code',
|
|
||||||
string='Company Country Code', readonly=True, store=True,
|
|
||||||
help="Used in views and methods of localization modules.")
|
|
||||||
year = fields.Integer(
|
|
||||||
string='Year', required=True, default=_get_year,
|
|
||||||
states={'done': [('readonly', True)]})
|
|
||||||
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,
|
|
||||||
states={'done': [('readonly', True)]})
|
|
||||||
year_month = fields.Char(
|
|
||||||
compute='_compute_year_month', string='Period', readonly=True,
|
|
||||||
track_visibility='onchange', store=True,
|
|
||||||
help="Year and month of the declaration.")
|
|
||||||
type = fields.Selection(
|
|
||||||
'_get_type', string='Type', required=True,
|
|
||||||
states={'done': [('readonly', True)]},
|
|
||||||
track_visibility='onchange', help="Select the declaration type.")
|
|
||||||
action = fields.Selection(
|
|
||||||
'_get_action',
|
|
||||||
string='Action', required=True,
|
|
||||||
default=_get_default_action,
|
|
||||||
states={'done': [('readonly', True)]},
|
|
||||||
track_visibility='onchange')
|
|
||||||
revision = fields.Integer(
|
|
||||||
string='Revision', default=1,
|
|
||||||
states={'done': [('readonly', True)]},
|
|
||||||
help="Used to keep track of changes")
|
|
||||||
computation_line_ids = fields.One2many(
|
|
||||||
'intrastat.product.computation.line',
|
|
||||||
'parent_id', string='Intrastat Product Computation Lines',
|
|
||||||
states={'done': [('readonly', True)]})
|
|
||||||
declaration_line_ids = fields.One2many(
|
|
||||||
'intrastat.product.declaration.line',
|
|
||||||
'parent_id', string='Intrastat Product Declaration Lines',
|
|
||||||
states={'done': [('readonly', True)]})
|
|
||||||
num_decl_lines = fields.Integer(
|
|
||||||
compute='_compute_numbers', string='Number of Declaration Lines',
|
|
||||||
store=True, track_visibility='onchange')
|
|
||||||
total_amount = fields.Integer(
|
|
||||||
compute='_compute_numbers', string='Total Fiscal Amount', store=True,
|
|
||||||
help="Total fiscal amount in company currency of the declaration.")
|
|
||||||
currency_id = fields.Many2one(
|
|
||||||
related='company_id.currency_id', readonly=True, string='Company 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',
|
|
||||||
states={'done': [('readonly', True)]})
|
|
||||||
valid = fields.Boolean(
|
|
||||||
compute='_check_validity',
|
|
||||||
string='Valid')
|
|
||||||
|
|
||||||
@api.constrains('year')
|
|
||||||
def _check_year(self):
|
|
||||||
for this in self:
|
|
||||||
s = str(this.year)
|
|
||||||
if len(s) != 4 or s[0] != '2':
|
|
||||||
raise ValidationError(_("Invalid Year !"))
|
|
||||||
|
|
||||||
_sql_constraints = [
|
|
||||||
('date_uniq',
|
|
||||||
'unique(year_month, company_id, type, revision)',
|
|
||||||
"A declaration of the same type already exists for this month !"
|
|
||||||
"\nYou should update the existing declaration "
|
|
||||||
"or change the revision number of this one."),
|
|
||||||
]
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('company_id')
|
|
||||||
def _compute_company_country_code(self):
|
|
||||||
for this in self:
|
|
||||||
if this.company_id:
|
|
||||||
if not this.company_id.country_id:
|
|
||||||
raise ValidationError(
|
|
||||||
_("You must set the country of the company!"))
|
|
||||||
this.company_country_code = \
|
|
||||||
this.company_id.country_id.code.lower()
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('year', 'month')
|
|
||||||
def _compute_year_month(self):
|
|
||||||
for this in self:
|
|
||||||
if this.year and this.month:
|
|
||||||
this.year_month = '-'.join(
|
|
||||||
[str(this.year), format(this.month, '02')])
|
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends('month')
|
|
||||||
def _check_validity(self):
|
|
||||||
""" TO DO: logic based upon computation lines """
|
|
||||||
for this in self:
|
|
||||||
this.valid = True
|
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def copy(self, default=None):
|
def copy(self, default=None):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
@@ -202,11 +203,11 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
default['revision'] = self.revision + 1
|
default['revision'] = self.revision + 1
|
||||||
return super(IntrastatProductDeclaration, self).copy(default)
|
return super(IntrastatProductDeclaration, self).copy(default)
|
||||||
|
|
||||||
def _company_warning(self, msg):
|
def _account_config_warning(self, msg):
|
||||||
action = self.env.ref('base.action_res_company_form')
|
action = self.env.ref('account.action_account_config')
|
||||||
raise RedirectWarning(
|
raise RedirectWarning(
|
||||||
msg, action.id,
|
msg, action.id,
|
||||||
_('Go to company configuration screen'))
|
_('Go to Accounting Configuration Settings screen'))
|
||||||
|
|
||||||
def _get_partner_country(self, inv_line):
|
def _get_partner_country(self, inv_line):
|
||||||
country = inv_line.invoice_id.src_dest_country_id \
|
country = inv_line.invoice_id.src_dest_country_id \
|
||||||
@@ -353,7 +354,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
[('invoice_lines', 'in', inv_line.id)])
|
[('invoice_lines', 'in', inv_line.id)])
|
||||||
if po_lines:
|
if po_lines:
|
||||||
if po_lines[0].move_ids:
|
if po_lines[0].move_ids:
|
||||||
region = po_lines[0].move_ids[0].location_id\
|
region = po_lines[0].move_ids[0].location_dest_id\
|
||||||
.get_intrastat_region()
|
.get_intrastat_region()
|
||||||
elif inv_type in ('out_invoice', 'out_refund'):
|
elif inv_type in ('out_invoice', 'out_refund'):
|
||||||
so_lines = self.env['sale.order.line'].search(
|
so_lines = self.env['sale.order.line'].search(
|
||||||
@@ -374,7 +375,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
"The default Intrastat Transport Mode "
|
"The default Intrastat Transport Mode "
|
||||||
"of the Company is not set, "
|
"of the Company is not set, "
|
||||||
"please configure it first.")
|
"please configure it first.")
|
||||||
self._company_warning(msg)
|
self._account_config_warning(msg)
|
||||||
return transport
|
return transport
|
||||||
|
|
||||||
def _get_incoterm(self, inv_line):
|
def _get_incoterm(self, inv_line):
|
||||||
@@ -385,7 +386,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
"The default Incoterm "
|
"The default Incoterm "
|
||||||
"of the Company is not set, "
|
"of the Company is not set, "
|
||||||
"please configure it first.")
|
"please configure it first.")
|
||||||
self._company_warning(msg)
|
self._account_config_warning(msg)
|
||||||
return incoterm
|
return incoterm
|
||||||
|
|
||||||
def _get_product_origin_country(self, inv_line):
|
def _get_product_origin_country(self, inv_line):
|
||||||
@@ -435,7 +436,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
with the country-specific logic for arrivals and dispatches.
|
with the country-specific logic for arrivals and dispatches.
|
||||||
Cf. l10n_be_intrastat_product_declaration for an example
|
Cf. l10n_be_intrastat_product_declaration for an example
|
||||||
"""
|
"""
|
||||||
start_date = date(self.year, self.month, 1)
|
start_date = date(int(self.year), self.month, 1)
|
||||||
end_date = start_date + relativedelta(day=1, months=+1, days=-1)
|
end_date = start_date + relativedelta(day=1, months=+1, days=-1)
|
||||||
domain = [
|
domain = [
|
||||||
('date_invoice', '>=', start_date),
|
('date_invoice', '>=', start_date),
|
||||||
@@ -525,7 +526,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
_logger.info(
|
_logger.info(
|
||||||
'Skipping invoice line %s qty %s'
|
'Skipping invoice line %s qty %s '
|
||||||
'of invoice %s. Reason: no product nor hs_code'
|
'of invoice %s. Reason: no product nor hs_code'
|
||||||
% (inv_line.name, inv_line.quantity, invoice.number))
|
% (inv_line.name, inv_line.quantity, invoice.number))
|
||||||
continue
|
continue
|
||||||
@@ -608,7 +609,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def action_gather(self):
|
def action_gather(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
self.message_post(_("Generate Lines from Invoices"))
|
self.message_post(body=_("Generate Lines from Invoices"))
|
||||||
self._check_generate_lines()
|
self._check_generate_lines()
|
||||||
self._note = ''
|
self._note = ''
|
||||||
if (
|
if (
|
||||||
@@ -720,7 +721,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
""" generate declaration lines """
|
""" generate declaration lines """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
assert self.valid, 'Computation lines are not valid'
|
assert self.valid, 'Computation lines are not valid'
|
||||||
self.message_post(_("Generate Declaration Lines"))
|
self.message_post(body=_("Generate Declaration Lines"))
|
||||||
# Delete existing declaration lines
|
# Delete existing declaration lines
|
||||||
self.declaration_line_ids.unlink()
|
self.declaration_line_ids.unlink()
|
||||||
# Regenerate declaration lines from computation lines
|
# Regenerate declaration lines from computation lines
|
||||||
@@ -743,7 +744,7 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
def generate_xml(self):
|
def generate_xml(self):
|
||||||
""" generate the INTRASTAT Declaration XML file """
|
""" generate the INTRASTAT Declaration XML file """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
self.message_post(_("Generate XML Declaration File"))
|
self.message_post(body=_("Generate XML Declaration File"))
|
||||||
self._check_generate_xml()
|
self._check_generate_xml()
|
||||||
self._unlink_attachments()
|
self._unlink_attachments()
|
||||||
xml_string = self._generate_xml()
|
xml_string = self._generate_xml()
|
||||||
@@ -755,6 +756,52 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
raise UserError(
|
raise UserError(
|
||||||
_("No XML File has been generated."))
|
_("No XML File has been generated."))
|
||||||
|
|
||||||
|
@api.multi
|
||||||
|
def create_xls(self):
|
||||||
|
if self.env.context.get('computation_lines'):
|
||||||
|
report_file = 'instrastat_transactions'
|
||||||
|
else:
|
||||||
|
report_file = 'instrastat_declaration_lines'
|
||||||
|
return {
|
||||||
|
'type': 'ir.actions.report',
|
||||||
|
'report_type': 'xlsx',
|
||||||
|
'report_name': 'intrastat_product.product_declaration_xls',
|
||||||
|
'context': dict(self.env.context, report_file=report_file),
|
||||||
|
'data': {'dynamic_report': True},
|
||||||
|
}
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _xls_computation_line_fields(self):
|
||||||
|
"""
|
||||||
|
Update list in custom module to add/drop columns or change order
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
'product', 'product_origin_country',
|
||||||
|
'hs_code', 'src_dest_country',
|
||||||
|
'amount_company_currency', 'accessory_cost',
|
||||||
|
'transaction', 'weight', 'suppl_unit_qty', 'suppl_unit',
|
||||||
|
'transport', 'invoice',
|
||||||
|
]
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _xls_declaration_line_fields(self):
|
||||||
|
"""
|
||||||
|
Update list in custom module to add/drop columns or change order
|
||||||
|
"""
|
||||||
|
return [
|
||||||
|
'hs_code', 'src_dest_country', 'amount_company_currency',
|
||||||
|
'transaction', 'weight', 'suppl_unit_qty', 'suppl_unit',
|
||||||
|
'transport',
|
||||||
|
]
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _xls_template(self):
|
||||||
|
"""
|
||||||
|
Placeholder for excel report template updates
|
||||||
|
|
||||||
|
"""
|
||||||
|
return {}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def done(self):
|
def done(self):
|
||||||
self.write({'state': 'done'})
|
self.write({'state': 'done'})
|
||||||
@@ -766,27 +813,34 @@ class IntrastatProductDeclaration(models.Model):
|
|||||||
|
|
||||||
class IntrastatProductComputationLine(models.Model):
|
class IntrastatProductComputationLine(models.Model):
|
||||||
_name = 'intrastat.product.computation.line'
|
_name = 'intrastat.product.computation.line'
|
||||||
_description = "Intrastat Product Computation Lines"
|
_description = "Intrastat Product Computataion Lines"
|
||||||
|
|
||||||
parent_id = fields.Many2one(
|
parent_id = fields.Many2one(
|
||||||
'intrastat.product.declaration',
|
'intrastat.product.declaration',
|
||||||
string='Intrastat Product Declaration',
|
string='Intrastat Product Declaration',
|
||||||
ondelete='cascade', readonly=True)
|
ondelete='cascade', readonly=True)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
related='parent_id.company_id', readonly=True)
|
'res.company', related='parent_id.company_id',
|
||||||
|
string="Company", readonly=True)
|
||||||
company_currency_id = fields.Many2one(
|
company_currency_id = fields.Many2one(
|
||||||
related='company_id.currency_id', readonly=True)
|
'res.currency', related='company_id.currency_id',
|
||||||
|
string="Company currency", readonly=True)
|
||||||
type = fields.Selection(
|
type = fields.Selection(
|
||||||
related='parent_id.type', readonly=True)
|
related='parent_id.type',
|
||||||
|
string='Type',
|
||||||
|
readonly=True)
|
||||||
reporting_level = fields.Selection(
|
reporting_level = fields.Selection(
|
||||||
related='parent_id.reporting_level', readonly=True)
|
related='parent_id.reporting_level',
|
||||||
|
string='Reporting Level',
|
||||||
|
readonly=True)
|
||||||
valid = fields.Boolean(
|
valid = fields.Boolean(
|
||||||
compute='_check_validity',
|
compute='_compute_check_validity',
|
||||||
string='Valid')
|
string='Valid')
|
||||||
invoice_line_id = fields.Many2one(
|
invoice_line_id = fields.Many2one(
|
||||||
'account.invoice.line', string='Invoice Line', readonly=True)
|
'account.invoice.line', string='Invoice Line', readonly=True)
|
||||||
invoice_id = fields.Many2one(
|
invoice_id = fields.Many2one(
|
||||||
related='invoice_line_id.invoice_id', string='Invoice', readonly=True)
|
'account.invoice', related='invoice_line_id.invoice_id',
|
||||||
|
string='Invoice', readonly=True)
|
||||||
declaration_line_id = fields.Many2one(
|
declaration_line_id = fields.Many2one(
|
||||||
'intrastat.product.declaration.line',
|
'intrastat.product.declaration.line',
|
||||||
string='Declaration Line', readonly=True)
|
string='Declaration Line', readonly=True)
|
||||||
@@ -795,11 +849,12 @@ class IntrastatProductComputationLine(models.Model):
|
|||||||
help="Country of Origin/Destination",
|
help="Country of Origin/Destination",
|
||||||
domain=[('intrastat', '=', True)])
|
domain=[('intrastat', '=', True)])
|
||||||
product_id = fields.Many2one(
|
product_id = fields.Many2one(
|
||||||
related='invoice_line_id.product_id', readonly=True)
|
'product.product', related='invoice_line_id.product_id',
|
||||||
|
string='Product', readonly=True)
|
||||||
hs_code_id = fields.Many2one(
|
hs_code_id = fields.Many2one(
|
||||||
'hs.code', string='Intrastat Code')
|
'hs.code', string='Intrastat Code')
|
||||||
intrastat_unit_id = fields.Many2one(
|
intrastat_unit_id = fields.Many2one(
|
||||||
related='hs_code_id.intrastat_unit_id',
|
'intrastat.unit', related='hs_code_id.intrastat_unit_id',
|
||||||
string='Suppl. Unit', readonly=True,
|
string='Suppl. Unit', readonly=True,
|
||||||
help="Intrastat Supplementary Unit")
|
help="Intrastat Supplementary Unit")
|
||||||
weight = fields.Float(
|
weight = fields.Float(
|
||||||
@@ -838,7 +893,7 @@ class IntrastatProductComputationLine(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('transport_id')
|
@api.depends('transport_id')
|
||||||
def _check_validity(self):
|
def _compute_check_validity(self):
|
||||||
""" TO DO: logic based upon fields """
|
""" TO DO: logic based upon fields """
|
||||||
for this in self:
|
for this in self:
|
||||||
this.valid = True
|
this.valid = True
|
||||||
@@ -854,7 +909,7 @@ class IntrastatProductComputationLine(models.Model):
|
|||||||
self.intrastat_unit_id =\
|
self.intrastat_unit_id =\
|
||||||
self.product_id.intrastat_id.intrastat_unit_id
|
self.product_id.intrastat_id.intrastat_unit_id
|
||||||
if not self.intrastat_unit_id:
|
if not self.intrastat_unit_id:
|
||||||
self.weight = self.product_id.weight_net
|
self.weight = self.product_id.weight
|
||||||
|
|
||||||
|
|
||||||
class IntrastatProductDeclarationLine(models.Model):
|
class IntrastatProductDeclarationLine(models.Model):
|
||||||
@@ -866,12 +921,19 @@ class IntrastatProductDeclarationLine(models.Model):
|
|||||||
string='Intrastat Product Declaration',
|
string='Intrastat Product Declaration',
|
||||||
ondelete='cascade', readonly=True)
|
ondelete='cascade', readonly=True)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
related='parent_id.company_id', readonly=True)
|
'res.company', related='parent_id.company_id',
|
||||||
|
string="Company", readonly=True)
|
||||||
company_currency_id = fields.Many2one(
|
company_currency_id = fields.Many2one(
|
||||||
related='company_id.currency_id', readonly=True)
|
'res.currency', related='company_id.currency_id',
|
||||||
type = fields.Selection(related='parent_id.type', readonly=True)
|
string="Company currency", readonly=True)
|
||||||
|
type = fields.Selection(
|
||||||
|
related='parent_id.type',
|
||||||
|
string='Type',
|
||||||
|
readonly=True)
|
||||||
reporting_level = fields.Selection(
|
reporting_level = fields.Selection(
|
||||||
related='parent_id.reporting_level', readonly=True)
|
related='parent_id.reporting_level',
|
||||||
|
string='Reporting Level',
|
||||||
|
readonly=True)
|
||||||
computation_line_ids = fields.One2many(
|
computation_line_ids = fields.One2many(
|
||||||
'intrastat.product.computation.line', 'declaration_line_id',
|
'intrastat.product.computation.line', 'declaration_line_id',
|
||||||
string='Computation Lines', readonly=True)
|
string='Computation Lines', readonly=True)
|
||||||
@@ -910,40 +972,3 @@ class IntrastatProductDeclarationLine(models.Model):
|
|||||||
product_origin_country_id = fields.Many2one(
|
product_origin_country_id = fields.Many2one(
|
||||||
'res.country', string='Country of Origin of the Product',
|
'res.country', string='Country of Origin of the Product',
|
||||||
help="Country of origin of the product i.e. product 'made in ____'")
|
help="Country of origin of the product i.e. product 'made in ____'")
|
||||||
|
|
||||||
def _fields_to_sum(self):
|
|
||||||
"""
|
|
||||||
This method is DEPRECATED.
|
|
||||||
You should use the _fields_to_sum method on the
|
|
||||||
IntrastatProductDeclaration class.
|
|
||||||
"""
|
|
||||||
fields_to_sum = [
|
|
||||||
'weight',
|
|
||||||
'suppl_unit_qty',
|
|
||||||
]
|
|
||||||
return fields_to_sum
|
|
||||||
|
|
||||||
@api.model
|
|
||||||
def _prepare_declaration_line(self, computation_lines):
|
|
||||||
"""
|
|
||||||
This method is DEPRECATED.
|
|
||||||
You should use the _fields_to_sum method on the
|
|
||||||
IntrastatProductDeclaration class.
|
|
||||||
"""
|
|
||||||
fields_to_sum = self._fields_to_sum()
|
|
||||||
vals = self._prepare_grouped_fields(
|
|
||||||
computation_lines[0], fields_to_sum)
|
|
||||||
for computation_line in computation_lines:
|
|
||||||
for field in fields_to_sum:
|
|
||||||
vals[field] += computation_line[field]
|
|
||||||
vals['amount_company_currency'] += (
|
|
||||||
computation_line['amount_company_currency'] +
|
|
||||||
computation_line['amount_accessory_cost_company_currency'])
|
|
||||||
# round, otherwise odoo with truncate (6.7 -> 6... instead of 7 !)
|
|
||||||
for field in fields_to_sum:
|
|
||||||
vals[field] = int(round(vals[field]))
|
|
||||||
if not vals['weight']:
|
|
||||||
vals['weight'] = 1
|
|
||||||
vals['amount_company_currency'] = int(round(
|
|
||||||
vals['amount_company_currency']))
|
|
||||||
return vals
|
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2009-2018 Noviat nv/sa (www.noviat.com).
|
||||||
# © 2009-2017 Noviat nv/sa (www.noviat.com).
|
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class IntrastatRegion(models.Model):
|
class IntrastatRegion(models.Model):
|
||||||
_name = 'intrastat.region'
|
_name = 'intrastat.region'
|
||||||
_description = "Intrastat Region"
|
_description = "Intrastat Region"
|
||||||
|
|
||||||
code = fields.Char(string='Code', required=True)
|
|
||||||
country_id = fields.Many2one(
|
|
||||||
'res.country', string='Country', required=True)
|
|
||||||
name = fields.Char(string='Name', translate=True)
|
|
||||||
description = fields.Char(string='Description')
|
|
||||||
company_id = fields.Many2one(
|
|
||||||
'res.company', string='Company',
|
|
||||||
default=lambda self: self.env['res.company']._company_default_get())
|
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
('intrastat_region_code_unique',
|
('intrastat_region_code_unique',
|
||||||
'UNIQUE(code, country_id)', # TODO add company_id ?
|
'UNIQUE(code, country_id)', # TODO add company_id ?
|
||||||
'Code must be unique.')]
|
'Code must be unique.')]
|
||||||
|
|
||||||
|
code = fields.Char(string='Code', required=True)
|
||||||
|
country_id = fields.Many2one(
|
||||||
|
comodel_name='res.country',
|
||||||
|
string='Country', required=True)
|
||||||
|
name = fields.Char(string='Name', translate=True)
|
||||||
|
description = fields.Char(string='Description')
|
||||||
|
company_id = fields.Many2one(
|
||||||
|
comodel_name='res.company', string='Company',
|
||||||
|
default=lambda self: self.env['res.company']._company_default_get(
|
||||||
|
'intrastat.region'))
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class IntrastatTransaction(models.Model):
|
class IntrastatTransaction(models.Model):
|
||||||
@@ -12,6 +11,10 @@ class IntrastatTransaction(models.Model):
|
|||||||
_description = "Intrastat Transaction"
|
_description = "Intrastat Transaction"
|
||||||
_order = 'code'
|
_order = 'code'
|
||||||
_rec_name = 'display_name'
|
_rec_name = 'display_name'
|
||||||
|
_sql_constraints = [(
|
||||||
|
'intrastat_transaction_code_unique',
|
||||||
|
'UNIQUE(code, company_id)',
|
||||||
|
'Code must be unique.')]
|
||||||
|
|
||||||
code = fields.Char(string='Code', required=True)
|
code = fields.Char(string='Code', required=True)
|
||||||
description = fields.Text(string='Description')
|
description = fields.Text(string='Description')
|
||||||
@@ -19,8 +22,9 @@ class IntrastatTransaction(models.Model):
|
|||||||
compute='_compute_display_name_field', string="Display Name",
|
compute='_compute_display_name_field', string="Display Name",
|
||||||
readonly=True, store=True)
|
readonly=True, store=True)
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
'res.company', string='Company',
|
comodel_name='res.company', string='Company',
|
||||||
default=lambda self: self.env['res.company']._company_default_get())
|
default=lambda self: self.env['res.company']._company_default_get(
|
||||||
|
'intrastat.transaction'))
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('code', 'description')
|
@api.depends('code', 'description')
|
||||||
@@ -32,8 +36,3 @@ class IntrastatTransaction(models.Model):
|
|||||||
this.display_name = len(display_name) > 55 \
|
this.display_name = len(display_name) > 55 \
|
||||||
and display_name[:55] + '...' \
|
and display_name[:55] + '...' \
|
||||||
or display_name
|
or display_name
|
||||||
|
|
||||||
_sql_constraints = [(
|
|
||||||
'intrastat_transaction_code_unique',
|
|
||||||
'UNIQUE(code, company_id)',
|
|
||||||
'Code must be unique.')]
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2019 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class IntrastatTransportMode(models.Model):
|
class IntrastatTransportMode(models.Model):
|
||||||
@@ -12,9 +11,13 @@ class IntrastatTransportMode(models.Model):
|
|||||||
_description = "Intrastat Transport Mode"
|
_description = "Intrastat Transport Mode"
|
||||||
_rec_name = 'display_name'
|
_rec_name = 'display_name'
|
||||||
_order = 'code'
|
_order = 'code'
|
||||||
|
_sql_constraints = [(
|
||||||
|
'intrastat_transport_code_unique',
|
||||||
|
'UNIQUE(code)',
|
||||||
|
'Code must be unique.')]
|
||||||
|
|
||||||
display_name = fields.Char(
|
display_name = fields.Char(
|
||||||
string='Display Name', compute='_display_name', store=True,
|
string='Display Name', compute='_compute_display_name', store=True,
|
||||||
readonly=True)
|
readonly=True)
|
||||||
code = fields.Char(string='Code', required=True)
|
code = fields.Char(string='Code', required=True)
|
||||||
name = fields.Char(string='Name', required=True, translate=True)
|
name = fields.Char(string='Name', required=True, translate=True)
|
||||||
@@ -22,11 +25,6 @@ class IntrastatTransportMode(models.Model):
|
|||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
@api.depends('name', 'code')
|
@api.depends('name', 'code')
|
||||||
def _display_name(self):
|
def _compute_display_name(self):
|
||||||
for this in self:
|
for this in self:
|
||||||
this.display_name = '%s. %s' % (this.code, this.name)
|
this.display_name = '%s. %s' % (this.code, this.name)
|
||||||
|
|
||||||
_sql_constraints = [(
|
|
||||||
'intrastat_transport_code_unique',
|
|
||||||
'UNIQUE(code)',
|
|
||||||
'Code must be unique.')]
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class IntrastatUnit(models.Model):
|
class IntrastatUnit(models.Model):
|
||||||
@@ -14,7 +13,7 @@ class IntrastatUnit(models.Model):
|
|||||||
name = fields.Char(string='Name', required=True)
|
name = fields.Char(string='Name', required=True)
|
||||||
description = fields.Char(string='Description', required=True)
|
description = fields.Char(string='Description', required=True)
|
||||||
uom_id = fields.Many2one(
|
uom_id = fields.Many2one(
|
||||||
'product.uom', string='Regular UoM',
|
comodel_name='product.uom', string='Regular UoM',
|
||||||
help="Select the regular Unit of Measure of Odoo that corresponds "
|
help="Select the regular Unit of Measure of Odoo that corresponds "
|
||||||
"to this Intrastat Supplementary Unit.")
|
"to this Intrastat Supplementary Unit.")
|
||||||
active = fields.Boolean(string='Active', default=True)
|
active = fields.Boolean(default=True)
|
||||||
|
|||||||
@@ -1,47 +1,46 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2011-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2011-2017 Akretion (http://www.akretion.com)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# © 2009-2017 Noviat (http://www.noviat.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class ResCompany(models.Model):
|
class ResCompany(models.Model):
|
||||||
_inherit = 'res.company'
|
_inherit = 'res.company'
|
||||||
|
|
||||||
intrastat_incoterm_id = fields.Many2one(
|
intrastat_incoterm_id = fields.Many2one(
|
||||||
'stock.incoterms',
|
comodel_name='stock.incoterms',
|
||||||
string='Default Incoterm for Intrastat',
|
string='Default Incoterm for Intrastat',
|
||||||
help="International Commercial Terms are a series of "
|
help="International Commercial Terms are a series of "
|
||||||
"predefined commercial terms used in international "
|
"predefined commercial terms used in international "
|
||||||
"transactions.")
|
"transactions.")
|
||||||
intrastat_arrivals = fields.Selection(
|
intrastat_arrivals = fields.Selection(
|
||||||
'_intrastat_arrivals', string='Arrivals',
|
selection='_intrastat_arrivals', string='Arrivals',
|
||||||
default='extended', required=True)
|
default='extended', required=True)
|
||||||
intrastat_dispatches = fields.Selection(
|
intrastat_dispatches = fields.Selection(
|
||||||
'_intrastat_dispatches', string='Dispatches',
|
selection='_intrastat_dispatches', string='Dispatches',
|
||||||
default='extended', required=True)
|
default='extended', required=True)
|
||||||
intrastat_transport_id = fields.Many2one(
|
intrastat_transport_id = fields.Many2one(
|
||||||
'intrastat.transport_mode',
|
comodel_name='intrastat.transport_mode',
|
||||||
string='Default Transport Mode', ondelete='restrict')
|
string='Default Transport Mode', ondelete='restrict')
|
||||||
intrastat = fields.Char(
|
intrastat = fields.Char(
|
||||||
string='Intrastat Declaration', store=True, readonly=True,
|
string='Intrastat Declaration', store=True, readonly=True,
|
||||||
compute='_compute_intrastat')
|
compute='_compute_intrastat')
|
||||||
intrastat_region_id = fields.Many2one(
|
intrastat_region_id = fields.Many2one(
|
||||||
'intrastat.region',
|
comodel_name='intrastat.region',
|
||||||
string='Default Intrastat Region')
|
string='Default Intrastat Region')
|
||||||
intrastat_transaction_out_invoice = fields.Many2one(
|
intrastat_transaction_out_invoice = fields.Many2one(
|
||||||
'intrastat.transaction',
|
comodel_name='intrastat.transaction',
|
||||||
string='Default Intrastat Transaction For Customer Invoice')
|
string='Default Intrastat Transaction For Customer Invoice')
|
||||||
intrastat_transaction_out_refund = fields.Many2one(
|
intrastat_transaction_out_refund = fields.Many2one(
|
||||||
'intrastat.transaction',
|
comodel_name='intrastat.transaction',
|
||||||
string='Default Intrastat Transaction for Customer Refunds')
|
string='Default Intrastat Transaction for Customer Refunds')
|
||||||
intrastat_transaction_in_invoice = fields.Many2one(
|
intrastat_transaction_in_invoice = fields.Many2one(
|
||||||
'intrastat.transaction',
|
comodel_name='intrastat.transaction',
|
||||||
string='Default Intrastat Transaction For Supplier Invoices')
|
string='Default Intrastat Transaction For Supplier Invoices')
|
||||||
intrastat_transaction_in_refund = fields.Many2one(
|
intrastat_transaction_in_refund = fields.Many2one(
|
||||||
'intrastat.transaction',
|
comodel_name='intrastat.transaction',
|
||||||
string='Default Intrastat Transaction For Supplier Refunds')
|
string='Default Intrastat Transaction For Supplier Refunds')
|
||||||
intrastat_accessory_costs = fields.Boolean(
|
intrastat_accessory_costs = fields.Boolean(
|
||||||
string='Include Accessory Costs in Fiscal Value of Product')
|
string='Include Accessory Costs in Fiscal Value of Product')
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
# Copyright 2009-2018 Noviat (http://www.noviat.com)
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import models, fields
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class ResConfigSettings(models.TransientModel):
|
class ResConfigSettings(models.TransientModel):
|
||||||
@@ -29,3 +29,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
related='company_id.intrastat_transaction_in_refund')
|
related='company_id.intrastat_transaction_in_refund')
|
||||||
intrastat_accessory_costs = fields.Boolean(
|
intrastat_accessory_costs = fields.Boolean(
|
||||||
related='company_id.intrastat_accessory_costs')
|
related='company_id.intrastat_accessory_costs')
|
||||||
|
country_id = fields.Many2one(
|
||||||
|
related='company_id.country_id', readonly=True)
|
||||||
|
country_code = fields.Char(
|
||||||
|
related='company_id.country_id.code', readonly=True)
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2010-2017 Akretion (http://www.akretion.com)
|
||||||
# © 2010-2017 Akretion (http://www.akretion.com)
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class SaleOrder(models.Model):
|
class SaleOrder(models.Model):
|
||||||
_inherit = "sale.order"
|
_inherit = "sale.order"
|
||||||
|
|
||||||
intrastat_transport_id = fields.Many2one(
|
intrastat_transport_id = fields.Many2one(
|
||||||
'intrastat.transport_mode', string='Transport Mode',
|
comodel_name='intrastat.transport_mode', string='Transport Mode',
|
||||||
help="This information is used in Intrastat reports")
|
help="This information is used in Intrastat reports")
|
||||||
intrastat = fields.Selection(
|
intrastat = fields.Selection(
|
||||||
string='Intrastat Declaration',
|
string='Intrastat Declaration',
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2009-2018 Noviat nv/sa (www.noviat.com).
|
||||||
# © 2009-2017 Noviat nv/sa (www.noviat.com).
|
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# @author Luc de Meyer <info@noviat.com>
|
# @author Luc de Meyer <info@noviat.com>
|
||||||
|
|
||||||
from odoo import models, fields, api
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
class StockWarehouse(models.Model):
|
class StockWarehouse(models.Model):
|
||||||
_inherit = 'stock.warehouse'
|
_inherit = 'stock.warehouse'
|
||||||
|
|
||||||
region_id = fields.Many2one('intrastat.region', string='Intrastat Region')
|
region_id = fields.Many2one(
|
||||||
|
comodel_name='intrastat.region', string='Intrastat Region')
|
||||||
|
|
||||||
|
|
||||||
class StockLocation(models.Model):
|
class StockLocation(models.Model):
|
||||||
|
|||||||
1
intrastat_product/report/__init__.py
Normal file
1
intrastat_product/report/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import intrastat_product_report_xls
|
||||||
276
intrastat_product/report/intrastat_product_report_xls.py
Normal file
276
intrastat_product/report/intrastat_product_report_xls.py
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
# Copyright 2009-2018 Noviat
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
from odoo.tools.translate import translate, _
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
IR_TRANSLATION_NAME = 'intrastat.product.report'
|
||||||
|
|
||||||
|
|
||||||
|
class IntrastatProductDeclarationXlsx(models.AbstractModel):
|
||||||
|
_name = 'report.intrastat_product.product_declaration_xls'
|
||||||
|
_inherit = 'report.report_xlsx.abstract'
|
||||||
|
|
||||||
|
def _(self, src):
|
||||||
|
lang = self.env.context.get('lang', 'en_US')
|
||||||
|
val = translate(
|
||||||
|
self.env.cr, IR_TRANSLATION_NAME, 'report', lang, src) or src
|
||||||
|
return val
|
||||||
|
|
||||||
|
def _get_template(self, declaration):
|
||||||
|
|
||||||
|
template = {
|
||||||
|
'product': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Product'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render(
|
||||||
|
"line.product_id and line.product_id.name"),
|
||||||
|
},
|
||||||
|
'width': 36,
|
||||||
|
},
|
||||||
|
'product_origin_country': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Product C/O'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._render(
|
||||||
|
"line.product_origin_country_id.name or ''"),
|
||||||
|
},
|
||||||
|
'width': 28,
|
||||||
|
},
|
||||||
|
'hs_code': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Intrastat Code'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._render(
|
||||||
|
"line.hs_code_id.local_code"),
|
||||||
|
},
|
||||||
|
'width': 14,
|
||||||
|
},
|
||||||
|
'src_dest_country': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Country of Origin/Destination'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._render(
|
||||||
|
"line.src_dest_country_id.name"),
|
||||||
|
},
|
||||||
|
'width': 28,
|
||||||
|
},
|
||||||
|
'amount_company_currency': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Fiscal Value'),
|
||||||
|
'format': self.format_theader_yellow_right,
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'number',
|
||||||
|
'value': self._render("line.amount_company_currency"),
|
||||||
|
'format': self.format_tcell_amount_right,
|
||||||
|
},
|
||||||
|
'width': 18,
|
||||||
|
},
|
||||||
|
'accessory_cost': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Accessory Costs'),
|
||||||
|
'format': self.format_theader_yellow_right,
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'number',
|
||||||
|
'value': self._render(
|
||||||
|
"line.amount_accessory_cost_company_currency"),
|
||||||
|
'format': self.format_tcell_amount_right,
|
||||||
|
},
|
||||||
|
'width': 18,
|
||||||
|
},
|
||||||
|
'transaction': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Intrastat Transaction'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render(
|
||||||
|
"line.transaction_id.display_name"),
|
||||||
|
},
|
||||||
|
'width': 36,
|
||||||
|
},
|
||||||
|
'weight': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Weight'),
|
||||||
|
'format': self.format_theader_yellow_right,
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'type': 'number',
|
||||||
|
'value': self._render(
|
||||||
|
"line.weight"),
|
||||||
|
'format': self.format_tcell_amount_right,
|
||||||
|
},
|
||||||
|
'width': 18,
|
||||||
|
},
|
||||||
|
'suppl_unit_qty': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Suppl. Unit Qty'),
|
||||||
|
'format': self.format_theader_yellow_right,
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
# we don't specify a type here and rely on the
|
||||||
|
# report_xlsx_helper type detection to use
|
||||||
|
# write_string when suppl_unit_qty is zero
|
||||||
|
'value': self._render(
|
||||||
|
"line.suppl_unit_qty or ''"),
|
||||||
|
'format': self.format_tcell_amount_right,
|
||||||
|
},
|
||||||
|
'width': 18,
|
||||||
|
},
|
||||||
|
'suppl_unit': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Suppl. Unit'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render(
|
||||||
|
"line.intrastat_unit_id.name or ''"),
|
||||||
|
},
|
||||||
|
'width': 14,
|
||||||
|
},
|
||||||
|
'incoterm': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Incoterm'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render("line.incoterm_id.name or ''"),
|
||||||
|
},
|
||||||
|
'width': 14,
|
||||||
|
},
|
||||||
|
'transport': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Transport Mode'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render("line.transport_id.name or ''"),
|
||||||
|
},
|
||||||
|
'width': 14,
|
||||||
|
},
|
||||||
|
'region': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Intrastat Region'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render("line.region_id.name or ''"),
|
||||||
|
},
|
||||||
|
'width': 28,
|
||||||
|
},
|
||||||
|
'invoice': {
|
||||||
|
'header': {
|
||||||
|
'type': 'string',
|
||||||
|
'value': self._('Invoice'),
|
||||||
|
},
|
||||||
|
'line': {
|
||||||
|
'value': self._render("line.invoice_id.number"),
|
||||||
|
},
|
||||||
|
'width': 18,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
template.update(declaration._xls_template())
|
||||||
|
|
||||||
|
return template
|
||||||
|
|
||||||
|
def _get_ws_params(self, wb, data, declaration):
|
||||||
|
template = self._get_template(declaration)
|
||||||
|
if self.env.context.get('computation_lines'):
|
||||||
|
wl = declaration._xls_computation_line_fields()
|
||||||
|
report = 'computation'
|
||||||
|
else:
|
||||||
|
wl = declaration._xls_declaration_line_fields()
|
||||||
|
report = 'declaration'
|
||||||
|
|
||||||
|
title = self._get_title(declaration, report, format='normal')
|
||||||
|
title_short = self._get_title(declaration, report, format='short')
|
||||||
|
sheet_name = title_short[:31].replace('/', '-')
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'ws_name': sheet_name,
|
||||||
|
'generate_ws_method': '_intrastat_report',
|
||||||
|
'title': title,
|
||||||
|
'wanted_list': wl,
|
||||||
|
'col_specs': template,
|
||||||
|
}
|
||||||
|
return [params]
|
||||||
|
|
||||||
|
def _get_title(self, declaration, report, format='normal'):
|
||||||
|
title = declaration.year_month
|
||||||
|
if format == 'normal':
|
||||||
|
if report == 'computation':
|
||||||
|
title += ' : ' + _('Computation Lines')
|
||||||
|
else:
|
||||||
|
title += ' : ' + _('Declaration Lines')
|
||||||
|
return title
|
||||||
|
|
||||||
|
def _report_title(self, ws, row_pos, ws_params, data, declaration):
|
||||||
|
return self._write_ws_title(ws, row_pos, ws_params)
|
||||||
|
|
||||||
|
def _empty_report(self, ws, row_pos, ws_params, data, declaration,
|
||||||
|
report):
|
||||||
|
if report == 'computation':
|
||||||
|
lines = _('Computation Lines')
|
||||||
|
else:
|
||||||
|
lines = _('Declaration Lines')
|
||||||
|
no_entries = _("No") + " " + lines + " " + _("for period %s") \
|
||||||
|
% declaration.year_month
|
||||||
|
ws.write_string(row_pos, 0, no_entries, self.format_left_bold)
|
||||||
|
|
||||||
|
def _intrastat_report(self, workbook, ws, ws_params, data, declaration):
|
||||||
|
|
||||||
|
ws.set_landscape()
|
||||||
|
ws.fit_to_pages(1, 0)
|
||||||
|
ws.set_header(self.xls_headers['standard'])
|
||||||
|
ws.set_footer(self.xls_footers['standard'])
|
||||||
|
|
||||||
|
self._set_column_width(ws, ws_params)
|
||||||
|
|
||||||
|
row_pos = 0
|
||||||
|
row_pos = self._report_title(ws, row_pos, ws_params, data, declaration)
|
||||||
|
|
||||||
|
if self.env.context.get('computation_lines'):
|
||||||
|
report = 'computation'
|
||||||
|
lines = declaration.computation_line_ids
|
||||||
|
else:
|
||||||
|
report = 'declaration'
|
||||||
|
lines = declaration.declaration_line_ids
|
||||||
|
|
||||||
|
if not lines:
|
||||||
|
return self._empty_report(
|
||||||
|
ws, row_pos, ws_params, data, declaration, report)
|
||||||
|
|
||||||
|
row_pos = self._write_line(
|
||||||
|
ws, row_pos, ws_params, col_specs_section='header',
|
||||||
|
default_format=self.format_theader_yellow_left)
|
||||||
|
|
||||||
|
ws.freeze_panes(row_pos, 0)
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
row_pos = self._write_line(
|
||||||
|
ws, row_pos, ws_params, col_specs_section='line',
|
||||||
|
render_space={'line': line},
|
||||||
|
default_format=self.format_tcell_left)
|
||||||
BIN
intrastat_product/static/description/icon.png
Normal file
BIN
intrastat_product/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -17,7 +17,8 @@
|
|||||||
<button name="generate_xml"
|
<button name="generate_xml"
|
||||||
string="Generate XML Declaration File"
|
string="Generate XML Declaration File"
|
||||||
type="object"
|
type="object"
|
||||||
attrs="{'invisible': [('state', '!=', 'draft')]}"/>
|
attrs="{'invisible': [('state', '!=', 'draft')]}"
|
||||||
|
invisible="context.get('generic_intrastat_product_declaration')"/>
|
||||||
<button name="done" string="Done" type="object" class="oe_highlight" states="draft"/>
|
<button name="done" string="Done" type="object" class="oe_highlight" states="draft"/>
|
||||||
<button name="back2draft" string="Back to Draft" type="object" states="done"/>
|
<button name="back2draft" string="Back to Draft" type="object" states="done"/>
|
||||||
<field name="state" widget="statusbar"/>
|
<field name="state" widget="statusbar"/>
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
<sheet string="Intrastat Product Declaration">
|
<sheet string="Intrastat Product Declaration">
|
||||||
<div class="oe_title">
|
<div class="oe_title">
|
||||||
<h1>
|
<h1>
|
||||||
<label string="Intrastat Product Declaration"/>
|
<span>Intrastat Product Declaration </span>
|
||||||
<field name="year_month" class="oe_inline"/>
|
<field name="year_month" class="oe_inline"/>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -48,13 +49,25 @@
|
|||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
<page string="Transactions">
|
<page string="Transactions">
|
||||||
|
<header>
|
||||||
|
<button name="create_xls" type="object" string="Excel Export"
|
||||||
|
context="{'computation_lines': 1}"/>
|
||||||
|
</header>
|
||||||
<group name="computation_lines">
|
<group name="computation_lines">
|
||||||
<field name="computation_line_ids" nolabel="1"/>
|
<field name="computation_line_ids"
|
||||||
|
context="{'type': type, 'reporting_level': reporting_level}"
|
||||||
|
nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Declaration Lines">
|
<page string="Declaration Lines">
|
||||||
|
<header>
|
||||||
|
<button name="create_xls" type="object" string="Excel Export"
|
||||||
|
context="{'declaration_lines': 1}"/>
|
||||||
|
</header>
|
||||||
<group name="declaration_lines">
|
<group name="declaration_lines">
|
||||||
<field name="declaration_line_ids" nolabel="1"/>
|
<field name="declaration_line_ids"
|
||||||
|
context="{'type': type, 'reporting_level': reporting_level}"
|
||||||
|
nolabel="1"/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
<page string="Notes">
|
<page string="Notes">
|
||||||
@@ -79,7 +92,7 @@
|
|||||||
<field name="revision"/>
|
<field name="revision"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
<field name="num_decl_lines"/>
|
<field name="num_decl_lines"/>
|
||||||
<field name="total_amount" sum="1"/>
|
<field name="total_amount" sum="Total amount"/>
|
||||||
<field name="currency_id"/>
|
<field name="currency_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</tree>
|
</tree>
|
||||||
@@ -143,6 +156,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<field name="suppl_unit_qty"/>
|
<field name="suppl_unit_qty"/>
|
||||||
<field name="intrastat_unit_id"/>
|
<field name="intrastat_unit_id"/>
|
||||||
|
<field name="type" invisible="1"/>
|
||||||
<field name="reporting_level" invisible="1"/>
|
<field name="reporting_level" invisible="1"/>
|
||||||
<field name="transport_id"
|
<field name="transport_id"
|
||||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||||
@@ -168,10 +182,10 @@
|
|||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="hs_code_id"/>
|
<field name="hs_code_id"/>
|
||||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||||
<field name="amount_company_currency" sum="1"/>
|
<field name="amount_company_currency"/>
|
||||||
<field name="amount_accessory_cost_company_currency" sum="1"/>
|
<field name="amount_accessory_cost_company_currency"/>
|
||||||
<field name="transaction_id"/>
|
<field name="transaction_id"/>
|
||||||
<field name="weight" sum="1"/>
|
<field name="weight"/>
|
||||||
<field name="suppl_unit_qty"
|
<field name="suppl_unit_qty"
|
||||||
attrs="{'invisible': [('intrastat_unit_id', '=', False)], 'required': [('intrastat_unit_id', '!=', False)]}"/>
|
attrs="{'invisible': [('intrastat_unit_id', '=', False)], 'required': [('intrastat_unit_id', '!=', False)]}"/>
|
||||||
<field name="intrastat_unit_id"/>
|
<field name="intrastat_unit_id"/>
|
||||||
@@ -180,6 +194,7 @@
|
|||||||
<field name="region_id" invisible="1"/>
|
<field name="region_id" invisible="1"/>
|
||||||
<field name="product_origin_country_id" invisible="1" string="Product C/O"/>
|
<field name="product_origin_country_id" invisible="1" string="Product C/O"/>
|
||||||
<field name="invoice_id"/>
|
<field name="invoice_id"/>
|
||||||
|
<field name="type" invisible="1"/>
|
||||||
<field name="reporting_level" invisible="1"/>
|
<field name="reporting_level" invisible="1"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
@@ -207,6 +222,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<field name="suppl_unit_qty"/>
|
<field name="suppl_unit_qty"/>
|
||||||
<field name="intrastat_unit_id"/>
|
<field name="intrastat_unit_id"/>
|
||||||
|
<field name="type" invisible="1"/>
|
||||||
<field name="reporting_level" invisible="1"/>
|
<field name="reporting_level" invisible="1"/>
|
||||||
<field name="transport_id"
|
<field name="transport_id"
|
||||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||||
@@ -230,11 +246,12 @@
|
|||||||
invisible="not context.get('intrastat_product_declaration_line_main_view')"/>
|
invisible="not context.get('intrastat_product_declaration_line_main_view')"/>
|
||||||
<field name="hs_code_id"/>
|
<field name="hs_code_id"/>
|
||||||
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
<field name="src_dest_country_id" domain="[('intrastat', '=', True)]"/>
|
||||||
<field name="amount_company_currency" sum="1"/>
|
<field name="amount_company_currency"/>
|
||||||
<field name="transaction_id"/>
|
<field name="transaction_id"/>
|
||||||
<field name="weight" sum="1"/>
|
<field name="weight"/>
|
||||||
<field name="suppl_unit_qty"/>
|
<field name="suppl_unit_qty"/>
|
||||||
<field name="intrastat_unit_id"/>
|
<field name="intrastat_unit_id"/>
|
||||||
|
<field name="type" invisible="1"/>
|
||||||
<field name="reporting_level" invisible="1"/>
|
<field name="reporting_level" invisible="1"/>
|
||||||
<field name="transport_id"
|
<field name="transport_id"
|
||||||
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
attrs="{'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}"/>
|
||||||
|
|||||||
@@ -1,62 +1,82 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!--
|
<!--
|
||||||
© 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
|
© 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
|
||||||
|
© 2019 Noviat (www.noviat.com)
|
||||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_res_config_settings" model="ir.ui.view">
|
<record id="view_res_config_settings" model="ir.ui.view">
|
||||||
<field name="name">intrastat.account.config.settings.form</field>
|
<field name="name">intrastat.account.config.settings.form</field>
|
||||||
<field name="model">res.config.settings</field>
|
<field name="model">res.config.settings</field>
|
||||||
<field name="inherit_id" ref="intrastat_base.view_intrastat_res_config_settings"/>
|
<field name="inherit_id" ref="intrastat_base.view_intrastat_res_config_settings"/>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
|
||||||
|
<xpath expr="//div[@id='intrastat']" position="after">
|
||||||
|
|
||||||
<div id="intrastat_content_grp" position="inside">
|
<field name="country_id" invisible="1"/>
|
||||||
<div class="row mt16">
|
<field name="country_code" invisible="1"/>
|
||||||
<label for="intrastat_arrivals" class="col-md-5 o_light_label"/>
|
|
||||||
<field name="intrastat_arrivals"/>
|
<div class="row mt16 o_settings_container" id="intrastat-product">
|
||||||
</div>
|
|
||||||
<div class="row mt16">
|
<div class="col-xs-12 col-md-12 o_setting_box">
|
||||||
<label for="intrastat_dispatches" class="col-md-5 o_light_label"/>
|
<div class="o_setting_left_pane"/>
|
||||||
<field name="intrastat_dispatches"/>
|
<div class="o_setting_right_pane">
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_arrivals" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_transport_id" class="col-md-5 o_light_label"/>
|
<field name="intrastat_arrivals"/>
|
||||||
<field name="intrastat_transport_id"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_dispatches" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_incoterm_id" class="col-md-5 o_light_label"/>
|
<field name="intrastat_dispatches"/>
|
||||||
<field name="intrastat_incoterm_id"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_transport_id" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_transaction_out_invoice" class="col-md-5 o_light_label"/>
|
<field name="intrastat_transport_id"/>
|
||||||
<field name="intrastat_transaction_out_invoice"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_incoterm_id" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_transaction_out_refund" class="col-md-5 o_light_label"/>
|
<field name="intrastat_incoterm_id"/>
|
||||||
<field name="intrastat_transaction_out_refund"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_transaction_out_invoice" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_transaction_in_invoice" class="col-md-5 o_light_label"/>
|
<field name="intrastat_transaction_out_invoice"/>
|
||||||
<field name="intrastat_transaction_in_invoice"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16">
|
<label for="intrastat_transaction_out_refund" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_transaction_in_refund" class="col-md-5 o_light_label"/>
|
<field name="intrastat_transaction_out_refund"/>
|
||||||
<field name="intrastat_transaction_in_refund"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div id="intrastat_accessory_costs" class="row mt16" invisible="1">
|
<label for="intrastat_transaction_in_invoice" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_accessory_costs" class="col-md-5 o_light_label"/>
|
<field name="intrastat_transaction_in_invoice"/>
|
||||||
<field name="intrastat_accessory_costs"/>
|
</div>
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="row mt16" id="intrastat_region" invisible="1">
|
<label for="intrastat_transaction_in_refund" class="col-md-5 o_light_label"/>
|
||||||
<label for="intrastat_region_id" class="col-md-5 o_light_label"/>
|
<field name="intrastat_transaction_in_refund"/>
|
||||||
<field name="intrastat_region_id"/>
|
</div>
|
||||||
</div>
|
<div class="row" attrs="{'invisible': [('country_code', 'not in', ['BE'])]}">
|
||||||
|
<label for="intrastat_region_id" class="col-md-5 o_light_label"/>
|
||||||
|
<field name="intrastat_region_id" domain="[('country_id','=', country_id)]"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="o_setting_left_pane">
|
||||||
|
<field name="intrastat_accessory_costs"
|
||||||
|
attrs="{'invisible': [('country_code', 'in', ['BE'])]}"/>
|
||||||
|
</div>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<div class="row">
|
||||||
|
<label for="intrastat_accessory_costs" class="col-md-12 o_light_label"
|
||||||
|
attrs="{'invisible': [('country_code', 'in', ['BE'])]}"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</field>
|
</div>
|
||||||
</record>
|
</div>
|
||||||
|
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user