-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by dreispt
- Loading branch information
Showing
17 changed files
with
982 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
====================================== | ||
Postlogistics Shipping Dangerous Goods | ||
====================================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fdelivery--carrier-lightgray.png?logo=github | ||
:target: https://github.com/OCA/delivery-carrier/tree/13.0/delivery_postlogistics_dangerous_goods | ||
:alt: OCA/delivery-carrier | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/delivery-carrier-13-0/delivery-carrier-13-0-delivery_postlogistics_dangerous_goods | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/99/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This modules overrides `Postlogistics Shipping` to declare dangerous goods | ||
during postlogistics label generation. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/delivery-carrier/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/delivery-carrier/issues/new?body=module:%20delivery_postlogistics_dangerous_goods%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Camptocamp | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/delivery-carrier <https://github.com/OCA/delivery-carrier/tree/13.0/delivery_postlogistics_dangerous_goods>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from . import postlogistics |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Postlogistics Shipping Dangerous Goods", | ||
"summary": "Declare dangerous goods when generating postlogistics labels", | ||
"version": "13.0.1.0.0", | ||
"author": "Camptocamp,Odoo Community Association (OCA)", | ||
"maintainer": "Camptocamp", | ||
"license": "AGPL-3", | ||
"category": "Delivery", | ||
"complexity": "normal", | ||
"depends": [ | ||
# OCA/delivery-carrier | ||
"delivery_postlogistics", | ||
# OCA/community-data-files | ||
"l10n_eu_product_adr", | ||
], | ||
"website": "https://github.com/OCA/delivery-carrier", | ||
"installable": True, | ||
"auto_install": False, | ||
"application": False, | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import stock_picking |
18 changes: 18 additions & 0 deletions
18
delivery_postlogistics_dangerous_goods/models/stock_picking.py
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import models | ||
|
||
from ..postlogistics.web_service import PostlogisticsWebServiceDangerousGoods | ||
|
||
|
||
class StockPicking(models.Model): | ||
_inherit = "stock.picking" | ||
|
||
def _generate_postlogistics_label(self, webservice_class=None, package_ids=None): | ||
""" Generate post logistic label using specific from this module.""" | ||
if webservice_class is None: | ||
webservice_class = PostlogisticsWebServiceDangerousGoods | ||
return super()._generate_postlogistics_label( | ||
webservice_class=webservice_class, package_ids=package_ids, | ||
) |
1 change: 1 addition & 0 deletions
1
delivery_postlogistics_dangerous_goods/postlogistics/__init__.py
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import web_service |
52 changes: 52 additions & 0 deletions
52
delivery_postlogistics_dangerous_goods/postlogistics/web_service.py
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2021 Camptocamp SA | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) | ||
|
||
import re | ||
|
||
from odoo import _, exceptions | ||
|
||
from odoo.addons.delivery_postlogistics.postlogistics import web_service | ||
|
||
UNNUMBER_REGEX = re.compile("^[0-9]{1,4}") | ||
|
||
|
||
class PostlogisticsWebServiceDangerousGoods(web_service.PostlogisticsWebService): | ||
def _get_unnumbers(self, picking, pack=None): | ||
""" | ||
If any dangerous goods with limited quantity, returns a list of UNNumbers. | ||
""" | ||
products = ( | ||
pack | ||
and pack.mapped("quant_ids.product_id") | ||
or picking.mapped("move_lines.product_id") | ||
) | ||
limited_amount_lq = picking.env.ref("l10n_eu_product_adr.limited_amount_1") | ||
limited_quantity_products = products.filtered( | ||
lambda p: p.is_dangerous and p.limited_amount_id == limited_amount_lq | ||
) | ||
unnumbers = [] | ||
for product in limited_quantity_products: | ||
unnumber = product.un_ref.name | ||
match = UNNUMBER_REGEX.match(unnumber) | ||
if not match: | ||
raise exceptions.UserError( | ||
_("UNNumber {} is invalid for product {}.").format( | ||
unnumber, product.name | ||
) | ||
) | ||
unnumbers.append(int(match[0])) | ||
return unnumbers | ||
|
||
def _prepare_attributes( | ||
self, picking, pack=None, pack_num=None, pack_total=None, pack_weight=None | ||
): | ||
# Adds a new attribute UNNumbers when there's dangerous goods | ||
# in the pack / picking | ||
res = super()._prepare_attributes( | ||
picking, pack, pack_num, pack_total, pack_weight | ||
) | ||
unnumbers = self._get_unnumbers(picking, pack) | ||
if unnumbers: | ||
res.setdefault("przl", []).append("LQ") | ||
res["unnumbers"] = unnumbers | ||
return res |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
* Matthieu Méquignon <matthieu.mequignon@camptocamp.com> |
2 changes: 2 additions & 0 deletions
2
delivery_postlogistics_dangerous_goods/readme/DESCRIPTION.rst
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This modules overrides `Postlogistics Shipping` to declare dangerous goods | ||
during postlogistics label generation. |
Oops, something went wrong.