Skip to content

Commit

Permalink
[IMP] module product_harmonized_system_per_country
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliesoutiras committed Sep 24, 2024
1 parent 12a4beb commit 945af0c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
1 change: 1 addition & 0 deletions product_harmonized_system_per_country/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
from . import hs_code
from . import product_category
from . import product_product
from . import product_template
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def _get_intrastat_lines_info(self):
res[line.product_id.id]["weight"] += weight
else:
res.pop(line.product_id.id)

Check warning on line 31 in product_harmonized_system_per_country/models/account_move.py

View check run for this annotation

Codecov / codecov/patch

product_harmonized_system_per_country/models/account_move.py#L31

Added line #L31 was not covered by tests
# sort res :
if res:
res = dict(
sorted(
Expand Down
22 changes: 1 addition & 21 deletions product_harmonized_system_per_country/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,7 @@
# @author Emilie SOUTIRAS <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

hs_code = fields.Char(compute="_compute_hs_code", store=False)

@api.depends(
"hs_code_id", "hs_code_id.parent_id", "hs_code_id.child_ids", "categ_id"
)
def _compute_hs_code(self):
for pdt_tmpl in self:
if pdt_tmpl.hs_code_id:
pdt_tmpl.hs_code = (
pdt_tmpl.hs_code_id.filter_per_country().hs_code or ""
)
else:
pdt_tmpl.hs_code = (
pdt_tmpl.categ_id.get_hs_code_recursively().hs_code or ""
)
from odoo import models


class ProductProduct(models.Model):
Expand Down
25 changes: 25 additions & 0 deletions product_harmonized_system_per_country/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2024 Groupe Voltaire
# @author Emilie SOUTIRAS <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

hs_code = fields.Char(compute="_compute_hs_code", store=False)

@api.depends(
"hs_code_id", "hs_code_id.parent_id", "hs_code_id.child_ids", "categ_id"
)
def _compute_hs_code(self):
for pdt_tmpl in self:
if pdt_tmpl.hs_code_id:
pdt_tmpl.hs_code = (

Check warning on line 19 in product_harmonized_system_per_country/models/product_template.py

View check run for this annotation

Codecov / codecov/patch

product_harmonized_system_per_country/models/product_template.py#L19

Added line #L19 was not covered by tests
pdt_tmpl.hs_code_id.filter_per_country().hs_code or ""
)
else:
pdt_tmpl.hs_code = (

Check warning on line 23 in product_harmonized_system_per_country/models/product_template.py

View check run for this annotation

Codecov / codecov/patch

product_harmonized_system_per_country/models/product_template.py#L23

Added line #L23 was not covered by tests
pdt_tmpl.categ_id.get_hs_code_recursively().hs_code or ""
)

0 comments on commit 945af0c

Please sign in to comment.