-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] l10n_eu_product_adr: Migration to 18.0
- Loading branch information
Showing
23 changed files
with
95 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,7 @@ Contributors | |
- Stefan Rijnhart <[email protected]> | ||
- Vyshnevska Iryna <[email protected]> | ||
- Isaac Gallart <[email protected]> | ||
- Chau Le <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
@@ -143,6 +144,9 @@ Dangerous goods data | |
Dangerous goods data extracted from spreadsheet retrieved from | ||
https://www.cepa.be/wp-content/uploads/ADR_2019_BijlageA_deel3_Tabel_A_EXCEL_FORMAAT.xlsx | ||
|
||
The migration of this module from 16.0 to 18.0 was financially supported | ||
by Camptocamp. | ||
|
||
Maintainers | ||
----------- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright 2021 Stefan Rijnhart <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import _, api, fields, models | ||
from odoo import api, fields, models | ||
from odoo.exceptions import ValidationError | ||
from odoo.osv.expression import AND | ||
|
||
|
@@ -70,39 +70,48 @@ def _check_un_number(self): | |
for goods in self: | ||
if len(goods.un_number) != 4: | ||
raise ValidationError( | ||
_( | ||
self.env._( | ||
"UN Number %s is invalid because it does not have " | ||
"a length of 4." | ||
"a length of 4.", | ||
goods.un_number, | ||
) | ||
% goods.un_number | ||
) | ||
|
||
@api.model | ||
def name_search(self, name="", args=None, operator="ilike", limit=100): | ||
"""Allow to search for UN Number""" | ||
args = list(args or []) | ||
if name and operator in ("ilike", "="): | ||
res = self.search(AND([args, [("un_number", operator, name)]]), limit=limit) | ||
if res: | ||
return res.name_get() | ||
record = self.search( | ||
AND([args, [("un_number", operator, name)]]), limit=limit | ||
) | ||
if record: | ||
return [(rec.id, rec.display_name) for rec in record] | ||
return super().name_search(name=name, args=args, operator=operator, limit=limit) | ||
|
||
def name_get(self): | ||
@api.depends( | ||
"un_number", | ||
"name", | ||
"transport_category", | ||
"limited_quantity", | ||
"limited_quantity_uom_id", | ||
) | ||
def _compute_display_name(self): | ||
"""Format the class name""" | ||
res = [] | ||
for rec in self: | ||
name = f"{rec.un_number} {rec.name}" | ||
affixes = [] | ||
if rec.transport_category != "-": | ||
affixes.append(_("cat:%s", rec.transport_category)) | ||
affixes.append(self.env._("cat:%s", rec.transport_category)) | ||
if rec.limited_quantity: | ||
affixes.append( | ||
_("qty:{limited_quantity} {limited_quantity_uom_id}").format( | ||
self.env._( | ||
"qty:%(limited_quantity)s %(limited_quantity_uom_id)s", | ||
limited_quantity=rec.limited_quantity, | ||
limited_quantity_uom_id=rec.limited_quantity_uom_id.name, | ||
) | ||
) | ||
if affixes: | ||
name += " (%s)" % (", ".join(affixes)) | ||
res.append((rec.id, name)) | ||
return res | ||
name += f" ({', '.join(affixes)})" | ||
|
||
rec.display_name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright 2019 Iryna Vyshnevska (Camptocamp) | ||
# Copyright 2021 Stefan Rijnhart <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import _, fields, models | ||
from odoo import fields, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
||
|
@@ -26,10 +26,9 @@ def unlink(self): | |
for label in self: | ||
if label.goods_ids: | ||
raise ValidationError( | ||
_( | ||
"Dangerous Goods Label {label} cannot be deleted because it " | ||
"is in use on one or more dangerous goods: {labels}" | ||
).format( | ||
self.env._( | ||
"Dangerous Goods Label %(label)s cannot be deleted because it " | ||
"is in use on one or more dangerous goods: %(labels)s", | ||
label=label.name, | ||
labels=", ".join(label.goods_ids.mapped("un_number")), | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# Copyright 2019 Iryna Vyshnevska (Camptocamp) | ||
# Copyright 2021 Opener B.V. <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import _, api, fields, models | ||
from odoo import api, fields, models | ||
from odoo.exceptions import UserError | ||
|
||
|
||
|
@@ -69,7 +69,7 @@ def write(self, values): | |
if variant_vals: | ||
if any(template.adr_goods_on_variants for template in self): | ||
raise UserError( | ||
_( | ||
self.env._( | ||
"There are different dangerous goods configured on " | ||
"this product's variant, so you cannot update the " | ||
"dangerous goods from here. Please reconfigure each " | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- Stefan Rijnhart \<<[email protected]>\> | ||
- Vyshnevska Iryna \<<[email protected]>\> | ||
- Isaac Gallart \<<[email protected]>\> | ||
- Chau Le \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.