Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Fayolle <alexandre.fayolle@camptocamp.com>
  • Loading branch information
mourad-ehm and gurneyalex authored Sep 17, 2024
1 parent 7f29594 commit 83aba1b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
28 changes: 10 additions & 18 deletions account_ecotax/models/account_ecotax_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,37 +62,29 @@ class AccountEcotaxClassification(models.Model):
("REM", "Remote vendor"),
],
required=True,
help="FAB ==> Fabricant : est établi en France et fabrique des EEE\n"
"sous son propre nom ou sa propre marque, ou fait concevoir ou\n"
" fabriquer des EEE et les commercialise sous\n"
" son propre nom et sa propre marque\n"
"REV ==> Revendeur sous sa marque : est établi en France et vend,\n"
" sous son propre nom ou sa propre marque des EEE produits\n"
" par d'autres fournisseurs"
"INT ==> Introducteur : est établi en France et met sur le marché\n"
"des EEE provenant d'un autre Etat membre"
"IMP ==> Importateur : est établi en France et met sur marché\n"
"des EEE provenant de pays hors Union Européenne"
"DIS ==> Vendeur à distance : est établie dans un autre Etat\n"
"membre ou dans un pays tiers et vend en France des EEE par\n"
"communication à distance",
help="MAN ==> Manufacturer: is locally established in the country, and manufactures goods which are subject to ecotaxes\n"
"under their own name and brand, or designs such goods, subcontracts the manufacturing and then sells them under their own name and brand\n"
"RES ==> Reseller, under their own brand: is locally established in the country, and sells under their own name or brand goods subject to ecotax manufactured by others\n"
"INT ==> Introducer: is locally established and sells on the local market goods subject to ecotax coming from other countries of the European Union\n"
"IMP ==> Importer: is established in France, and sells on the local market goods subject to ecotax coming from countries outside the European Union\n"
"REM ==> Remote vendor: is established in another country of the European Union or outside the EU, and remotely sells good subject to ecotaxes to customers in the country",
)
emebi_code = fields.Char()
intrastat_code = fields.Char()
scale_code = fields.Char()
sale_ecotax_ids = fields.Many2many(
"account.tax",
"ecotax_classif_taxes_rel",
"ecotax_classif_id",
"tax_id",
string="Sale EcoTaxe",
string="Sale EcoTax",
domain=[("is_ecotax", "=", True), ("type_tax_use", "=", "sale")],
)
purchase_ecotax_ids = fields.Many2many(
"account.tax",
"ecotax_classif_purchase_taxes_rel",
"ecotax_classif_id",
"tax_id",
string="Purchase EcoTaxe",
string="Purchase EcoTax",
domain=[("is_ecotax", "=", True), ("type_tax_use", "=", "purchase")],
)

Expand All @@ -101,5 +93,5 @@ def _compute_ecotax_vals(self):
for classif in self:
if classif.ecotax_type == "weight_based":
classif.default_fixed_ecotax = 0
if classif.ecotax_type == "fixed":
elif classif.ecotax_type == "fixed":
classif.ecotax_coef = 0
2 changes: 1 addition & 1 deletion account_ecotax/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _compute_ecotax(self):
for tax in compute_all_currency["taxes"]:
subtotal_ecotax += tax["amount"]

unit = quantity and subtotal_ecotax / quantity or subtotal_ecotax
unit = subtotal_ecotax / quantity if quantity else subtotal_ecotax
line.ecotax_amount_unit = unit
line.subtotal_ecotax = subtotal_ecotax

Expand Down
16 changes: 8 additions & 8 deletions account_ecotax/models/ecotax_line_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class EcotaxLineMixin(models.AbstractModel):
"""Mixin class for objects which can be used to save
multi ecotax calssification by account move line
multi ecotax classification by account move line
or sale order line."""

_name = "ecotax.line.mixin"
Expand All @@ -22,17 +22,17 @@ class EcotaxLineMixin(models.AbstractModel):
amount_unit = fields.Float(
digits="Ecotax",
compute="_compute_ecotax",
help="Ecotax Amount computed form Classification or Manuel ecotax",
help="Ecotax Amount computed from Classification or Manual ecotax",
store=True,
)
force_amount_unit = fields.Float(
digits="Ecotax",
help="Force ecotax.\n" "Allow to subtite default Ecotax Classification\n",
help="Force ecotax.\n" "Allow to add a subtitle to the default Ecotax Classification",
)
amount_total = fields.Float(
digits="Ecotax",
compute="_compute_ecotax",
help="Ecotax Amount total computed form Classification or forced ecotax amount",
help="Ecotax Amount total computed from Classification or forced ecotax amount",
store=True,
)
quantity = fields.Float(digits="Product Unit of Measure", readonly=True)
Expand All @@ -47,13 +47,13 @@ def _compute_ecotax(self):
for ecotaxline in self:
ecotax_cls = ecotaxline.classification_id

if ecotax_cls.ecotax_type == "weight_based":
if ecotaxline.force_amount_unit:
# force ecotax amount
amt = ecotaxline.force_amount_unit
elif ecotax_cls.ecotax_type == "weight_based":
amt = ecotax_cls.ecotax_coef * (ecotaxline.product_id.weight or 0.0)
else:
amt = ecotax_cls.default_fixed_ecotax
# force ecotax amount
if ecotaxline.force_amount_unit:
amt = ecotaxline.force_amount_unit

ecotaxline.amount_unit = amt
ecotaxline.amount_total = ecotaxline.amount_unit * ecotaxline.quantity
4 changes: 2 additions & 2 deletions account_ecotax/models/ecotax_line_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class EcotaxLineProduct(models.Model):
"""class for objects which can be used to save mutili ecotax calssification by product."""
"""class for objects which can be used to save mutiple ecotax classifications by product."""

_name = "ecotax.line.product"
_description = "Ecotax Line product"
Expand All @@ -23,7 +23,7 @@ class EcotaxLineProduct(models.Model):
force_amount = fields.Float(
digits="Ecotax",
help="Force ecotax amount.\n"
"Allow to substitute default Ecotax Classification\n",
"Allow to substitute default Ecotax Classification",
)
amount = fields.Float(
digits="Ecotax",
Expand Down
2 changes: 1 addition & 1 deletion account_ecotax/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ProductTemplate(models.Model):
ecotax_amount = fields.Float(
digits="Ecotax",
compute="_compute_ecotax",
help="Ecotax Amount computed form Classification",
help="Ecotax Amount computed from Classification",
store=True,
)
fixed_ecotax = fields.Float(
Expand Down

0 comments on commit 83aba1b

Please sign in to comment.