diff --git a/l10n_be_intrastat_product/__manifest__.py b/l10n_be_intrastat_product/__manifest__.py
index 427d12113..6683c1221 100644
--- a/l10n_be_intrastat_product/__manifest__.py
+++ b/l10n_be_intrastat_product/__manifest__.py
@@ -3,22 +3,20 @@
{
"name": "Intrastat Product Declaration for Belgium",
- "version": "15.0.1.0.0",
+ "version": "16.0.1.0.0",
"category": "Intrastat",
"license": "AGPL-3",
"summary": "Intrastat Product Declaration for Belgium",
"author": "Noviat,Odoo Community Association (OCA)",
"maintainers": ["luc-demeyer", "jdidderen-noviat"],
"website": "https://github.com/OCA/l10n-belgium",
- "depends": ["intrastat_product"],
+ "depends": ["intrastat_product", "base_view_inheritance_extension"],
"conflicts": ["l10n_be_intrastat", "report_intrastat"],
"data": [
"security/intrastat_security.xml",
- "security/ir.model.access.csv",
"data/intrastat_region.xml",
- "data/intrastat_transaction.xml",
"views/account_move_views.xml",
- "views/l10n_be_intrastat_product_views.xml",
+ "views/intrastat_product_views.xml",
],
"installable": True,
}
diff --git a/l10n_be_intrastat_product/data/intrastat_transaction.xml b/l10n_be_intrastat_product/data/intrastat_transaction.xml
deleted file mode 100644
index a2679bfa1..000000000
--- a/l10n_be_intrastat_product/data/intrastat_transaction.xml
+++ /dev/null
@@ -1,238 +0,0 @@
-
-
-
-
-
- 11
- Transactions involving actual change of ownership with financial compensation. Outright sale/purchase except
- direct trade with/by private consumers.
-
-
-
- 12
- Transactions involving actual change of ownership with financial compensation. Direct trade with/by private
- consumers (incl. distance sale).
-
-
-
- 21
- Return and replacement of goods free of charge after registration of the original transaction. Return of goods.
-
-
-
- 22
- Return and replacement of goods free of charge after registration of the original transaction. Replacement for
- returned goods.
-
-
-
- 23
- Return and replacement of goods free of charge after registration of the original transaction. Replacement
- (e.g. under warranty) for goods not being returned.
-
-
-
- 31
- Transactions involving intended change of ownership or change of ownership without financial compensation.
- Movements to/from a warehouse (excluding call-off and consignment stock).
-
-
-
- 32
- Transactions involving intended change of ownership or change of ownership without financial compensation.
- Supply for sale on approval or after trial (including call-off and consignment stock).
-
-
-
- 33
- Transactions involving intended change of ownership or change of ownership without financial compensation.
- Financial leasing.
-
-
-
- 34
- Transactions involving intended change of ownership or change of ownership without financial compensation.
- Transactions involving transfer of ownership without financial compensation.
-
-
-
- 41
- Transactions with a view to processing under contract (not involving change of ownership). Goods expected to
- return to the initial Member State/country of export.
-
-
-
- 42
- Transactions with a view to processing under contract (not involving change of ownership). Goods not expected
- to return to the initial Member State/country of export.
-
-
-
- 51
- Transactions following processing under contract (not involving change of ownership). Goods returning to the
- initial Member State/country of export.
-
-
-
- 52
- Transactions following processing under contract (not involving change of ownership). Goods not returning to
- the initial Member State/country of export.
-
-
-
- 60
- Operations following repair or maintenance. This service can be both free of charge or against payment. These
- operations do not involve a (future) transfer of ownership.
-
-
-
- 71
- Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in
- quasi-import or export). Release of goods for free circulation in a Member State with a subsequent export to
- another Member State.
-
-
-
- 72
- Transactions with a view to/following customs clearance (not involving change of ownership, related to goods in
- quasi-import or export). Transportation of goods from one Member State to another Member State to place the
- goods under the export procedure.
-
-
-
- 80
- Transactions involving the supply of building materials and technical equipment under a general construction or
- civil engineering contract for which no separate invoicing of the goods is required and an invoice for the
- total contract is issued.
-
-
-
- 91
- Other transactions which cannot be classified under other codes. Hire, loan, and operational leasing longer
- than 24 months.
-
-
-
- 99
- Other transactions which cannot be classified under other codes. Other.
-
-
-
-
-
- 1
- Transactions involving an actual or intended transfer of ownership from residents to non-residents against
- financial or other compensation (except the transactions listed under 2, 7 and 8)
-
- 0
-
-
- 2
- Return and replacement of goods free of charge after registration of the original transaction
-
- 0
-
-
- 3
- Transactions involving transfer of ownership without financial or in kind compensation (e.g. aid shipments)
-
- 0
-
-
- 4
- Operations with a view to processing 1 under contract (no transfer of ownership to the processor)
-
- 0
-
-
- 5
- Operations following processing under contract (no transfer of ownership to the processor)
-
- 0
-
-
- 6
- Operations "following" repair or maintenance, other than under joint inter-governmental production programmes.
- Repair and maintenance can be against payment or free of charge. These operations do not involve a (future)
- transfer of ownership*.
-
- 0
-
-
- 7
- Operations under joint defence projects or other joint intergovernmental production programmes
-
- 0
-
-
- 8
- Transactions involving the supply of building materials and technical equipment under a general construction or
- civil engineering contract for which no separate invoicing of the goods is required and an invoice for the
- total contract is issued
-
- 0
-
-
- 9
- Other transactions which cannot be classified under other codes
-
- 0
-
-
-
diff --git a/l10n_be_intrastat_product/models/__init__.py b/l10n_be_intrastat_product/models/__init__.py
index 7a463032a..5023ab6f5 100644
--- a/l10n_be_intrastat_product/models/__init__.py
+++ b/l10n_be_intrastat_product/models/__init__.py
@@ -1,2 +1,2 @@
from . import account_move
-from . import l10n_be_intrastat_product_declaration
+from . import intrastat_product_declaration
diff --git a/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py b/l10n_be_intrastat_product/models/intrastat_product_declaration.py
similarity index 54%
rename from l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py
rename to l10n_be_intrastat_product/models/intrastat_product_declaration.py
index 43b441d40..ae8fa521e 100644
--- a/l10n_be_intrastat_product/models/l10n_be_intrastat_product_declaration.py
+++ b/l10n_be_intrastat_product/models/intrastat_product_declaration.py
@@ -7,7 +7,7 @@
from dateutil.relativedelta import relativedelta
from lxml import etree
-from odoo import _, api, fields, models
+from odoo import _, api, models
from odoo.exceptions import UserError
from odoo.addons.report_xlsx_helper.report.report_xlsx_abstract import (
@@ -20,49 +20,12 @@
_INTRASTAT_XMLNS = "http://www.onegate.eu/2010-01-01"
-class L10nBeIntrastatProductDeclaration(models.Model):
- _name = "l10n.be.intrastat.product.declaration"
- _description = "Intrastat Product Declaration for Belgium"
- _inherit = ["intrastat.product.declaration", "mail.thread"]
-
- computation_line_ids = fields.One2many(
- "l10n.be.intrastat.product.computation.line",
- "parent_id",
- string="Intrastat Product Computation Lines",
- states={"done": [("readonly", True)]},
- )
- declaration_line_ids = fields.One2many(
- "l10n.be.intrastat.product.declaration.line",
- "parent_id",
- string="Intrastat Product Declaration Lines",
- states={"done": [("readonly", True)]},
- )
-
- def _get_intrastat_transaction(self, inv_line, notedict):
- transaction = super()._get_intrastat_transaction(inv_line, notedict)
- msg1 = _("Select a 1 digit intrastat transaction code.")
- msg2 = _("Select a 2 digit intrastat transaction code.")
- module = __name__.split("addons.")[1].split(".")[0]
- if transaction:
- if int(transaction.code) >= 10 and self.year <= "2021":
- self._format_line_note(inv_line, notedict, [msg1])
- elif int(transaction.code) < 10 and self.year > "2021":
- self._format_line_note(inv_line, notedict, [msg2])
- else:
- if self.year <= "2021":
- transaction = self.env.ref("%s.intrastat_transaction_1" % module)
- else:
- transaction = self.env.ref("%s.intrastat_transaction_11" % module)
- invoice = inv_line.move_id
- if not invoice.intrastat_transaction_id:
- cp = invoice.commercial_partner_id
- if not cp.is_company:
- transaction = self.env.ref("%s.intrastat_transaction_12" % module)
- return transaction
+class IntrastatProductDeclaration(models.Model):
+ _inherit = "intrastat.product.declaration"
def _get_region(self, inv_line, notedict):
region = super()._get_region(inv_line, notedict)
- if not region:
+ if self.company_country_code == "BE" and not region:
msg = _(
"The Intrastat Region of the Company is not set, "
"please configure it first."
@@ -70,19 +33,6 @@ def _get_region(self, inv_line, notedict):
self._account_config_warning(msg)
return region
- def _get_vat(self, inv_line, notedict):
- inv = inv_line.move_id
- cp = inv.commercial_partner_id
- b2c = not cp.is_company
- b2b_na = cp.is_company and (
- (cp.vat or "").lower().strip() == "na"
- or (not cp.vat and not inv.fiscal_position_id.vat_required)
- )
- if b2c or b2b_na:
- return "QV999999999999"
- else:
- return super()._get_vat(inv_line, notedict)
-
def _handle_refund(self, inv_line, line_vals, notedict):
"""
NBB/BNB Intrastat Manual 2022 :
@@ -100,6 +50,8 @@ def _handle_refund(self, inv_line, line_vals, notedict):
Move the refund handling to the 'intrastat_product' module and
add refund unit tests.
"""
+ if self.company_country_code != "BE":
+ return
refund = inv_line.move_id
if refund.intrastat_transaction_id:
line_vals["transaction_id"] = refund.intrastat_transaction_id.id
@@ -118,7 +70,7 @@ def _handle_refund(self, inv_line, line_vals, notedict):
if self.company_id.intrastat_dispatches == "exempt":
line_vals.update(
{
- "hs_code_id": notedict["credit_note_code"].id,
+ "hs_code_id": notedict["credit_note_code_origin"].id,
"region_id": refund.src_dest_region_id.id,
"transaction_id": False,
}
@@ -138,7 +90,7 @@ def _handle_refund(self, inv_line, line_vals, notedict):
if self.company_id.intrastat_arrivals == "exempt":
line_vals.update(
{
- "hs_code_id": notedict["credit_note_code"].id,
+ "hs_code_id": notedict["credit_note_code_origin"].id,
"region_id": refund.src_dest_region_id.id,
"transaction_id": False,
}
@@ -175,32 +127,31 @@ def _handle_refund(self, inv_line, line_vals, notedict):
}
)
return
-
- line_notes = [
- _("Unable to determine the correct handling of Refund."),
- _("Please check/set the Intrastat Transaction Code on the Refund."),
- ]
- self._format_line_note(inv_line, notedict, line_notes)
+ msg = _(
+ "Unable to determine the correct handling of Refund. "
+ "Please check/set the Intrastat Transaction Code on the Refund."
+ )
+ notedict["invoice"][notedict["inv_origin"]].add(msg)
def _update_computation_line_vals(self, inv_line, line_vals, notedict):
super()._update_computation_line_vals(inv_line, line_vals, notedict)
# handling of refunds
- inv = inv_line.move_id
- if inv.move_type in ["in_refund", "out_refund"]:
- self._handle_refund(inv_line, line_vals, notedict)
+ if self.company_country_code == "BE":
+ inv = inv_line.move_id
+ if inv.move_type in ["in_refund", "out_refund"]:
+ self._handle_refund(inv_line, line_vals, notedict)
- if line_vals:
- if self.declaration_type == "dispatches":
- if not line_vals["vat"]:
- line_notes = [
- _("Missing VAT Number on partner '%s'")
- % inv.partner_id.name_get()[0][1]
- ]
- self._format_line_note(inv_line, notedict, line_notes)
- # extended declaration
- if self.reporting_level == "extended":
- incoterm = self._get_incoterm(inv_line, notedict)
- line_vals.update({"incoterm_id": incoterm.id})
+ if line_vals:
+ if self.declaration_type == "dispatches":
+ if not line_vals.get("vat", ""):
+ msg = _("Missing VAT Number")
+ notedict["partner"][inv.partner_id.display_name][msg].add(
+ notedict["inv_origin"]
+ )
+ # extended declaration
+ if self.reporting_level == "extended":
+ incoterm = self._get_incoterm(inv_line, notedict)
+ line_vals.update({"incoterm_id": incoterm.id})
return
def _handle_invoice_accessory_cost(
@@ -220,95 +171,63 @@ def _handle_invoice_accessory_cost(
stated on a separate line on the invoice), transport and insurance
costs may not be included in the value of the goods.
"""
+ if self.company_country_code != "BE":
+ return super()._handle_invoice_accessory_cost(
+ invoice,
+ lines_current_invoice,
+ total_inv_accessory_costs_cc,
+ total_inv_product_cc,
+ total_inv_weight,
+ )
+ else:
+ return
def _gather_invoices_init(self, notedict):
- if self.company_id.country_id.code not in ("be", "BE"):
- raise UserError(
- _(
- "The Belgian Intrastat Declaration requires "
- "the Company's Country to be equal to 'Belgium'."
- )
+ if self.company_country_code == "BE":
+ # Special commodity codes
+ # Current version implements only regular credit notes
+ special_code = "99600000"
+ hs_code = self.env["hs.code"].search(
+ [
+ ("local_code", "=", special_code),
+ "|",
+ ("company_id", "=", self.company_id.id),
+ ("company_id", "=", False),
+ ],
+ limit=1,
)
-
- module = __name__.split("addons.")[1].split(".")[0]
-
- # Special commodity codes
- # Current version implements only regular credit notes
- special_code = "99600000"
- hs_code = self.env["hs.code"].search([("local_code", "=", special_code)])
- if len(hs_code) > 1:
- hs_code = hs_code.filtered(
- lambda r: r.company_id == self.company_id
- ) or hs_code.filtered(lambda r: not r.company_id)
- if not hs_code:
- msg = (
- _(
- "Intrastat Code '%s' not found. "
- "\nYou can update your codes "
- "via the module intrastat_product_hscodes_import."
+ if not hs_code:
+ msg = (
+ _(
+ "Intrastat Code '%s' not found. "
+ "\nYou can update your codes "
+ "via the module intrastat_product_hscodes_import."
+ )
+ % special_code
)
- % special_code
- )
- raise UserError(msg)
- notedict["credit_note_code"] = hs_code[0]
-
- if self.year <= "2021":
- notedict["transcation_21"] = self.env.ref(
- "%s.intrastat_transaction_2" % module
+ raise UserError(msg)
+ notedict.update(
+ {
+ "credit_note_code_origin": hs_code,
+ }
)
else:
- notedict["transcation_21"] = self.env.ref(
- "%s.intrastat_transaction_21" % module
- )
-
- def _prepare_invoice_domain(self):
- """
- Domain should be based on fiscal position in stead of country.
- Both in_ and out_refund must be included in order to cover
- - credit notes with and without return
- - companies subject to arrivals or dispatches only
- """
- domain = super()._prepare_invoice_domain()
- if self.declaration_type == "arrivals":
- domain.append(
- ("move_type", "in", ("in_invoice", "in_refund", "out_refund"))
- )
- elif self.declaration_type == "dispatches":
- domain.append(
- ("move_type", "in", ("out_invoice", "in_refund", "out_refund"))
- )
- return domain
+ return super()._gather_invoices_init(notedict)
def _sanitize_vat(self, vat):
return vat and vat.replace(" ", "").replace(".", "").upper()
- @api.model
- def _group_line_hashcode_fields(self, computation_line):
- res = super()._group_line_hashcode_fields(computation_line)
- if self.declaration_type == "arrivals":
- del res["product_origin_country"]
- del res["vat"]
- if self.reporting_level == "extended":
- res["incoterm"] = computation_line.incoterm_id.id or False
- return res
-
- @api.model
- def _prepare_grouped_fields(self, computation_line, fields_to_sum):
- vals = super()._prepare_grouped_fields(computation_line, fields_to_sum)
- if self.reporting_level == "extended":
- vals["incoterm_id"] = computation_line.incoterm_id.id
- return vals
-
def _check_generate_xml(self):
self.ensure_one()
res = super()._check_generate_xml()
- if not self.declaration_line_ids:
- res = self.generate_declaration()
+ if self.company_country_code == "BE":
+ if not self.declaration_line_ids:
+ res = self.generate_declaration()
return res
def _get_kbo_bce_nr(self):
kbo_bce_nr = False
- vat = self._sanitize_vat(self.company_id.partner_id.vat)
+ vat = self._sanitize_vat(self.company_id.vat)
if vat and vat[:2] == "BE":
kbo_bce_nr = vat[2:]
return kbo_bce_nr
@@ -322,7 +241,12 @@ def _node_Administration(self, parent):
etree.SubElement(Administration, "Domain").text = "SXX"
def _node_Item(self, parent, line, decl_code):
- for fld in ("src_dest_country_id", "transaction_id", "region_id", "hs_code_id"):
+ for fld in (
+ "src_dest_country_code",
+ "transaction_id",
+ "region_code",
+ "hs_code_id",
+ ):
if not line[fld]:
raise UserError(
_("Error while processing %(line)s:\nMissing '%(line_field)s'.")
@@ -336,9 +260,7 @@ def _node_Item(self, parent, line, decl_code):
etree.SubElement(
Item, "Dim", attrib={"prop": "EXTTA"}
).text = line.transaction_id.code
- etree.SubElement(
- Item, "Dim", attrib={"prop": "EXREG"}
- ).text = line.region_id.code
+ etree.SubElement(Item, "Dim", attrib={"prop": "EXREG"}).text = line.region_code
etree.SubElement(
Item, "Dim", attrib={"prop": "EXTGO"}
).text = line.hs_code_id.local_code
@@ -399,97 +321,99 @@ def _node_Report(self, parent, decl_code):
def _generate_xml(self):
self.ensure_one()
-
- if self.declaration_type == "arrivals":
- decl_code = "19"
- if self.reporting_level == "standard":
- xsd = "ex19s"
+ if self.company_country_code == "BE":
+ if self.declaration_type == "arrivals":
+ decl_code = "19"
+ if self.reporting_level == "standard":
+ xsd = "ex19s"
+ else:
+ xsd = "ex19e"
else:
- xsd = "ex19e"
+ decl_code = "29"
+ if self.reporting_level == "standard":
+ xsd = "intrastat_x_s"
+ else:
+ xsd = "intrastat_x_e"
+
+ ns_map = {
+ None: _INTRASTAT_XMLNS,
+ "xsi": "http://www.w3.org/2001/XMLSchema-instance",
+ }
+ root = etree.Element("DeclarationReport", nsmap=ns_map)
+ self._node_Administration(root)
+ self._node_Report(root, decl_code)
+
+ xml_string = etree.tostring(
+ root, pretty_print=True, encoding="UTF-8", xml_declaration=True
+ )
+ module = __name__.split("addons.")[1].split(".")[0]
+ self.company_id._intrastat_check_xml_schema(
+ xml_string, "{}/static/data/{}.xsd".format(module, xsd)
+ )
+ return xml_string
else:
- decl_code = "29"
- if self.reporting_level == "standard":
- xsd = "intrastat_x_s"
- else:
- xsd = "intrastat_x_e"
-
- ns_map = {
- None: _INTRASTAT_XMLNS,
- "xsi": "http://www.w3.org/2001/XMLSchema-instance",
- }
- root = etree.Element("DeclarationReport", nsmap=ns_map)
- self._node_Administration(root)
- self._node_Report(root, decl_code)
-
- xml_string = etree.tostring(
- root, pretty_print=True, encoding="UTF-8", xml_declaration=True
- )
- module = __name__.split("addons.")[1].split(".")[0]
- self.company_id._intrastat_check_xml_schema(
- xml_string, "{}/static/data/{}.xsd".format(module, xsd)
- )
- return xml_string
+ return super()._generate_xml()
def _xls_computation_line_fields(self):
res = super()._xls_computation_line_fields()
- i = res.index("product_origin_country")
- res.pop(i)
+ if self.company_country_code == "BE":
+ i = res.index("product_origin_country")
+ res.pop(i)
return res
def _xls_declaration_line_fields(self):
res = super()._xls_declaration_line_fields()
- if self.declaration_type == "dispatches":
- i = res.index("hs_code")
- res.insert(i + 1, "product_origin_country")
+ if self.company_country_code == "BE":
+ if self.declaration_type == "dispatches":
+ i = res.index("hs_code")
+ res.insert(i + 1, "product_origin_country")
return res
-class L10nBeIntrastatProductComputationLine(models.Model):
- _name = "l10n.be.intrastat.product.computation.line"
+class IntrastatProductComputationLine(models.Model):
_inherit = "intrastat.product.computation.line"
_description = "Intrastat Product Computation Lines for Belgium"
- parent_id = fields.Many2one(
- comodel_name="l10n.be.intrastat.product.declaration",
- string="Intrastat Product Declaration",
- ondelete="cascade",
- readonly=True,
- )
- declaration_line_id = fields.Many2one(
- comodel_name="l10n.be.intrastat.product.declaration.line",
- string="Declaration Line",
- readonly=True,
- )
-
- @api.constrains("vat")
- def _check_vat(self):
+ @api.depends("partner_id")
+ def _compute_vat(self):
for rec in self:
- if not rec.vat == "QV999999999999":
- super(L10nBeIntrastatProductComputationLine, rec)._check_vat()
+ if rec.company_country_code == "BE" and (
+ rec.invoice_id.fiscal_position_id.intrastat == "b2c"
+ or (
+ rec.invoice_id.fiscal_position_id.intrastat == "b2b"
+ and (
+ not rec.invoice_id.fiscal_position_id.vat_required
+ or (
+ rec.partner_id.vat
+ and rec.partner_id.vat.lower().strip() == "na"
+ )
+ )
+ )
+ ):
+ rec.vat = "QV999999999999"
+ else:
+ super(IntrastatProductComputationLine, rec)._compute_vat()
return
-
-class L10nBeIntrastatProductDeclarationLine(models.Model):
- _name = "l10n.be.intrastat.product.declaration.line"
- _inherit = "intrastat.product.declaration.line"
- _description = "Intrastat Product Declaration Lines for Belgium"
-
- parent_id = fields.Many2one(
- comodel_name="l10n.be.intrastat.product.declaration",
- string="Intrastat Product Declaration",
- ondelete="cascade",
- readonly=True,
- )
- computation_line_ids = fields.One2many(
- comodel_name="l10n.be.intrastat.product.computation.line",
- inverse_name="declaration_line_id",
- string="Computation Lines",
- readonly=True,
- )
-
@api.constrains("vat")
def _check_vat(self):
for rec in self:
if not rec.vat == "QV999999999999":
- super(L10nBeIntrastatProductDeclarationLine, rec)._check_vat()
+ super(IntrastatProductComputationLine, rec)._check_vat()
return
+
+ def _group_line_hashcode_fields(self):
+ res = super()._group_line_hashcode_fields()
+ if self.company_country_code == "BE":
+ if self.declaration_type == "arrivals":
+ del res["product_origin_country"]
+ del res["vat"]
+ if self.reporting_level == "extended":
+ res["incoterm"] = self.incoterm_id.id or False
+ return res
+
+ def _prepare_grouped_fields(self, fields_to_sum):
+ vals = super()._prepare_grouped_fields(fields_to_sum)
+ if self.reporting_level == "extended":
+ vals["incoterm_id"] = self.incoterm_id.id
+ return vals
diff --git a/l10n_be_intrastat_product/security/ir.model.access.csv b/l10n_be_intrastat_product/security/ir.model.access.csv
deleted file mode 100644
index 4f917cae4..000000000
--- a/l10n_be_intrastat_product/security/ir.model.access.csv
+++ /dev/null
@@ -1,4 +0,0 @@
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_l10n_be_intrastat_product_declaration,l10n_be_intrastat_product_declaration accountant,model_l10n_be_intrastat_product_declaration,account.group_account_manager,1,1,1,1
-access_l10n_be_intrastat_product_declaration_line,l10n_be_intrastat_product_declaration_line accountant,model_l10n_be_intrastat_product_declaration_line,account.group_account_manager,1,1,1,1
-access_l10n_be_intrastat_product_computation_line,l10n_be_intrastat_product_computation_line accountant,model_l10n_be_intrastat_product_computation_line,account.group_account_manager,1,1,1,1
diff --git a/l10n_be_intrastat_product/tests/test_intrastat_be.py b/l10n_be_intrastat_product/tests/test_intrastat_be.py
index 79dc5f008..38a47a960 100644
--- a/l10n_be_intrastat_product/tests/test_intrastat_be.py
+++ b/l10n_be_intrastat_product/tests/test_intrastat_be.py
@@ -11,25 +11,26 @@ def setUpClass(cls):
cls.inv_obj = cls.env["account.move"]
cls.fpos_obj = cls.env["account.fiscal.position"]
cls.region_obj = cls.env["intrastat.region"]
- cls.decl_obj = cls.env["l10n.be.intrastat.product.declaration"]
+ cls.decl_obj = cls.env["intrastat.product.declaration"]
cls.company = cls.env.company
cls.env.company.country_id = cls.env.ref("base.be")
+ cls.env.company.vat = "BE0820512013"
cls.company.intrastat_region_id = cls.env.ref(
"l10n_be_intrastat_product.intrastat_region_2"
)
- cls.fpos = cls.fpos_obj.create(
+ cls.fpos_b2b = cls.fpos_obj.create(
{
"name": "Intrastat Fiscal Position (B2B)",
- "intrastat": True,
+ "intrastat": "b2b",
"vat_required": True,
"country_group_id": cls.env.ref("base.europe").id,
}
)
- cls.fpos_na = cls.fpos_obj.create(
+ cls.fpos_b2c = cls.fpos_obj.create(
{
"name": "Intrastat Fiscal Position (B2C)",
- "intrastat": True,
+ "intrastat": "b2c",
"vat_required": False,
"country_group_id": cls.env.ref("base.europe").id,
}
@@ -78,7 +79,7 @@ def setUpClass(cls):
"country_id": cls.env.ref("base.nl").id,
"is_company": True,
"vat": "NL 123456782B90",
- "property_account_position_id": cls.fpos.id,
+ "property_account_position_id": cls.fpos_b2b.id,
}
)
cls.partner_b2b_2 = cls.env["res.partner"].create(
@@ -87,7 +88,7 @@ def setUpClass(cls):
"country_id": cls.env.ref("base.nl").id,
"is_company": True,
"vat": "NL000000000B00",
- "property_account_position_id": cls.fpos.id,
+ "property_account_position_id": cls.fpos_b2b.id,
}
)
cls.partner_b2b_na = cls.env["res.partner"].create(
@@ -95,7 +96,8 @@ def setUpClass(cls):
"name": "NL B2B NA",
"country_id": cls.env.ref("base.nl").id,
"is_company": True,
- "property_account_position_id": cls.fpos_na.id,
+ "vat": "na",
+ "property_account_position_id": cls.fpos_b2b.id,
}
)
cls.partner_b2c = cls.env["res.partner"].create(
@@ -103,7 +105,7 @@ def setUpClass(cls):
"name": "NL B2C",
"country_id": cls.env.ref("base.nl").id,
"is_company": False,
- "property_account_position_id": cls.fpos.id,
+ "property_account_position_id": cls.fpos_b2c.id,
}
)
cls.env["account.tax"].search([("company_id", "=", cls.company.id)]).write(
@@ -115,7 +117,6 @@ def test_be_sale_b2b(self):
inv_out = self.inv_obj.with_context(default_move_type="out_invoice").create(
{
"partner_id": self.partner_b2b_1.id,
- "fiscal_position_id": self.fpos.id,
}
)
with Form(inv_out) as inv_form:
@@ -132,7 +133,7 @@ def test_be_sale_b2b(self):
}
)
declaration.action_gather()
- declaration.generate_declaration()
+ declaration.done()
clines = declaration.computation_line_ids
dlines = declaration.declaration_line_ids
self.assertEqual(clines[0].vat, "NL123456782B90")
@@ -174,7 +175,7 @@ def test_be_sale_b2b(self):
}
)
declaration.action_gather()
- declaration.generate_declaration()
+ declaration.done()
clines = declaration.computation_line_ids
dlines = declaration.declaration_line_ids
self.assertEqual(clines[1].amount_company_currency, -5000.0)
@@ -185,7 +186,6 @@ def test_be_sale_b2b_na(self):
inv_out = self.inv_obj.with_context(default_move_type="out_invoice").create(
{
"partner_id": self.partner_b2b_na.id,
- "fiscal_position_id": self.fpos_na.id,
}
)
with Form(inv_out) as inv_form:
@@ -202,16 +202,14 @@ def test_be_sale_b2b_na(self):
}
)
declaration.action_gather()
- declaration.generate_declaration()
+ declaration.done()
dlines = declaration.declaration_line_ids
self.assertEqual(dlines[0].vat, "QV999999999999")
def test_be_sale_b2c(self):
-
inv_out = self.inv_obj.with_context(default_move_type="out_invoice").create(
{
"partner_id": self.partner_b2c.id,
- "fiscal_position_id": self.fpos.id,
}
)
with Form(inv_out) as inv_form:
@@ -228,7 +226,7 @@ def test_be_sale_b2c(self):
}
)
declaration.action_gather()
- declaration.generate_declaration()
+ declaration.done()
# clines = declaration.computation_line_ids
dlines = declaration.declaration_line_ids
self.assertEqual(dlines[0].vat, "QV999999999999")
@@ -238,7 +236,6 @@ def test_be_purchase(self):
inv_in1 = self.inv_obj.with_context(default_move_type="in_invoice").create(
{
"partner_id": self.partner_b2b_1.id,
- "fiscal_position_id": self.fpos.id,
}
)
with Form(inv_in1) as inv_form:
@@ -250,7 +247,6 @@ def test_be_purchase(self):
inv_in2 = self.inv_obj.with_context(default_move_type="in_invoice").create(
{
"partner_id": self.partner_b2b_2.id,
- "fiscal_position_id": self.fpos.id,
}
)
with Form(inv_in2) as inv_form:
@@ -269,7 +265,7 @@ def test_be_purchase(self):
}
)
declaration.action_gather()
- declaration.generate_declaration()
+ declaration.done()
clines = declaration.computation_line_ids
dlines = declaration.declaration_line_ids
self.assertEqual(clines[1].weight, 460.0)
diff --git a/l10n_be_intrastat_product/views/intrastat_product_views.xml b/l10n_be_intrastat_product/views/intrastat_product_views.xml
new file mode 100644
index 000000000..a75c774a5
--- /dev/null
+++ b/l10n_be_intrastat_product/views/intrastat_product_views.xml
@@ -0,0 +1,200 @@
+
+
+
+
+ l10n.be.intrastat.product.computation.line.form
+ intrastat.product.computation.line
+ primary
+
+
+
+
+ {
+ "invisible": [],
+ }
+
+
+
+
+
+
+ 1
+
+
+
+ {'required': [('reporting_level', '=', 'extended')],
+ 'invisible': [('reporting_level', '!=', 'extended')]}
+
+
+
+
+
+ l10n.be.intrastat.product.computation.line.tree
+ intrastat.product.computation.line
+ primary
+
+
+
+
+ {
+ "column_invisible": [],
+ }
+
+
+
+ 1
+
+
+
+
+
+ l10n.be.intrastat.product.declaration.line.form
+ intrastat.product.declaration.line
+ primary
+
+
+
+ {'invisible': [('declaration_type', '=', 'arrivals')]}
+
+
+
+ {'required': [('reporting_level', '=', 'extended')],
+ 'invisible': [('reporting_level', '!=', 'extended')]}
+
+
+
+
+
+ l10n.be.intrastat.product.declaration.line.tree
+ intrastat.product.declaration.line
+ primary
+
+
+
+ {'invisible': [('declaration_type', '=', 'arrivals')]}
+
+
+
+
+
+ l10n.be.intrastat.product.declaration.form
+ intrastat.product.declaration
+ primary
+
+
+
+
+ {
+ "tree_view_ref": "l10n_be_intrastat_product.l10n_be_intrastat_product_computation_line_view_tree",
+ "form_view_ref": "l10n_be_intrastat_product.l10n_be_intrastat_product_computation_line_view_form",
+ }
+
+
+
+
+ {
+ "tree_view_ref": "l10n_be_intrastat_product.l10n_be_intrastat_product_declaration_line_view_tree",
+ "form_view_ref": "l10n_be_intrastat_product.l10n_be_intrastat_product_declaration_line_view_form",
+ }
+
+
+
+
+
+
+ Belgian Intrastat Product Declaration
+ intrastat.product.declaration
+ tree,form,graph
+
+
+
+
+
+ tree
+
+
+
+
+
+
+ form
+
+
+
+
+
+
+ graph
+
+
+
+
+
+
diff --git a/l10n_be_intrastat_product/views/l10n_be_intrastat_product_views.xml b/l10n_be_intrastat_product/views/l10n_be_intrastat_product_views.xml
deleted file mode 100644
index 5e608cf44..000000000
--- a/l10n_be_intrastat_product/views/l10n_be_intrastat_product_views.xml
+++ /dev/null
@@ -1,173 +0,0 @@
-
-
-
-
- l10n.be.intrastat.product.computation.line.form
- l10n.be.intrastat.product.computation.line
- primary
-
-
-
-
-
-
- 1
-
-
-
- {'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}
-
-
-
-
-
- l10n.be.intrastat.product.computation.line.tree
- l10n.be.intrastat.product.computation.line
- primary
-
-
-
-
-
-
- 1
-
-
-
-
-
- l10n.be.intrastat.product.declaration.line.form
- l10n.be.intrastat.product.declaration.line
- primary
-
-
-
- {'invisible': [('declaration_type', '=', 'arrivals')]}
-
-
-
-
-
-
- {'required': [('reporting_level', '=', 'extended')], 'invisible': [('reporting_level', '!=', 'extended')]}
-
-
-
-
-
- l10n.be.intrastat.product.declaration.line.tree
- l10n.be.intrastat.product.declaration.line
- primary
-
-
-
- {'invisible': [('declaration_type', '=', 'arrivals')]}
-
-
-
-
-
-
-
-
- l10n.be.intrastat.product.declaration.form
- l10n.be.intrastat.product.declaration
- primary
-
-
-
-
-
-
-
-
-
-
- l10n.be.intrastat.product.declaration.tree
- l10n.be.intrastat.product.declaration
- primary
-
-
-
- Belgian Intrastat Product Declaration
-
-
-
-
-
- l10n.be.intrastat.product.declaration.search
- l10n.be.intrastat.product.declaration
- primary
-
-
-
- Search Belgian Intrastat Product Declaration
-
-
-
-
-
- l10n.be.intrastat.product.declaration.graph
- l10n.be.intrastat.product.declaration
- primary
-
-
-
- Belgian Intrastat Product Declaration
-
-
-
-
-
- Belgian Intrastat Product Declaration
- l10n.be.intrastat.product.declaration
- tree,form,graph
-
-
-
-
-