Skip to content
Open
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
5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -13815,3 +13815,8 @@ msgstr "tert-BUTYLISOCYANAT"
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr "tert-BUTYLCYCLOHEXYLCHLORFORMIAT"

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "Adr-Faktor"
5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -13181,3 +13181,8 @@ msgstr ""
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr ""

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "Factor Adr"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msgstr "Factor Adr"
msgstr "Coeficiente Adr"

5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -13876,3 +13876,8 @@ msgstr "ISOCYANATE DE tert-BUTYLE"
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr "CHLOROFORMIATE DE tert-BUTYLCYCLOHEXYLE"

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "Facteur Adr"
5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -13184,3 +13184,8 @@ msgstr ""
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr ""

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "Fattore Adr"
5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/l10n_eu_product_adr.pot
Original file line number Diff line number Diff line change
Expand Up @@ -13227,3 +13227,8 @@ msgstr ""
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr ""

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "Factor Adr"
5 changes: 5 additions & 0 deletions l10n_eu_product_adr/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -13897,3 +13897,8 @@ msgstr "tert-BUTYLISOCYANAAT"
#: model:adr.goods,name:l10n_eu_product_adr.adr_goods_2747
msgid "tert-BUTYLCYCLOHEXYL CHLOROFORMATE"
msgstr "tert-BUTYLCYCLOHEXYLCHLOORFORMIAAT"

#. module: l10n_eu_product_adr
#: model:ir.model.fields,field_description:l10n_eu_product_adr.field_product_product__adr_factor
msgid "Adr Factor"
msgstr "ADR-factor"
16 changes: 16 additions & 0 deletions l10n_eu_product_adr/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import api, fields, models

from .common import category_points_factor_map, un_number_points_factor_map


class ProductProduct(models.Model):
_inherit = "product.product"
Expand Down Expand Up @@ -36,6 +38,20 @@ class ProductProduct(models.Model):
adr_tunnel_restriction_code = fields.Selection(
related="adr_goods_id.tunnel_restriction_code",
)
adr_factor = fields.Integer(compute="_compute_adr_factor", store=True)

@api.depends("adr_goods_id")
def _compute_adr_factor(self):
for product in self:
if product.adr_goods_id:
product.adr_factor = un_number_points_factor_map.get(
product.adr_goods_id.un_number,
category_points_factor_map.get(
product.adr_goods_id.transport_category, 0
),
)
else:
product.adr_factor = 0

@api.onchange("is_dangerous")
def onchange_is_dangerous(self):
Expand Down
9 changes: 2 additions & 7 deletions l10n_eu_product_adr/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from odoo import api, fields, models
from odoo.tools.float_utils import float_round

from .common import category_points_factor_map, un_number_points_factor_map


class StockMove(models.Model):
_inherit = "stock.move"
Expand All @@ -31,15 +29,12 @@ def _compute_adr_points(self):
if not sm.product_id.adr_goods_id:
sm.adr_points = 0
continue
adr_goods = sm.product_id.adr_goods_id
if sm.product_id.weight:
# Assume that the product weight is in kilos per unit
reference_qty = sm.product_id.weight * sm.product_uom_qty
else:
# Conflate the reference unit (kilo, liter) with the ADR unit
reference_qty = sm.product_uom_qty / sm.product_uom.factor
adr_factor = un_number_points_factor_map.get(
adr_goods.un_number,
category_points_factor_map.get(adr_goods.transport_category, 0),
sm.adr_points = float_round(
sm.product_id.adr_factor * reference_qty, precision
)
sm.adr_points = float_round(adr_factor * reference_qty, precision)