[MIG] intrastat_product: Migration to 14.0

Rename field type to declaration_type
Use the new intrastat boolean of fiscal position, following issue #110

Co-authored-by: Alexis de Lattre <alexis.delattre@akretion.com>
This commit is contained in:
João Marques
2021-02-08 14:31:59 +00:00
parent 384cf4951c
commit 2d290b6700
26 changed files with 294 additions and 357 deletions

View File

@@ -14,13 +14,13 @@ Intrastat Product
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github
:target: https://github.com/OCA/intrastat-extrastat/tree/13.0/intrastat_product :target: https://github.com/OCA/intrastat-extrastat/tree/14.0/intrastat_product
:alt: OCA/intrastat-extrastat :alt: OCA/intrastat-extrastat
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/intrastat-extrastat-13-0/intrastat-extrastat-13-0-intrastat_product :target: https://translation.odoo-community.org/projects/intrastat-extrastat-14-0/intrastat-extrastat-14-0-intrastat_product
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/227/13.0 :target: https://runbot.odoo-community.org/runbot/227/14.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -115,7 +115,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/intrastat-extrastat/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/intrastat-extrastat/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/intrastat-extrastat/issues/new?body=module:%20intrastat_product%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/intrastat-extrastat/issues/new?body=module:%20intrastat_product%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@@ -134,6 +134,9 @@ Contributors
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com> * Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
* Luc De Meyer, Noviat <info@noviat.com> * Luc De Meyer, Noviat <info@noviat.com>
* Tecnativa <www.tecnativa.com>:
* João Marques
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -148,6 +151,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/intrastat-extrastat <https://github.com/OCA/intrastat-extrastat/tree/13.0/intrastat_product>`_ project on GitHub. This module is part of the `OCA/intrastat-extrastat <https://github.com/OCA/intrastat-extrastat/tree/14.0/intrastat_product>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -1,17 +1,18 @@
# Copyright 2011-2017 Akretion (http://www.akretion.com) # Copyright 2011-2020 Akretion (http://www.akretion.com)
# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2009-2020 Noviat (http://www.noviat.com)
# Copyright 2018 brain-tec AG (http://www.braintec-group.com) # Copyright 2018-2020 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": "13.0.1.1.2", "version": "14.0.1.0.0",
"category": "Intrastat", "category": "Intrastat",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Base module for Intrastat Product", "summary": "Base module for Intrastat Product",
"author": "brain-tec AG, Akretion, Noviat, Odoo Community Association (OCA)", "author": "brain-tec AG, Akretion, Noviat, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/intrastat-extrastat",
"depends": [ "depends": [
"intrastat_base", "intrastat_base",
"product_harmonized_system", "product_harmonized_system",

View File

@@ -14,7 +14,7 @@
<record id="base.main_company" model="res.company"> <record id="base.main_company" model="res.company">
<field name="intrastat_arrivals">extended</field> <field name="intrastat_arrivals">extended</field>
<field name="intrastat_dispatches">extended</field> <field name="intrastat_dispatches">extended</field>
<field name="incoterm_id" ref="account.incoterm_DDU" /> <field name="incoterm_id" ref="account.incoterm_DAP" />
<field name="intrastat_transport_id" ref="intrastat_transport_3" /> <field name="intrastat_transport_id" ref="intrastat_transport_3" />
</record> </record>
</odoo> </odoo>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="intrastat_transaction_company_rule" model="ir.rule">
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
<record id="intrastat_region_company_rule" model="ir.rule">
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
<record id="intrastat_product_declaration_company_rule" model="ir.rule">
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
</record>
</odoo>

View File

@@ -1,62 +0,0 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade # pylint: disable=W7936
_months = [
(1, "01"),
(2, "02"),
(3, "03"),
(4, "04"),
(5, "05"),
(6, "06"),
(7, "07"),
(8, "08"),
(9, "09"),
(10, "10"),
(11, "11"),
(12, "12"),
]
def map_intrastat_product_declaration_month(env):
openupgrade.map_values(
env.cr,
openupgrade.get_legacy_name("month"),
"month",
_months,
table="intrastat_product_declaration",
)
def update_invoice_relation_fields(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE account_move am
SET (intrastat_transaction_id, intrastat_transport_id,
src_dest_country_id, intrastat_country, src_dest_region_id
) = (ai.intrastat_transaction_id,
ai.intrastat_transport_id, ai.src_dest_country_id,
ai.intrastat_country, ai.src_dest_region_id)
FROM account_invoice ai
WHERE am.old_invoice_id = ai.id""",
)
openupgrade.logged_query(
env.cr,
"""
UPDATE intrastat_product_computation_line ipcl
SET invoice_line_id = aml.id
FROM account_invoice_line ail
JOIN account_move_line aml ON aml.old_invoice_line_id = ail.id
WHERE ipcl.%(old_line_id)s = ail.id"""
% {"old_line_id": openupgrade.get_legacy_name("invoice_line_id")},
)
@openupgrade.migrate()
def migrate(env, version):
map_intrastat_product_declaration_month(env)
update_invoice_relation_fields(env)
openupgrade.load_data(
env.cr, "intrastat_product", "migrations/13.0.1.0.3/noupdate_changes.xml"
)

View File

@@ -1,13 +0,0 @@
# Copyright 2020 ForgeFlow <http://www.forgeflow.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade
_column_renames = {
"intrastat_product_declaration": [("month", None)],
"intrastat_product_computation_line": [("invoice_line_id", None)],
}
@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _column_renames)

View File

@@ -0,0 +1,13 @@
# Copyright 2020 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
def migrate(cr, version):
if not version:
return
cr.execute(
'ALTER TABLE "intrastat_product_declaration" RENAME "type" '
'TO "declaration_type"'
)

View File

@@ -1,4 +1,4 @@
# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2011-2020 Akretion France (http://www.akretion.com)
# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2009-2020 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>
@@ -14,6 +14,7 @@ class AccountMove(models.Model):
string="Intrastat Transaction Type", string="Intrastat Transaction Type",
ondelete="restrict", ondelete="restrict",
tracking=True, tracking=True,
check_company=True,
help="Intrastat nature of transaction", help="Intrastat nature of transaction",
) )
intrastat_transport_id = fields.Many2one( intrastat_transport_id = fields.Many2one(
@@ -26,14 +27,12 @@ class AccountMove(models.Model):
string="Origin/Destination 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 " "arrivals.", help="Destination country for dispatches. Origin country for " "arrivals.",
) )
intrastat_country = fields.Boolean( intrastat_country = fields.Boolean(
compute="_compute_intrastat_country", compute="_compute_intrastat_country",
string="Intrastat Country", string="Intrastat Country",
store=True, store=True,
compute_sudo=True,
) )
src_dest_region_id = fields.Many2one( src_dest_region_id = fields.Many2one(
comodel_name="intrastat.region", comodel_name="intrastat.region",
@@ -106,7 +105,9 @@ class AccountMoveLine(models.Model):
_inherit = "account.move.line" _inherit = "account.move.line"
hs_code_id = fields.Many2one( hs_code_id = fields.Many2one(
comodel_name="hs.code", compute="_compute_hs_code_id", string="Intrastat Code", comodel_name="hs.code",
compute="_compute_hs_code_id",
string="Intrastat Code",
) )
def _compute_hs_code_id(self): def _compute_hs_code_id(self):

View File

@@ -1,5 +1,5 @@
# Copyright 2011-2017 Akretion (http://www.akretion.com) # Copyright 2011-2020 Akretion (http://www.akretion.com)
# Copyright 2009-2018 Noviat (http://www.noviat.com) # Copyright 2009-2020 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>

View File

@@ -1,15 +1,16 @@
# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2011-2020 Akretion France (http://www.akretion.com)
# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2009-2020 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>
import logging import logging
from datetime import date, datetime from datetime import date
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from odoo import _, api, fields, models from odoo import _, api, fields, models
from odoo.exceptions import RedirectWarning, UserError, ValidationError from odoo.exceptions import RedirectWarning, UserError, ValidationError
from odoo.tools import float_is_zero
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -19,35 +20,31 @@ class IntrastatProductDeclaration(models.Model):
_description = "Intrastat Product Report Base Object" _description = "Intrastat Product Report Base Object"
_rec_name = "year_month" _rec_name = "year_month"
_inherit = ["mail.thread", "mail.activity.mixin", "intrastat.common"] _inherit = ["mail.thread", "mail.activity.mixin", "intrastat.common"]
_order = "year_month desc, type, revision" _order = "year_month desc, declaration_type, revision"
_sql_constraints = [ _sql_constraints = [
( (
"date_uniq", "date_uniq",
"unique(year_month, company_id, type, revision)", "unique(year_month, company_id, declaration_type, revision)",
"A declaration of the same type already exists for this month !" "A declaration of the same type already exists for this month !"
"\nYou should update the existing declaration " "\nYou should update the existing declaration "
"or change the revision number of this one.", "or change the revision number of this one.",
) )
] ]
# TODO:
# drop the use of self._note & self._line_nbr when migrating to Odoo 14
# refactoring this now may break the localisation modules
_note = ""
_line_nbr = ""
@api.model @api.model
def default_get(self, fields_list): def default_get(self, fields_list):
res = super().default_get(fields_list) res = super().default_get(fields_list)
decl_date = fields.Date.context_today(self) - relativedelta(months=1) decl_date = fields.Date.context_today(self) - relativedelta(months=1)
res.update( res.update(
{"year": str(decl_date.year), "month": str(decl_date.month).rjust(2, "0")} {"year": str(decl_date.year), "month": str(decl_date.month).zfill(2)}
) )
return res return res
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name="res.company", comodel_name="res.company",
string="Company", string="Company",
readonly=True, required=True,
states={"done": [("readonly", True)]},
default=lambda self: self._default_company_id(), default=lambda self: self._default_company_id(),
) )
company_country_code = fields.Char( company_country_code = fields.Char(
@@ -87,13 +84,12 @@ class IntrastatProductDeclaration(models.Model):
store=True, store=True,
help="Year and month of the declaration.", help="Year and month of the declaration.",
) )
type = fields.Selection( declaration_type = fields.Selection(
selection="_get_type", selection="_get_declaration_type",
string="Type", string="Type",
required=True, required=True,
states={"done": [("readonly", True)]}, states={"done": [("readonly", True)]},
tracking=True, tracking=True,
help="Select the declaration type.",
) )
action = fields.Selection( action = fields.Selection(
selection="_get_action", selection="_get_action",
@@ -155,16 +151,22 @@ class IntrastatProductDeclaration(models.Model):
states={"done": [("readonly", True)]}, states={"done": [("readonly", True)]},
) )
valid = fields.Boolean(compute="_compute_check_validity", string="Valid") valid = fields.Boolean(compute="_compute_check_validity", string="Valid")
xml_attachment_id = fields.Many2one("ir.attachment", string="XML Export") xml_attachment_id = fields.Many2one("ir.attachment", string="XML Attachment")
xml_attachment_datas = fields.Binary(
related="xml_attachment_id.datas", string="XML Export"
)
xml_attachment_name = fields.Char(
related="xml_attachment_id.name", string="XML Filename"
)
@api.model @api.model
def _default_company_id(self): def _default_company_id(self):
return self.env.company return self.env.company
@api.model @api.model
def _get_type(self): def _get_declaration_type(self):
res = [] res = []
company = self.env.user.company_id company = self.env.company
arrivals = company.intrastat_arrivals arrivals = company.intrastat_arrivals
dispatches = company.intrastat_dispatches dispatches = company.intrastat_dispatches
if arrivals != "exempt": if arrivals != "exempt":
@@ -212,15 +214,15 @@ class IntrastatProductDeclaration(models.Model):
if len(this.year) != 4 or this.year[0] != "2": if len(this.year) != 4 or this.year[0] != "2":
raise ValidationError(_("Invalid Year !")) raise ValidationError(_("Invalid Year !"))
@api.onchange("type") @api.onchange("declaration_type")
def _onchange_type(self): def _onchange_declaration_type(self):
if self.type == "arrivals": if self.declaration_type == "arrivals":
self.reporting_level = ( self.reporting_level = (
self.company_id.intrastat_arrivals == "extended" self.company_id.intrastat_arrivals == "extended"
and "extended" and "extended"
or "standard" or "standard"
) )
if self.type == "dispatches": if self.declaration_type == "dispatches":
self.reporting_level = ( self.reporting_level = (
self.company_id.intrastat_dispatches == "extended" self.company_id.intrastat_dispatches == "extended"
and "extended" and "extended"
@@ -239,7 +241,7 @@ class IntrastatProductDeclaration(models.Model):
msg, action.id, _("Go to Accounting Configuration Settings screen") msg, action.id, _("Go to Accounting Configuration Settings screen")
) )
def _get_partner_country(self, inv_line): def _get_partner_country(self, inv_line, notedict):
country = ( country = (
inv_line.move_id.src_dest_country_id inv_line.move_id.src_dest_country_id
or inv_line.move_id.partner_id.country_id or inv_line.move_id.partner_id.country_id
@@ -250,23 +252,22 @@ class IntrastatProductDeclaration(models.Model):
country = False country = False
return country return country
def _get_intrastat_transaction(self, inv_line): def _get_intrastat_transaction(self, inv_line, notedict):
invoice = inv_line.move_id invoice = inv_line.move_id
if invoice.intrastat_transaction_id: if invoice.intrastat_transaction_id:
return invoice.intrastat_transaction_id return invoice.intrastat_transaction_id
else: else:
company = invoice.company_id company = invoice.company_id
if invoice.type == "out_invoice": if invoice.move_type == "out_invoice":
return company.intrastat_transaction_out_invoice return company.intrastat_transaction_out_invoice
elif invoice.type == "out_refund": elif invoice.move_type == "out_refund":
return company.intrastat_transaction_out_refund return company.intrastat_transaction_out_refund
elif invoice.type == "in_invoice": elif invoice.move_type == "in_invoice":
return company.intrastat_transaction_in_invoice return company.intrastat_transaction_in_invoice
elif invoice.type == "in_refund": elif invoice.move_type == "in_refund":
return company.intrastat_transaction_in_refund return company.intrastat_transaction_in_refund
def _get_weight_and_supplunits(self, inv_line, hs_code): def _get_weight_and_supplunits(self, inv_line, hs_code, notedict):
line_nbr = self._line_nbr
line_qty = inv_line.quantity line_qty = inv_line.quantity
product = inv_line.product_id product = inv_line.product_id
intrastat_unit_id = hs_code.intrastat_unit_id intrastat_unit_id = hs_code.intrastat_unit_id
@@ -279,7 +280,7 @@ class IntrastatProductDeclaration(models.Model):
if not source_uom: if not source_uom:
line_notes = [_("Missing unit of measure.")] line_notes = [_("Missing unit of measure.")]
self._note += self._format_line_note(inv_line, line_nbr, line_notes) self._format_line_note(inv_line, notedict, line_notes)
return weight, suppl_unit_qty return weight, suppl_unit_qty
if intrastat_unit_id: if intrastat_unit_id:
@@ -293,7 +294,7 @@ class IntrastatProductDeclaration(models.Model):
) )
% intrastat_unit_id.name, % intrastat_unit_id.name,
] ]
self._note += self._format_line_note(inv_line, line_nbr, line_notes) self._format_line_note(inv_line, notedict, line_notes)
return weight, suppl_unit_qty return weight, suppl_unit_qty
if target_uom.category_id == source_uom.category_id: if target_uom.category_id == source_uom.category_id:
suppl_unit_qty = source_uom._compute_quantity(line_qty, target_uom) suppl_unit_qty = source_uom._compute_quantity(line_qty, target_uom)
@@ -305,7 +306,7 @@ class IntrastatProductDeclaration(models.Model):
) )
% (source_uom.name, target_uom.name) % (source_uom.name, target_uom.name)
] ]
self._note += self._format_line_note(inv_line, line_nbr, line_notes) self._format_line_note(inv_line, notedict, line_notes)
return weight, suppl_unit_qty return weight, suppl_unit_qty
if weight: if weight:
@@ -317,10 +318,8 @@ class IntrastatProductDeclaration(models.Model):
weight = source_uom._compute_quantity(line_qty, kg_uom) weight = source_uom._compute_quantity(line_qty, kg_uom)
elif source_uom.category_id == pce_uom_categ: elif source_uom.category_id == pce_uom_categ:
if not product.weight: # re-create weight_net ? if not product.weight: # re-create weight_net ?
line_notes = [ line_notes = [_("Missing weight on product %s.") % product.display_name]
_("Missing weight on product %s.") % product.name_get()[0][1] self._format_line_note(inv_line, notedict, line_notes)
]
self._note += self._format_line_note(inv_line, line_nbr, line_notes)
return weight, suppl_unit_qty return weight, suppl_unit_qty
if source_uom == pce_uom: if source_uom == pce_uom:
weight = product.weight * line_qty # product.weight_net weight = product.weight * line_qty # product.weight_net
@@ -337,14 +336,14 @@ class IntrastatProductDeclaration(models.Model):
"Conversion from unit of measure '%s' to 'Kg' " "Conversion from unit of measure '%s' to 'Kg' "
"is not implemented yet. It is needed for product '%s'." "is not implemented yet. It is needed for product '%s'."
) )
% (source_uom.name, product.name_get()[0][1]) % (source_uom.name, product.display_name)
] ]
self._note += self._format_line_note(inv_line, line_nbr, line_notes) self._note += self._format_line_note(inv_line, notedict, line_notes)
return weight, suppl_unit_qty return weight, suppl_unit_qty
return weight, suppl_unit_qty return weight, suppl_unit_qty
def _get_amount(self, inv_line): def _get_amount(self, inv_line, notedict):
invoice = inv_line.move_id invoice = inv_line.move_id
amount = invoice.currency_id._convert( amount = invoice.currency_id._convert(
inv_line.price_subtotal, inv_line.price_subtotal,
@@ -354,7 +353,7 @@ class IntrastatProductDeclaration(models.Model):
) )
return amount return amount
def _get_region(self, inv_line): def _get_region(self, inv_line, notedict):
""" """
For supplier invoices/refunds: if the invoice line is linked For supplier invoices/refunds: if the invoice line is linked
to a stock move, use the destination stock location ; to a stock move, use the destination stock location ;
@@ -374,29 +373,27 @@ class IntrastatProductDeclaration(models.Model):
""" """
region = False region = False
inv_type = inv_line.move_id.type move_type = inv_line.move_id.move_type
if inv_type in ("in_invoice", "in_refund"): if move_type in ("in_invoice", "in_refund"):
po_lines = self.env["purchase.order.line"].search( po_line = self.env["purchase.order.line"].search(
[("invoice_lines", "in", inv_line.id)] [("invoice_lines", "in", inv_line.id)], limit=1
) )
if po_lines: if po_line:
if po_lines[0].move_ids: if po_line.move_ids:
region = ( region = po_line.move_ids[0].location_dest_id.get_intrastat_region()
po_lines[0].move_ids[0].location_dest_id.get_intrastat_region() elif move_type in ("out_invoice", "out_refund"):
so_line = self.env["sale.order.line"].search(
[("invoice_lines", "in", inv_line.id)], limit=1
) )
elif inv_type in ("out_invoice", "out_refund"): if so_line:
so_lines = self.env["sale.order.line"].search( so = so_line.order_id
[("invoice_lines", "in", inv_line.id)]
)
if so_lines:
so = so_lines[0].order_id
region = so.warehouse_id.region_id region = so.warehouse_id.region_id
if not region: if not region:
if self.company_id.intrastat_region_id: if self.company_id.intrastat_region_id:
region = self.company_id.intrastat_region_id region = self.company_id.intrastat_region_id
return region return region
def _get_transport(self, inv_line): def _get_transport(self, inv_line, notedict):
transport = ( transport = (
inv_line.move_id.intrastat_transport_id inv_line.move_id.intrastat_transport_id
or self.company_id.intrastat_transport_id or self.company_id.intrastat_transport_id
@@ -410,7 +407,7 @@ class IntrastatProductDeclaration(models.Model):
self._account_config_warning(msg) self._account_config_warning(msg)
return transport return transport
def _get_incoterm(self, inv_line): def _get_incoterm(self, inv_line, notedict):
incoterm = inv_line.move_id.invoice_incoterm_id or self.company_id.incoterm_id incoterm = inv_line.move_id.invoice_incoterm_id or self.company_id.incoterm_id
if not incoterm: if not incoterm:
msg = _( msg = _(
@@ -421,12 +418,11 @@ class IntrastatProductDeclaration(models.Model):
self._account_config_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, notedict):
return inv_line.product_id.origin_country_id return inv_line.product_id.origin_country_id
def _update_computation_line_vals(self, inv_line, line_vals): def _update_computation_line_vals(self, inv_line, line_vals, notedict):
""" placeholder for localization modules """ """ placeholder for localization modules """
pass
def _handle_invoice_accessory_cost( def _handle_invoice_accessory_cost(
self, self,
@@ -482,9 +478,13 @@ class IntrastatProductDeclaration(models.Model):
("date", ">=", start_date), ("date", ">=", start_date),
("date", "<=", end_date), ("date", "<=", end_date),
("state", "=", "posted"), ("state", "=", "posted"),
("intrastat_country", "=", True), ("intrastat_fiscal_position", "=", True),
("company_id", "=", self.company_id.id), ("company_id", "=", self.company_id.id),
("type", "!=", "entry"), (
"move_type",
"in",
("out_invoice", "out_refund", "in_invoice", "in_refund"),
),
] ]
return domain return domain
@@ -497,25 +497,27 @@ class IntrastatProductDeclaration(models.Model):
else: else:
return False return False
def _gather_invoices_init(self): def _gather_invoices_init(self, notedict):
""" placeholder for localization modules """ """ placeholder for localization modules """
pass
def _format_line_note(self, line, line_nbr, line_notes): def _format_line_note(self, line, notedict, line_notes):
indent = 8 * " " indent = 8 * " "
note = _("Invoice %s, line %s") % (line.move_id.name, line_nbr) note = _("Invoice %s, line %s") % (line.move_id.name, notedict["line_nbr"])
note += ":\n" note += ":\n"
for line_note in line_notes: for line_note in line_notes:
note += indent + line_note note += indent + line_note
note += "\n" note += "\n"
return note notedict["note"] += note
def _gather_invoices(self): def _gather_invoices(self, notedict):
lines = [] lines = []
qty_prec = self.env["decimal.precision"].precision_get(
"Product Unit of Measure"
)
accessory_costs = self.company_id.intrastat_accessory_costs accessory_costs = self.company_id.intrastat_accessory_costs
self._gather_invoices_init() self._gather_invoices_init(notedict)
domain = self._prepare_invoice_domain() domain = self._prepare_invoice_domain()
order = "journal_id, name" order = "journal_id, name"
invoices = self.env["account.move"].search(domain, order=order) invoices = self.env["account.move"].search(domain, order=order)
@@ -526,8 +528,10 @@ class IntrastatProductDeclaration(models.Model):
total_inv_accessory_costs_cc = 0.0 # in company currency total_inv_accessory_costs_cc = 0.0 # in company currency
total_inv_product_cc = 0.0 # in company currency total_inv_product_cc = 0.0 # in company currency
total_inv_weight = 0.0 total_inv_weight = 0.0
for line_nbr, inv_line in enumerate(invoice.invoice_line_ids, start=1): for line_nbr, inv_line in enumerate(
self._line_nbr = line_nbr invoice.invoice_line_ids.filtered(lambda x: not x.display_type), start=1
):
notedict["line_nbr"] = line_nbr
inv_intrastat_line = invoice.intrastat_line_ids.filtered( inv_intrastat_line = invoice.intrastat_line_ids.filtered(
lambda r: r.invoice_line_id == inv_line lambda r: r.invoice_line_id == inv_line
) )
@@ -547,7 +551,7 @@ class IntrastatProductDeclaration(models.Model):
continue continue
if not inv_line.quantity: if float_is_zero(inv_line.quantity, precision_digits=qty_prec):
_logger.info( _logger.info(
"Skipping invoice line %s qty %s " "Skipping invoice line %s qty %s "
"of invoice %s. Reason: qty = 0" "of invoice %s. Reason: qty = 0"
@@ -555,24 +559,21 @@ class IntrastatProductDeclaration(models.Model):
) )
continue continue
partner_country = self._get_partner_country(inv_line) partner_country = self._get_partner_country(inv_line, notedict)
if not partner_country: if not partner_country:
_logger.info( line_notes = [
"Skipping invoice line %s qty %s " _(
"of invoice %s. Reason: no partner_country" "Missing country on invoice partner '%s' "
% (inv_line.name, inv_line.quantity, invoice.name) "or on the delivery address (partner '%s'). "
) )
continue % (
invoice.partner_id.display_name,
if any( invoice.partner_shipping_id
[tax.exclude_from_intrastat_if_present for tax in inv_line.tax_ids] and invoice.partner_shipping_id.display_name
): or "-",
_logger.info(
"Skipping invoice line %s "
"qty %s of invoice %s. Reason: "
"tax.exclude_from_intrastat_if_present"
% (inv_line.name, inv_line.quantity, invoice.name)
) )
]
self._format_line_note(inv_line, notedict, line_notes)
continue continue
if inv_intrastat_line: if inv_intrastat_line:
@@ -582,11 +583,9 @@ class IntrastatProductDeclaration(models.Model):
if not hs_code: if not hs_code:
line_notes = [ line_notes = [
_("Missing Intrastat Code on product %s. ") _("Missing Intrastat Code on product %s. ")
% (inv_line.product_id.name_get()[0][1]) % (inv_line.product_id.display_name)
] ]
self._note += self._format_line_note( self._format_line_note(inv_line, notedict, line_notes)
inv_line, line_nbr, line_notes
)
continue continue
else: else:
_logger.info( _logger.info(
@@ -596,18 +595,20 @@ class IntrastatProductDeclaration(models.Model):
) )
continue continue
intrastat_transaction = self._get_intrastat_transaction(inv_line) intrastat_transaction = self._get_intrastat_transaction(
inv_line, notedict
)
if inv_intrastat_line: if inv_intrastat_line:
weight = inv_intrastat_line.transaction_weight weight = inv_intrastat_line.transaction_weight
suppl_unit_qty = inv_intrastat_line.transaction_suppl_unit_qty suppl_unit_qty = inv_intrastat_line.transaction_suppl_unit_qty
else: else:
weight, suppl_unit_qty = self._get_weight_and_supplunits( weight, suppl_unit_qty = self._get_weight_and_supplunits(
inv_line, hs_code inv_line, hs_code, notedict
) )
total_inv_weight += weight total_inv_weight += weight
amount_company_currency = self._get_amount(inv_line) amount_company_currency = self._get_amount(inv_line, notedict)
total_inv_product_cc += amount_company_currency total_inv_product_cc += amount_company_currency
if inv_intrastat_line: if inv_intrastat_line:
@@ -615,9 +616,11 @@ class IntrastatProductDeclaration(models.Model):
inv_intrastat_line.product_origin_country_id inv_intrastat_line.product_origin_country_id
) )
else: else:
product_origin_country = self._get_product_origin_country(inv_line) product_origin_country = self._get_product_origin_country(
inv_line, notedict
)
region = self._get_region(inv_line) region = self._get_region(inv_line, notedict)
line_vals = { line_vals = {
"parent_id": self.id, "parent_id": self.id,
@@ -635,11 +638,11 @@ class IntrastatProductDeclaration(models.Model):
} }
# extended declaration # extended declaration
if self._extended: if self.reporting_level == "extended":
transport = self._get_transport(inv_line) transport = self._get_transport(inv_line, notedict)
line_vals.update({"transport_id": transport.id}) line_vals.update({"transport_id": transport.id})
self._update_computation_line_vals(inv_line, line_vals) self._update_computation_line_vals(inv_line, line_vals, notedict)
if line_vals: if line_vals:
lines_current_invoice.append(line_vals) lines_current_invoice.append(line_vals)
@@ -684,42 +687,33 @@ class IntrastatProductDeclaration(models.Model):
self.ensure_one() self.ensure_one()
self.message_post(body=_("Generate Lines from Invoices")) self.message_post(body=_("Generate Lines from Invoices"))
self._check_generate_lines() self._check_generate_lines()
self._note = "" notedict = {
if ( "note": "",
self.type == "arrivals" and self.company_id.intrastat_arrivals == "extended" "line_nbr": 0,
) or ( }
self.type == "dispatches" # TODO: implement a solution to avoid double warnings
and self.company_id.intrastat_dispatches == "extended" # e.g. warning on invoice that is repeated for every line
): # or warning on a product that is repeated for every invoice line
self._extended = True # with that product
else:
self._extended = False
self.computation_line_ids.unlink() self.computation_line_ids.unlink()
self.declaration_line_ids.unlink() self.declaration_line_ids.unlink()
lines = self._gather_invoices() lines = self._gather_invoices(notedict)
vals = {"note": notedict["note"]}
if not lines: if not lines:
self.action = "nihil" vals["action"] = "nihil"
note = ( vals["note"] += (
"\n" "\n"
+ _("No records found for the selected period !") + _("No records found for the selected period !")
+ "\n" + "\n"
+ _("The Declaration Action has been set to 'nihil'.") + _("The Declaration Action has been set to 'nihil'.")
) )
self._note += note
else: else:
self.write({"computation_line_ids": [(0, 0, x) for x in lines]}) vals["computation_line_ids"] = [(0, 0, x) for x in lines]
if self._note: self.write(vals)
note_header = ( if vals["note"]:
"\n\n>>> "
+ fields.Datetime.to_string(
fields.Datetime.context_timestamp(self, datetime.now())
)
+ "\n"
)
self.note = note_header + self._note + (self.note or "")
result_view = self.env.ref("intrastat_base.intrastat_result_view_form") result_view = self.env.ref("intrastat_base.intrastat_result_view_form")
return { return {
"name": _("Generate lines from invoices: results"), "name": _("Generate lines from invoices: results"),
@@ -728,7 +722,7 @@ class IntrastatProductDeclaration(models.Model):
"res_model": "intrastat.result.view", "res_model": "intrastat.result.view",
"view_id": result_view.id, "view_id": result_view.id,
"target": "new", "target": "new",
"context": dict(self._context, note=self._note), "context": dict(self._context, note=vals["note"]),
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
} }
@@ -829,16 +823,20 @@ class IntrastatProductDeclaration(models.Model):
self.message_post(body=_("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_bytes = self._generate_xml()
if xml_string: if xml_bytes:
attach_id = self._attach_xml_file( attach_id = self._attach_xml_file(
xml_string, "{}_{}".format(self.type, self.revision) xml_bytes, "{}_{}".format(self.declaration_type, self.revision)
) )
self.write({"xml_attachment_id": attach_id}) self.write({"xml_attachment_id": attach_id})
return self._open_attach_view(attach_id) return
else: else:
raise UserError(_("No XML File has been generated.")) raise UserError(_("No XML File has been generated."))
def delete_xml(self):
self.ensure_one()
self.xml_attachment_id and self.xml_attachment_id.unlink()
def create_xls(self): def create_xls(self):
if self.env.context.get("computation_lines"): if self.env.context.get("computation_lines"):
report_file = "instrastat_transactions" report_file = "instrastat_transactions"
@@ -917,7 +915,7 @@ class IntrastatProductComputationLine(models.Model):
company_currency_id = fields.Many2one( company_currency_id = fields.Many2one(
related="company_id.currency_id", string="Company currency" related="company_id.currency_id", string="Company currency"
) )
type = fields.Selection(related="parent_id.type") declaration_type = fields.Selection(related="parent_id.declaration_type")
reporting_level = fields.Selection(related="parent_id.reporting_level") reporting_level = fields.Selection(related="parent_id.reporting_level")
valid = fields.Boolean(compute="_compute_check_validity", string="Valid") valid = fields.Boolean(compute="_compute_check_validity", string="Valid")
invoice_line_id = fields.Many2one( invoice_line_id = fields.Many2one(
@@ -1017,7 +1015,7 @@ class IntrastatProductDeclarationLine(models.Model):
company_currency_id = fields.Many2one( company_currency_id = fields.Many2one(
related="company_id.currency_id", string="Company currency" related="company_id.currency_id", string="Company currency"
) )
type = fields.Selection(related="parent_id.type") declaration_type = fields.Selection(related="parent_id.declaration_type")
reporting_level = fields.Selection(related="parent_id.reporting_level") reporting_level = fields.Selection(related="parent_id.reporting_level")
computation_line_ids = fields.One2many( computation_line_ids = fields.One2many(
"intrastat.product.computation.line", "intrastat.product.computation.line",

View File

@@ -1,4 +1,4 @@
# Copyright 2011-2017 Akretion France (http://www.akretion.com) # Copyright 2011-2020 Akretion France (http://www.akretion.com)
# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2009-2020 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>

View File

@@ -1,5 +1,5 @@
# Copyright 2011-2017 Akretion (http://www.akretion.com) # Copyright 2011-2020 Akretion (http://www.akretion.com)
# Copyright 2009-2018 Noviat (http://www.noviat.com) # Copyright 2009-2020 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>

View File

@@ -1,4 +1,4 @@
# Copyright 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) # Copyright 2017-2020 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# Copyright 2009-2020 Noviat (http://www.noviat.com) # Copyright 2009-2020 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).
@@ -37,4 +37,4 @@ class ResConfigSettings(models.TransientModel):
related="company_id.intrastat_accessory_costs", readonly=False related="company_id.intrastat_accessory_costs", readonly=False
) )
country_id = fields.Many2one(related="company_id.country_id") country_id = fields.Many2one(related="company_id.country_id")
country_code = fields.Char(related="company_id.country_id.code") # country_code is defined in the 'account' module

View File

@@ -1,4 +1,4 @@
# Copyright 2010-2019 Akretion France (http://www.akretion.com) # Copyright 2010-2020 Akretion France (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com> # @author Alexis de Lattre <alexis.delattre@akretion.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).

View File

@@ -1,4 +1,4 @@
# Copyright 2009-2018 Noviat nv/sa (www.noviat.com). # Copyright 2009-2020 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>
@@ -18,10 +18,10 @@ class StockLocation(models.Model):
def get_intrastat_region(self): def get_intrastat_region(self):
self.ensure_one() self.ensure_one()
locations = self.search([("id", "parent_of", self.id)]) warehouse = self.env["stock.warehouse"].search(
warehouses = self.env["stock.warehouse"].search( [("lot_stock_id", "parent_of", self.ids), ("region_id", "!=", False)],
[("lot_stock_id", "in", locations.ids), ("region_id", "!=", False)] limit=1,
) )
if warehouses: if warehouse:
return warehouses[0].region_id return warehouse.region_id
return None return None

View File

@@ -1,2 +1,5 @@
* Alexis de Lattre, Akretion <alexis.delattre@akretion.com> * Alexis de Lattre, Akretion <alexis.delattre@akretion.com>
* Luc De Meyer, Noviat <info@noviat.com> * Luc De Meyer, Noviat <info@noviat.com>
* Tecnativa <www.tecnativa.com>:
* João Marques

View File

@@ -3,8 +3,13 @@
import logging import logging
from odoo import models from odoo import _, models
from odoo.tools.translate import _, translate from odoo.tools.translate import translate
from odoo.addons.report_xlsx_helper.report.report_xlsx_format import (
FORMATS,
XLS_HEADERS,
)
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@@ -63,12 +68,12 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
"header": { "header": {
"type": "string", "type": "string",
"value": self._("Fiscal Value"), "value": self._("Fiscal Value"),
"format": self.format_theader_yellow_right, "format": FORMATS["format_theader_yellow_right"],
}, },
"line": { "line": {
"type": "number", "type": "number",
"value": self._render("line.amount_company_currency"), "value": self._render("line.amount_company_currency"),
"format": self.format_tcell_amount_right, "format": FORMATS["format_tcell_amount_right"],
}, },
"width": 18, "width": 18,
}, },
@@ -76,14 +81,14 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
"header": { "header": {
"type": "string", "type": "string",
"value": self._("Accessory Costs"), "value": self._("Accessory Costs"),
"format": self.format_theader_yellow_right, "format": FORMATS["format_theader_yellow_right"],
}, },
"line": { "line": {
"type": "number", "type": "number",
"value": self._render( "value": self._render(
"line.amount_accessory_cost_company_currency" "line.amount_accessory_cost_company_currency"
), ),
"format": self.format_tcell_amount_right, "format": FORMATS["format_tcell_amount_right"],
}, },
"width": 18, "width": 18,
}, },
@@ -96,12 +101,12 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
"header": { "header": {
"type": "string", "type": "string",
"value": self._("Weight"), "value": self._("Weight"),
"format": self.format_theader_yellow_right, "format": FORMATS["format_theader_yellow_right"],
}, },
"line": { "line": {
"type": "number", "type": "number",
"value": self._render("line.weight"), "value": self._render("line.weight"),
"format": self.format_tcell_amount_right, "format": FORMATS["format_tcell_amount_right"],
}, },
"width": 18, "width": 18,
}, },
@@ -109,14 +114,14 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
"header": { "header": {
"type": "string", "type": "string",
"value": self._("Suppl. Unit Qty"), "value": self._("Suppl. Unit Qty"),
"format": self.format_theader_yellow_right, "format": FORMATS["format_theader_yellow_right"],
}, },
"line": { "line": {
# we don't specify a type here and rely on the # we don't specify a type here and rely on the
# report_xlsx_helper type detection to use # report_xlsx_helper type detection to use
# write_string when suppl_unit_qty is zero # write_string when suppl_unit_qty is zero
"value": self._render("line.suppl_unit_qty or ''"), "value": self._render("line.suppl_unit_qty or ''"),
"format": self.format_tcell_amount_right, "format": FORMATS["format_tcell_amount_right"],
}, },
"width": 18, "width": 18,
}, },
@@ -192,14 +197,14 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
no_entries = ( no_entries = (
_("No") + " " + lines + " " + _("for period %s") % declaration.year_month _("No") + " " + lines + " " + _("for period %s") % declaration.year_month
) )
ws.write_string(row_pos, 0, no_entries, self.format_left_bold) ws.write_string(row_pos, 0, no_entries, FORMATS["format_left_bold"])
def _intrastat_report(self, workbook, ws, ws_params, data, declaration): def _intrastat_report(self, workbook, ws, ws_params, data, declaration):
ws.set_landscape() ws.set_landscape()
ws.fit_to_pages(1, 0) ws.fit_to_pages(1, 0)
ws.set_header(self.xls_headers["standard"]) ws.set_header(XLS_HEADERS["xls_headers"]["standard"])
ws.set_footer(self.xls_footers["standard"]) ws.set_footer(XLS_HEADERS["xls_footers"]["standard"])
self._set_column_width(ws, ws_params) self._set_column_width(ws, ws_params)
@@ -221,7 +226,7 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
row_pos, row_pos,
ws_params, ws_params,
col_specs_section="header", col_specs_section="header",
default_format=self.format_theader_yellow_left, default_format=FORMATS["format_theader_yellow_left"],
) )
ws.freeze_panes(row_pos, 0) ws.freeze_panes(row_pos, 0)
@@ -233,5 +238,5 @@ class IntrastatProductDeclarationXlsx(models.AbstractModel):
ws_params, ws_params,
col_specs_section="line", col_specs_section="line",
render_space={"line": line}, render_space={"line": line},
default_format=self.format_tcell_left, default_format=FORMATS["format_tcell_left"],
) )

View File

@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Intrastat Product</title> <title>Intrastat Product</title>
<style type="text/css"> <style type="text/css">
@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/tree/13.0/intrastat_product"><img alt="OCA/intrastat-extrastat" src="https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/intrastat-extrastat-13-0/intrastat-extrastat-13-0-intrastat_product"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/227/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/tree/14.0/intrastat_product"><img alt="OCA/intrastat-extrastat" src="https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/intrastat-extrastat-14-0/intrastat-extrastat-14-0-intrastat_product"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/227/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module contains common objects and fields for the Intrastat Product reporting.</p> <p>This module contains common objects and fields for the Intrastat Product reporting.</p>
<p>It should be used in combination with country-specific Intrastat Product reporting modules <p>It should be used in combination with country-specific Intrastat Product reporting modules
such as:</p> such as:</p>
@@ -455,7 +455,7 @@ the customization or new method is required for multiple countries).</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/intrastat-extrastat/issues/new?body=module:%20intrastat_product%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/issues/new?body=module:%20intrastat_product%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -470,9 +470,18 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
</div> </div>
<div class="section" id="contributors"> <div class="section" id="contributors">
<h2><a class="toc-backref" href="#id8">Contributors</a></h2> <h2><a class="toc-backref" href="#id8">Contributors</a></h2>
<ul>
<li><p class="first">Alexis de Lattre, Akretion &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</p>
</li>
<li><p class="first">Luc De Meyer, Noviat &lt;<a class="reference external" href="mailto:info&#64;noviat.com">info&#64;noviat.com</a>&gt;</p>
</li>
<li><p class="first">Tecnativa &lt;www.tecnativa.com&gt;:</p>
<blockquote>
<ul class="simple"> <ul class="simple">
<li>Alexis de Lattre, Akretion &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li> <li>João Marques</li>
<li>Luc De Meyer, Noviat &lt;<a class="reference external" href="mailto:info&#64;noviat.com">info&#64;noviat.com</a>&gt;</li> </ul>
</blockquote>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -482,7 +491,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/tree/13.0/intrastat_product">OCA/intrastat-extrastat</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/intrastat-extrastat/tree/14.0/intrastat_product">OCA/intrastat-extrastat</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@@ -9,7 +9,10 @@
expr="//page[@name='other_info']//field[@name='invoice_incoterm_id']" expr="//page[@name='other_info']//field[@name='invoice_incoterm_id']"
position="after" position="after"
> >
<field name="intrastat_transaction_id" /> <field
name="intrastat_transaction_id"
domain="[('company_id', '=', company_id)]"
/>
<field name="intrastat" invisible="1" /> <field name="intrastat" invisible="1" />
<field <field
name="intrastat_transport_id" name="intrastat_transport_id"
@@ -24,7 +27,7 @@
id="intrastat_lines" id="intrastat_lines"
string="Intrastat transaction details" string="Intrastat transaction details"
groups="intrastat_product.group_invoice_intrastat_transaction_details" groups="intrastat_product.group_invoice_intrastat_transaction_details"
attrs="{'invisible': [('type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}" attrs="{'invisible': [('move_type', 'not in', ('out_invoice', 'out_refund', 'in_invoice', 'in_refund'))]}"
> >
<div> <div>
<button <button

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!-- <!--
© 2010-2017 Akretion (http://www.akretion.com/) Copyright 2010-2020 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/) Copyright 2015-2020 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 <luc.demeyer@noviat.com> @author Luc De Meyer <luc.demeyer@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).

View File

@@ -11,7 +11,7 @@
type="object" type="object"
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('action', '=', 'nihil')]}" attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('action', '=', 'nihil')]}"
string="Generate Lines from Invoices" string="Generate Lines from Invoices"
class="oe_highlight" class="btn-primary"
/> />
<button <button
name="generate_declaration" name="generate_declaration"
@@ -26,11 +26,17 @@
attrs="{'invisible': [('xml_attachment_id', '!=', False)]}" attrs="{'invisible': [('xml_attachment_id', '!=', False)]}"
invisible="context.get('generic_intrastat_product_declaration')" invisible="context.get('generic_intrastat_product_declaration')"
/> />
<button
name="delete_xml"
string="Delete XML Export"
type="object"
attrs="{'invisible': [('xml_attachment_id', '=', False)]}"
/>
<button <button
name="done" name="done"
string="Done" string="Done"
type="object" type="object"
class="oe_highlight" class="btn-primary"
states="draft" states="draft"
/> />
<button <button
@@ -52,11 +58,14 @@
<group name="properties-1"> <group name="properties-1">
<field name="year" /> <field name="year" />
<field name="month" /> <field name="month" />
<field name="type" /> <field name="declaration_type" />
<field <field
name="xml_attachment_id" name="xml_attachment_datas"
filename="xml_attachment_name"
invisible="context.get('generic_intrastat_product_declaration')" invisible="context.get('generic_intrastat_product_declaration')"
/> />
<field name="xml_attachment_name" invisible="1" />
<field name="xml_attachment_id" invisible="1" />
<field name="reporting_level" invisible="1" /> <field name="reporting_level" invisible="1" />
</group> </group>
<group name="properties-2"> <group name="properties-2">
@@ -71,7 +80,6 @@
<field <field
name="company_id" name="company_id"
groups="base.group_multi_company" groups="base.group_multi_company"
widget="selection"
/> />
<field name="company_country_code" invisible="1" /> <field name="company_country_code" invisible="1" />
<field name="currency_id" invisible="1" /> <field name="currency_id" invisible="1" />
@@ -90,7 +98,7 @@
<group name="computation_lines"> <group name="computation_lines">
<field <field
name="computation_line_ids" name="computation_line_ids"
context="{'type': type, 'reporting_level': reporting_level}" context="{'declaration_type': declaration_type, 'reporting_level': reporting_level}"
nolabel="1" nolabel="1"
/> />
</group> </group>
@@ -107,7 +115,7 @@
<group name="declaration_lines"> <group name="declaration_lines">
<field <field
name="declaration_line_ids" name="declaration_line_ids"
context="{'type': type, 'reporting_level': reporting_level}" context="{'declaration_type': declaration_type, 'reporting_level': reporting_level}"
nolabel="1" nolabel="1"
/> />
</group> </group>
@@ -135,7 +143,7 @@
> >
<field name="year_month" /> <field name="year_month" />
<field name="revision" /> <field name="revision" />
<field name="type" /> <field name="declaration_type" />
<field name="num_decl_lines" /> <field name="num_decl_lines" />
<field name="total_amount" sum="Total amount" /> <field name="total_amount" sum="Total amount" />
<field name="currency_id" /> <field name="currency_id" />
@@ -148,16 +156,18 @@
<field name="model">intrastat.product.declaration</field> <field name="model">intrastat.product.declaration</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<search string="Search Intrastat Product Declarations"> <search string="Search Intrastat Product Declarations">
<field name="year_month" />
<filter <filter
name="arrivals" name="arrivals"
string="Arrivals" string="Arrivals"
domain="[('type', '=', 'arrivals')]" domain="[('declaration_type', '=', 'arrivals')]"
/> />
<filter <filter
name="dispatches" name="dispatches"
string="Dispatches" string="Dispatches"
domain="[('type', '=', 'dispatches')]" domain="[('declaration_type', '=', 'dispatches')]"
/> />
<separator />
<filter <filter
name="draft" name="draft"
string="Draft" string="Draft"
@@ -171,9 +181,9 @@
context="{'group_by': 'year_month'}" context="{'group_by': 'year_month'}"
/> />
<filter <filter
name="type_group_by" name="declaration_type_group_by"
string="Type" string="Type"
context="{'group_by': 'type'}" context="{'group_by': 'declaration_type'}"
/> />
</group> </group>
</search> </search>
@@ -185,7 +195,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<graph string="Intrastat Product" type="bar" stacked="False"> <graph string="Intrastat Product" type="bar" stacked="False">
<field name="year_month" type="row" /> <field name="year_month" type="row" />
<field name="type" type="row" /> <field name="declaration_type" type="row" />
<field name="total_amount" type="measure" /> <field name="total_amount" type="measure" />
</graph> </graph>
</field> </field>
@@ -196,7 +206,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<pivot string="Intrastat Product"> <pivot string="Intrastat Product">
<field name="year_month" type="row" /> <field name="year_month" type="row" />
<field name="type" type="col" /> <field name="declaration_type" type="col" />
<field name="total_amount" type="measure" /> <field name="total_amount" type="measure" />
</pivot> </pivot>
</field> </field>
@@ -236,7 +246,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="declaration_type" invisible="1" />
<field name="reporting_level" invisible="1" /> <field name="reporting_level" invisible="1" />
<field <field
name="transport_id" name="transport_id"
@@ -285,7 +295,7 @@
string="Product C/O" string="Product C/O"
/> />
<field name="invoice_id" /> <field name="invoice_id" />
<field name="type" invisible="1" /> <field name="declaration_type" invisible="1" />
<field name="reporting_level" invisible="1" /> <field name="reporting_level" invisible="1" />
</tree> </tree>
</field> </field>
@@ -318,7 +328,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="declaration_type" invisible="1" />
<field name="reporting_level" invisible="1" /> <field name="reporting_level" invisible="1" />
<field <field
name="transport_id" name="transport_id"
@@ -350,7 +360,7 @@
<field name="weight" /> <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="declaration_type" invisible="1" />
<field name="reporting_level" invisible="1" /> <field name="reporting_level" invisible="1" />
<field <field
name="transport_id" name="transport_id"

View File

@@ -5,7 +5,7 @@
<field name="model">intrastat.region</field> <field name="model">intrastat.region</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Intrastat Region"> <form string="Intrastat Region">
<group> <group name="main">
<field name="code" /> <field name="code" />
<field name="name" /> <field name="name" />
<field name="description" /> <field name="description" />
@@ -22,7 +22,7 @@
<tree string="Intrastat Region"> <tree string="Intrastat Region">
<field name="code" /> <field name="code" />
<field name="name" /> <field name="name" />
<field name="description" /> <field name="description" optional="show" />
<field name="country_id" /> <field name="country_id" />
<field name="company_id" groups="base.group_multi_company" /> <field name="company_id" groups="base.group_multi_company" />
</tree> </tree>
@@ -37,5 +37,6 @@
id="intrastat_region_menu" id="intrastat_region_menu"
action="intrastat_region_action" action="intrastat_region_action"
parent="intrastat_base.menu_intrastat_config_root" parent="intrastat_base.menu_intrastat_config_root"
sequence="50"
/> />
</odoo> </odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<!-- <!--
© 2010-2017 Akretion (http://www.akretion.com/) Copyright 2010-2020 Akretion (http://www.akretion.com/)
© 2015-2017 Noviat (http://www.noviat.com/) Copyright 2015-2020 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 <luc.demeyer@noviat.com> @author Luc De Meyer <luc.demeyer@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).

View File

@@ -28,7 +28,7 @@
<tree string="Intrastat Transportat Modes"> <tree string="Intrastat Transportat Modes">
<field name="code" /> <field name="code" />
<field name="name" /> <field name="name" />
<field name="description" /> <field name="description" optional="show" />
</tree> </tree>
</field> </field>
</record> </record>

View File

@@ -35,7 +35,7 @@
<tree string="Intrastat Supplementary Units"> <tree string="Intrastat Supplementary Units">
<field name="name" /> <field name="name" />
<field name="uom_id" /> <field name="uom_id" />
<field name="description" /> <field name="description" optional="show" />
</tree> </tree>
</field> </field>
</record> </record>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<!-- <!--
© 2018 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>) Copyright 2018-2020 brain-tec AG (Kumar Aberer <kumar.aberer@braintec-group.com>)
© 2019 Noviat (www.noviat.com) Copyright 2019-2020 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>
@@ -13,55 +13,43 @@
ref="intrastat_base.view_intrastat_res_config_settings" 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-settings" position="inside">
<field name="country_id" invisible="1" />
<field name="country_code" invisible="1" />
<div class="row mt16 o_settings_container" id="intrastat-product">
<div class="col-xs-12 col-md-12 o_setting_box">
<div class="o_setting_left_pane" /> <div class="o_setting_left_pane" />
<div <div
class="o_setting_right_pane" class="o_setting_right_pane"
id="intrastat-product-main-params" id="intrastat-product-main-params"
> >
<div class="row"> <div class="row">
<label <label for="intrastat_arrivals" class="col-md-5" />
for="intrastat_arrivals"
class="col-md-5 o_light_label"
/>
<field name="intrastat_arrivals" /> <field name="intrastat_arrivals" />
<field name="country_id" invisible="1" />
</div> </div>
<div class="row"> <div class="row">
<label <label for="intrastat_dispatches" class="col-md-5" />
for="intrastat_dispatches"
class="col-md-5 o_light_label"
/>
<field name="intrastat_dispatches" /> <field name="intrastat_dispatches" />
</div> </div>
<div class="row"> <div class="row">
<label <label for="intrastat_transport_id" class="col-md-5" />
for="intrastat_transport_id"
class="col-md-5 o_light_label"
/>
<field name="intrastat_transport_id" /> <field name="intrastat_transport_id" />
</div> </div>
<div class="row"> <div class="row">
<label <label
for="intrastat_transaction_out_invoice" for="intrastat_transaction_out_invoice"
class="col-md-5 o_light_label" class="col-md-5"
/> />
<field name="intrastat_transaction_out_invoice" /> <field name="intrastat_transaction_out_invoice" />
</div> </div>
<div class="row"> <div class="row">
<label <label
for="intrastat_transaction_out_refund" for="intrastat_transaction_out_refund"
class="col-md-5 o_light_label" class="col-md-5"
/> />
<field name="intrastat_transaction_out_refund" /> <field name="intrastat_transaction_out_refund" />
</div> </div>
<div class="row"> <div class="row">
<label <label
for="intrastat_transaction_in_invoice" for="intrastat_transaction_in_invoice"
class="col-md-5 o_light_label" class="col-md-5"
/> />
<field name="intrastat_transaction_in_invoice" /> <field name="intrastat_transaction_in_invoice" />
</div> </div>
@@ -71,7 +59,7 @@
> >
<label <label
for="intrastat_transaction_in_refund" for="intrastat_transaction_in_refund"
class="col-md-5 o_light_label" class="col-md-5"
/> />
<field name="intrastat_transaction_in_refund" /> <field name="intrastat_transaction_in_refund" />
</div> </div>
@@ -79,10 +67,7 @@
class="row" class="row"
attrs="{'invisible': [('country_code', 'not in', ['BE'])]}" attrs="{'invisible': [('country_code', 'not in', ['BE'])]}"
> >
<label <label for="intrastat_region_id" class="col-md-5" />
for="intrastat_region_id"
class="col-md-5 o_light_label"
/>
<field <field
name="intrastat_region_id" name="intrastat_region_id"
domain="[('country_id','=', country_id)]" domain="[('country_id','=', country_id)]"
@@ -99,14 +84,12 @@
<div class="row"> <div class="row">
<label <label
for="intrastat_accessory_costs" for="intrastat_accessory_costs"
class="col-md-12 o_light_label" class="col-12"
attrs="{'invisible': [('country_code', 'in', ['BE'])]}" attrs="{'invisible': [('country_code', 'in', ['BE'])]}"
/> />
</div> </div>
</div> </div>
</div> </div>
</div>
</xpath>
</field> </field>
</record> </record>
</odoo> </odoo>