Skip to content

Commit d8a7a39

Browse files
committed
add product_harmonized_system_tax_rate
1 parent 8a38152 commit d8a7a39

17 files changed

Lines changed: 826 additions & 0 deletions
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
==================================
2+
product_harmonized_system_tax_rate
3+
==================================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:0ebdb0339fd37d629f79ee2daa2cfe7373fd3329266142eca6bdb116acdfb49e
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fintrastat--extrastat-lightgray.png?logo=github
20+
:target: https://github.com/OCA/intrastat-extrastat/tree/18.0/product_harmonized_system_tax_rate
21+
:alt: OCA/intrastat-extrastat
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/intrastat-extrastat-18-0/intrastat-extrastat-18-0-product_harmonized_system_tax_rate
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/intrastat-extrastat&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Import Tax Rates per { country, HS Code}
32+
33+
This module allows to set import taxes (import duties and/or tariffs) on
34+
countries of origin and HS codes.
35+
36+
The tax rate is also available on the product.
37+
38+
Current limitations:
39+
40+
- Only support Ad valorem type of import tax (rate is % of the value in
41+
currency)
42+
- On product: one origin per product (see product_harmonized_system)
43+
- On product: no support of destination country
44+
45+
**Table of contents**
46+
47+
.. contents::
48+
:local:
49+
50+
Usage
51+
=====
52+
53+
1) Add HS Codes ( Inventory > H.S. Codes )
54+
2) Add HS code Tax Rates ( Inventory > H.S. Codes Tax Rates)
55+
3) (optional) Configure a product: set HS Code and Country of Origin
56+
57+
Bug Tracker
58+
===========
59+
60+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/intrastat-extrastat/issues>`_.
61+
In case of trouble, please check there if your issue has already been reported.
62+
If you spotted it first, help us to smash it by providing a detailed and welcomed
63+
`feedback <https://github.com/OCA/intrastat-extrastat/issues/new?body=module:%20product_harmonized_system_tax_rate%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
64+
65+
Do not contact contributors directly about support or help with technical issues.
66+
67+
Credits
68+
=======
69+
70+
Authors
71+
-------
72+
73+
* Akretion
74+
75+
Contributors
76+
------------
77+
78+
- Olivier Nibart olivier.nibart@akretion.com
79+
- Raphaël Reverdy raphael.reverdy@akretion.com
80+
81+
Other credits
82+
-------------
83+
84+
The development of this module has been financially supported by:
85+
86+
- Noukie's SA (https://www.noukies.com)
87+
- Akretion France (https://www.akretion.com)
88+
89+
Maintainers
90+
-----------
91+
92+
This module is maintained by the OCA.
93+
94+
.. image:: https://odoo-community.org/logo.png
95+
:alt: Odoo Community Association
96+
:target: https://odoo-community.org
97+
98+
OCA, or the Odoo Community Association, is a nonprofit organization whose
99+
mission is to support the collaborative development of Odoo features and
100+
promote its widespread use.
101+
102+
.. |maintainer-nayatec| image:: https://github.com/nayatec.png?size=40px
103+
:target: https://github.com/nayatec
104+
:alt: nayatec
105+
.. |maintainer-hparfr| image:: https://github.com/hparfr.png?size=40px
106+
:target: https://github.com/hparfr
107+
:alt: hparfr
108+
109+
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
110+
111+
|maintainer-nayatec| |maintainer-hparfr|
112+
113+
This module is part of the `OCA/intrastat-extrastat <https://github.com/OCA/intrastat-extrastat/tree/18.0/product_harmonized_system_tax_rate>`_ project on GitHub.
114+
115+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import models
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2019-2025 Akretion France (http://www.akretion.com)
2+
# @author Olivier Nibart <olivier.nibart@akretion.com>
3+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
4+
5+
{
6+
"name": "product_harmonized_system_tax_rate",
7+
"summary": """
8+
Add a notion of tax rate linked to an H.S. Code and Country.""",
9+
"version": "18.0.1.0.0",
10+
"license": "AGPL-3",
11+
"author": "Akretion, Odoo Community Association (OCA)",
12+
"website": "https://github.com/OCA/intrastat-extrastat",
13+
"depends": [
14+
"product_harmonized_system_stock",
15+
],
16+
"maintainers": ["nayatec", "hparfr"],
17+
"data": [
18+
"views/hs_code_tax_rate_views.xml",
19+
"views/hs_code_views.xml",
20+
"views/product_views.xml",
21+
"security/ir.model.access.csv",
22+
],
23+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import hs_code_tax_rate
2+
from . import hs_code
3+
from . import product
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2021 Akretion France (http://www.akretion.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from odoo import fields, models
5+
6+
7+
class HSCode(models.Model):
8+
_inherit = "hs.code"
9+
10+
tax_rate_ids = fields.One2many(
11+
comodel_name="hs.code.tax.rate",
12+
inverse_name="hs_code_id",
13+
string="Tax Rates",
14+
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2021 Akretion France (http://www.akretion.com)
2+
# @author Olivier Nibart <olivier.nibart@akretion.com>
3+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
4+
5+
from odoo import fields, models
6+
7+
8+
class HSCodeTaxRate(models.Model):
9+
_name = "hs.code.tax.rate"
10+
_description = "H.S. Code Tax Rate"
11+
_order = "hs_code_id, tax_rate"
12+
_sql_constraints = [
13+
(
14+
"hs_code_origin_country_uniq",
15+
"unique(origin_country_id, hs_code_id)",
16+
"H.S. Code/Country of Origin must be unique",
17+
)
18+
]
19+
20+
hs_code_id = fields.Many2one(
21+
"hs.code",
22+
string="H.S. Code",
23+
required=True,
24+
ondelete="restrict",
25+
help="Harmonised System Code. Nomenclature is "
26+
"available from the World Customs Organisation, see "
27+
"http://www.wcoomd.org/.",
28+
)
29+
30+
origin_country_id = fields.Many2one(
31+
"res.country",
32+
string="Country of Origin",
33+
required=True,
34+
help="Country of origin of the product i.e. product " "'made in ____'.",
35+
)
36+
37+
tax_rate = fields.Float(
38+
string="Tax Rate %",
39+
required=True,
40+
help="Tax rate percentage for this H.S. Code / Country of Origin.",
41+
)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Copyright 2021 Akretion France (http://www.akretion.com)
2+
# @author Olivier Nibart <olivier.nibart@akretion.com>
3+
# @author Raphaël Reverdy <raphael.reverdy@akretion.com>
4+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
5+
6+
from odoo import api, fields, models
7+
8+
9+
class ProductTemplate(models.Model):
10+
_inherit = "product.template"
11+
12+
hs_code_tax_rate_id = fields.Many2one(
13+
"hs.code.tax.rate",
14+
compute="_compute_hs_code_tax_rate_id",
15+
string="H.S. Code Tax Rate Id",
16+
readonly=True,
17+
store=True,
18+
)
19+
20+
hs_code_tax_rate = fields.Float(
21+
# helper for dependent modules
22+
related="hs_code_tax_rate_id.tax_rate",
23+
)
24+
25+
hs_code_tax_rate_str = fields.Char(
26+
# used in the view
27+
string="H.S. Code Tax Rate",
28+
compute="_compute_hs_code_tax_rate_str",
29+
)
30+
31+
@api.depends("origin_country_id", "hs_code_id", "hs_code_id.tax_rate_ids")
32+
def _compute_hs_code_tax_rate_id(self):
33+
for product in self:
34+
product.hs_code_tax_rate_id = product.hs_code_id.tax_rate_ids.filtered(
35+
lambda x, product=product: x.origin_country_id
36+
== product.origin_country_id
37+
)[:1]
38+
39+
@api.depends("hs_code_tax_rate")
40+
def _compute_hs_code_tax_rate_str(self):
41+
for product in self:
42+
if product.hs_code_tax_rate_id:
43+
# test on hs_code_tax_rate_id to distinguish no value and 0%.
44+
product.hs_code_tax_rate_str = f"{product.hs_code_tax_rate} %"
45+
else:
46+
product.hs_code_tax_rate_str = ""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* Olivier Nibart <olivier.nibart@akretion.com>
2+
* Raphaël Reverdy <raphael.reverdy@akretion.com>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The development of this module has been financially supported by:
2+
3+
* Noukie's SA (https://www.noukies.com)
4+
* Akretion France (https://www.akretion.com)

0 commit comments

Comments
 (0)