Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions base_customs_territory/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
======================
Base Customs Territory
======================

Some states or regions belong politically to a country that is part of a
customs union (e.g. the EU), but are themselves excluded from that customs
territory. Examples include the Canary Islands, Ceuta and Melilla (Spain).
Shipments to these regions require customs export documentation just like
shipments to third countries, even though the destination country itself is
a member of the customs union.

This module adds an ``outside_customs_territory`` boolean field to
``res.country.state`` and pre-populates it for the known exceptions:

* **Canary Islands** – Las Palmas, Santa Cruz de Tenerife
* **Ceuta**
* **Melilla**

The flag is admin-editable on the state record, so future exceptions can be
activated without any code change.

Carrier integrations can use this flag to override country-group-based
decisions.
1 change: 1 addition & 0 deletions base_customs_territory/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions base_customs_territory/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Base Customs Territory",
"version": "18.0.1.0.0",
"category": "Base",
"summary": "Flag states/regions outside the customs territory of their country",
"license": "AGPL-3",
"author": "Nitrokey",
"website": "https://github.com/Nitrokey/odoo-modules/",
"maintainer": ["initOS", "Nitrokey"],
"depends": ["base"],
"data": [
"data/res_country_state_data.xml",
],
"installable": True,
}
22 changes: 22 additions & 0 deletions base_customs_territory/data/res_country_state_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<!-- Spain: territories outside the EU customs and VAT area -->

<!-- Canary Islands -->
<record id="base.state_es_gc" model="res.country.state">
<field name="outside_customs_territory" eval="True" />
</record>
<record id="base.state_es_tf" model="res.country.state">
<field name="outside_customs_territory" eval="True" />
</record>

<!-- Ceuta -->
<record id="base.state_es_ce" model="res.country.state">
<field name="outside_customs_territory" eval="True" />
</record>

<!-- Melilla -->
<record id="base.state_es_ml" model="res.country.state">
<field name="outside_customs_territory" eval="True" />
</record>
</odoo>
1 change: 1 addition & 0 deletions base_customs_territory/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_country_state
13 changes: 13 additions & 0 deletions base_customs_territory/models/res_country_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from odoo import fields, models


class ResCountryState(models.Model):
_inherit = "res.country.state"

outside_customs_territory = fields.Boolean(
default=False,
help="When set, this state/region is treated as outside the customs "
"territory of its parent country, even if that country belongs to a "
"customs union (e.g. the EU). Carrier integrations use this flag to "
"require customs export documentation for shipments to this region.",
)
1 change: 1 addition & 0 deletions delivery_dhl_parcel_de/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"stock_delivery",
"delivery_carrier_account",
"base_iso3166",
"base_customs_territory",
"stock_picking_declared_value",
"mrp",
"product_harmonized_system",
Expand Down
5 changes: 4 additions & 1 deletion delivery_dhl_parcel_de/models/delivery_carrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ def dhl_parcel_de_provider_get_package_info(self, picking, insurance_value):
}

europe_group_id = self.env.ref("base.europe")
if recipient_address_id.country_id not in europe_group_id.country_ids:
if (
recipient_address_id.country_id not in europe_group_id.country_ids
or recipient_address_id.state_id.outside_customs_territory
):
product_data = self.prepare_product_data_request(picking)
company = self.company_id or self.env.company
currency = company.currency_id and company.currency_id.name
Expand Down
Loading