diff --git a/delivery_carrier_label_default/README.rst b/delivery_carrier_label_default/README.rst index 65e5c3ea4e..7fcb00eefa 100644 --- a/delivery_carrier_label_default/README.rst +++ b/delivery_carrier_label_default/README.rst @@ -14,13 +14,13 @@ Default label for carrier labels :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/12.0/delivery_carrier_label_default + :target: https://github.com/OCA/delivery-carrier/tree/14.0/delivery_carrier_label_default :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-12-0/delivery-carrier-12-0-delivery_carrier_label_default + :target: https://translation.odoo-community.org/projects/delivery-carrier-14-0/delivery-carrier-14-0-delivery_carrier_label_default :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/12.0 + :target: https://runbot.odoo-community.org/runbot/99/14.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -43,7 +43,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -54,6 +54,7 @@ Authors ~~~~~~~ * Camptocamp +* Sunflower IT Contributors ~~~~~~~~~~~~ @@ -62,6 +63,7 @@ Contributors * Sébastien Alix * Sergio Teruel * Iryna Vyshnevska +* Kevin Kamau Other credits ~~~~~~~~~~~~~ @@ -84,6 +86,6 @@ 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 `_ project on GitHub. +This module is part of the `OCA/delivery-carrier `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/delivery_carrier_label_default/__init__.py b/delivery_carrier_label_default/__init__.py index 0650744f6b..83cca80691 100644 --- a/delivery_carrier_label_default/__init__.py +++ b/delivery_carrier_label_default/__init__.py @@ -1 +1,4 @@ +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + from . import models diff --git a/delivery_carrier_label_default/__manifest__.py b/delivery_carrier_label_default/__manifest__.py index 0e104f173a..f5c1e02faf 100644 --- a/delivery_carrier_label_default/__manifest__.py +++ b/delivery_carrier_label_default/__manifest__.py @@ -1,17 +1,19 @@ # Copyright 2013-2019 Camptocamp SA +# Copyright 2021 Sunflower IT # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) { "name": "Default label for carrier labels", "summary": "This module defines a basic label to print " "when no specific carrier is selected.", - "version": "12.0.1.0.0", + "version": "14.0.1.0.0", "development_status": "Production/Stable", "category": "Delivery", "website": "https://github.com/OCA/delivery-carrier", - "author": "Camptocamp, Odoo Community Association (OCA)", + "author": "Camptocamp, Sunflower IT, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "depends": [ + "stock", "base_delivery_carrier_label", ], "data": [ diff --git a/delivery_carrier_label_default/i18n/delivery_carrier_label_default.pot b/delivery_carrier_label_default/i18n/delivery_carrier_label_default.pot index f24c1bdd32..1887cf4246 100644 --- a/delivery_carrier_label_default/i18n/delivery_carrier_label_default.pot +++ b/delivery_carrier_label_default/i18n/delivery_carrier_label_default.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 14.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: delivery_carrier_label_default -#: model:ir.actions.report,name:delivery_carrier_label_default.default_label +#: model:ir.actions.report,name:delivery_carrier_label_default.action_default_label msgid "Shipping Label" msgstr "" diff --git a/delivery_carrier_label_default/models/__init__.py b/delivery_carrier_label_default/models/__init__.py index ae4c27227f..01d042efe3 100644 --- a/delivery_carrier_label_default/models/__init__.py +++ b/delivery_carrier_label_default/models/__init__.py @@ -1 +1,5 @@ -from . import stock_picking +# Copyright 2013-2019 Camptocamp SA +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from . import delivery_carrier diff --git a/delivery_carrier_label_default/models/delivery_carrier.py b/delivery_carrier_label_default/models/delivery_carrier.py new file mode 100644 index 0000000000..5d96782cdb --- /dev/null +++ b/delivery_carrier_label_default/models/delivery_carrier.py @@ -0,0 +1,38 @@ +# Copyright 2013-2019 Camptocamp SA +# Copyright 2021 Sunflower IT +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +import base64 + +from odoo import models + + +class DeliveryCarrier(models.Model): + _inherit = "delivery.carrier" + + def send_shipping(self, pickings): + # call parent chain. + result = super().send_shipping(pickings) + # check if parent result has label defined, if not, add default label + # Avoid more than one default attachment to be added. (No dups) + if "labels" not in result[0]: + attachment = self.env["ir.attachment"].search( + [("name", "=ilike", ("%" + pickings[0].name + "%"))] + ) + if not attachment: + pdf_report = self.env.ref( + "delivery_carrier_label_default.action_default_label" + )._render_qweb_pdf([pickings[0].id]) + if pdf_report: + result[0]["labels"] = [ + { + "name": "Shipping Label %s.pdf" % pickings[0].name, + "file": base64.b64encode(pdf_report[0]), + "file_type": "pdf", + } + ] + if result is None: + result = self.alternative_send_shipping(pickings) + for result_dict, picking in zip(result, pickings): + for label in result_dict.get("labels", []): + picking.attach_shipping_label(label) + return result diff --git a/delivery_carrier_label_default/readme/CONTRIBUTORS.rst b/delivery_carrier_label_default/readme/CONTRIBUTORS.rst index 93d279c981..e4eb1db3e6 100644 --- a/delivery_carrier_label_default/readme/CONTRIBUTORS.rst +++ b/delivery_carrier_label_default/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * Sébastien Alix * Sergio Teruel * Iryna Vyshnevska +* Kevin Kamau diff --git a/delivery_carrier_label_default/static/description/icon.png b/delivery_carrier_label_default/static/description/icon.png new file mode 100644 index 0000000000..e69de29bb2 diff --git a/delivery_carrier_label_default/static/description/index.html b/delivery_carrier_label_default/static/description/index.html index 20d1f2ac02..d723ca7e75 100644 --- a/delivery_carrier_label_default/static/description/index.html +++ b/delivery_carrier_label_default/static/description/index.html @@ -3,7 +3,7 @@ - + Default label for carrier labels