diff --git a/ebill_postfinance_stock/README.rst b/ebill_postfinance_stock/README.rst new file mode 100644 index 000000000..28cae97a0 --- /dev/null +++ b/ebill_postfinance_stock/README.rst @@ -0,0 +1,85 @@ +======================= +eBill Postfinance Stock +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:d560906a22ebe7ea9c8860c9debf497de39154cb16cf9b93cdf7123f96203532 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fl10n--switzerland-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-switzerland/tree/17.0/ebill_postfinance_stock + :alt: OCA/l10n-switzerland +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-switzerland-17-0/l10n-switzerland-17-0-ebill_postfinance_stock + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-switzerland&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds some information related to delivery in the eBill +Postfinance integration. + +**Table of contents** + +.. contents:: + :local: + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Thierry Ducrest + +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. + +.. |maintainer-TDu| image:: https://github.com/TDu.png?size=40px + :target: https://github.com/TDu + :alt: TDu + +Current `maintainer `__: + +|maintainer-TDu| + +This module is part of the `OCA/l10n-switzerland `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/ebill_postfinance_stock/__init__.py b/ebill_postfinance_stock/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/ebill_postfinance_stock/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/ebill_postfinance_stock/__manifest__.py b/ebill_postfinance_stock/__manifest__.py new file mode 100644 index 000000000..2f270cceb --- /dev/null +++ b/ebill_postfinance_stock/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "eBill Postfinance Stock", + "summary": """Add stock integration to Postfinance eBill""", + "version": "17.0.1.0.0", + "license": "AGPL-3", + "author": "Camptocamp,Odoo Community Association (OCA)", + "maintainers": ["TDu"], + "website": "https://github.com/OCA/l10n-switzerland", + "depends": [ + "ebill_postfinance", + "sale_stock", + ], + "auto_install": True, +} diff --git a/ebill_postfinance_stock/i18n/ebill_postfinance_stock.pot b/ebill_postfinance_stock/i18n/ebill_postfinance_stock.pot new file mode 100644 index 000000000..793a9b642 --- /dev/null +++ b/ebill_postfinance_stock/i18n/ebill_postfinance_stock.pot @@ -0,0 +1,19 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * ebill_postfinance_stock +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: ebill_postfinance_stock +#: model:ir.model,name:ebill_postfinance_stock.model_ebill_postfinance_invoice_message +msgid "Postfinance message send to service" +msgstr "" diff --git a/ebill_postfinance_stock/messages/invoice-line-stock-yellowbill.jinja b/ebill_postfinance_stock/messages/invoice-line-stock-yellowbill.jinja new file mode 100644 index 000000000..521b51ec7 --- /dev/null +++ b/ebill_postfinance_stock/messages/invoice-line-stock-yellowbill.jinja @@ -0,0 +1,10 @@ +{% for picking in line.sale_line_ids.move_ids.mapped('picking_id') %} +{%- if picking.state != 'cancel' %} +{% set ref.position = ref.position + 1 %} + + {{ ref.position }} + DeliveryNoteNumber + {{ picking.name }} + +{%- endif %} +{% endfor %} diff --git a/ebill_postfinance_stock/models/__init__.py b/ebill_postfinance_stock/models/__init__.py new file mode 100644 index 000000000..6c45f0783 --- /dev/null +++ b/ebill_postfinance_stock/models/__init__.py @@ -0,0 +1 @@ +from . import ebill_postfinance_invoice_message diff --git a/ebill_postfinance_stock/models/ebill_postfinance_invoice_message.py b/ebill_postfinance_stock/models/ebill_postfinance_invoice_message.py new file mode 100644 index 000000000..89bda52eb --- /dev/null +++ b/ebill_postfinance_stock/models/ebill_postfinance_invoice_message.py @@ -0,0 +1,24 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +import os + +from odoo import models +from odoo.modules.module import get_module_root + +MODULE_PATH = get_module_root(os.path.dirname(__file__)) +INVOICE_LINE_STOCK_TEMPLATE = "invoice-line-stock-yellowbill.jinja" +TEMPLATE_DIR = [MODULE_PATH + "/messages"] + + +class EbillPostfinanceInvoiceMessage(models.Model): + _inherit = "ebill.postfinance.invoice.message" + + def _get_jinja_env(self, template_dir): + template_dir += TEMPLATE_DIR + return super()._get_jinja_env(template_dir) + + def _get_payload_params_yb(self): + params = super()._get_payload_params_yb() + params["invoice_line_stock_template"] = INVOICE_LINE_STOCK_TEMPLATE + return params diff --git a/ebill_postfinance_stock/pyproject.toml b/ebill_postfinance_stock/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/ebill_postfinance_stock/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/ebill_postfinance_stock/readme/CONTRIBUTORS.md b/ebill_postfinance_stock/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..62ceaf42f --- /dev/null +++ b/ebill_postfinance_stock/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +- Thierry Ducrest \<\> diff --git a/ebill_postfinance_stock/readme/DESCRIPTION.md b/ebill_postfinance_stock/readme/DESCRIPTION.md new file mode 100644 index 000000000..f32add70e --- /dev/null +++ b/ebill_postfinance_stock/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds some information related to delivery in the eBill +Postfinance integration. diff --git a/ebill_postfinance_stock/static/description/icon.png b/ebill_postfinance_stock/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/ebill_postfinance_stock/static/description/icon.png differ diff --git a/ebill_postfinance_stock/static/description/index.html b/ebill_postfinance_stock/static/description/index.html new file mode 100644 index 000000000..7044c6e6e --- /dev/null +++ b/ebill_postfinance_stock/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +eBill Postfinance Stock + + + +
+

eBill Postfinance Stock

+ + +

Beta License: AGPL-3 OCA/l10n-switzerland Translate me on Weblate Try me on Runboat

+

This module adds some information related to delivery in the eBill +Postfinance integration.

+

Table of contents

+ +
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

TDu

+

This module is part of the OCA/l10n-switzerland project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/ebill_postfinance_stock/tests/__init__.py b/ebill_postfinance_stock/tests/__init__.py new file mode 100644 index 000000000..d5235b1f0 --- /dev/null +++ b/ebill_postfinance_stock/tests/__init__.py @@ -0,0 +1 @@ +from . import test_ebill_postfinance_message_yb diff --git a/ebill_postfinance_stock/tests/examples/invoice_qr_yb.xml b/ebill_postfinance_stock/tests/examples/invoice_qr_yb.xml new file mode 100644 index 000000000..8449f8b3c --- /dev/null +++ b/ebill_postfinance_stock/tests/examples/invoice_qr_yb.xml @@ -0,0 +1,192 @@ + + +
+ Camptocamp SA + IPECeBILLServer + CreateybInvoice + 1 + 2.0 + 0 + Odoo + 14.0 +
+ + + 41101000001021209 + 41010198248040391 + 2019-06-21 + $TRANSACTION_ID + PDFAppendix + + + +
+ BILL + INV_TEST_01 + 2019-06-21 + + VAT + +
+ Camptocamp SA + StreetOne + 1015 + Lausanne + CH + info@camptocamp.com +
+ CHE012345678 +
+
+ + + $CUSTOMER_ID +
+ Test RAD Customer XML + Teststrasse 100 + This is a very long street name that should be sna + 1700 + Fribourg + CH +
+ +
+
+ +
+ Test RAD Customer XML + 1700 + Fribourg + CH + +
+
+ + 2019-06-21 + 2019-06-21 + + CHF + + + 1 + OrderReference + CustomerRef + + 2019-06-01 + + en + + 2019-07-01 + IBAN + Yes + + 777 + Reserve + CH2130808001234567827 + 210000000003139471430009017 + + + +
+ + + NORMAL + 1 + Product Q & A + 370003021 + 4.0 + Units + 1 + + + 7.7 + 37.88 + 492.0 + 529.88 + + 37.88 + + 529.88 + 492.0 + + 2 + OrderNumberBySupplier + Order123 + + + 3 + OrderNumberByBuyer + CustomerRef + + + 4 + DeliveryNoteNumber + Picking Name + + + + NORMAL + 2 + Product With a Very Long Name That Need To Be Truncated + 370003022 + 1.0 + Units + 1 + + + 7.7 + 0.0 + 0.0 + 0.0 + + 0.0 + + 0.0 + 0.0 + + 5 + OrderNumberBySupplier + Order123 + + + 6 + OrderNumberByBuyer + CustomerRef + + + 7 + DeliveryNoteNumber + Picking Name + + + + NORMAL + 3 + Phone support + 4.0 + PCE + 1 + 0.0 + 0.0 + + + + + + 7.7 + 37.88 + 492.0 + 529.88 + + 37.88 + + 492.0 + 529.88 + + 529.88 + +
+ + + +
diff --git a/ebill_postfinance_stock/tests/test_ebill_postfinance_message_yb.py b/ebill_postfinance_stock/tests/test_ebill_postfinance_message_yb.py new file mode 100644 index 000000000..32aeea517 --- /dev/null +++ b/ebill_postfinance_stock/tests/test_ebill_postfinance_message_yb.py @@ -0,0 +1,60 @@ +# Copyright 2022 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) + +from string import Template + +from freezegun import freeze_time +from lxml import etree as ET + +from odoo.modules.module import get_module_path +from odoo.tools import file_open + +from odoo.addons.ebill_postfinance.tests.common import CommonCase + + +@freeze_time("2019-06-21 09:06:00") +class TestEbillPostfinanceMessageYB(CommonCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.schema_file = ( + get_module_path("ebill_postfinance") + "/messages/ybInvoice_V2.0.4.xsd" + ) + cls.pickings = cls.sale.order_line.move_ids.mapped("picking_id") + cls.pickings[0].name = "Picking Name" + for line in cls.pickings.move_ids.move_line_ids: + line.picked = True + cls.pickings._action_done() + + def test_invoice_qr(self): + """Check XML payload genetated for an invoice.""" + self.invoice.name = "INV_TEST_01" + self.invoice.invoice_date_due = "2019-07-01" + message = self.invoice.create_postfinance_ebill() + message.set_transaction_id() + message.payload = message._generate_payload_yb() + # Validate the xml generated on top of the xsd schema + node = ET.fromstring(message.payload.encode("utf-8")) + self.assertXmlValidXSchema(node, xschema=None, filename=self.schema_file) + # Remove the PDF file data from the XML to ease diff check + lines = message.payload.splitlines() + for pos, line in enumerate(lines): + if line.find("MimeType") != -1: + lines.pop(pos) + break + payload = "\n".join(lines).encode("utf8") + # Prepare the XML file that is expected + expected_tmpl = Template( + file_open("ebill_postfinance_stock/tests/examples/invoice_qr_yb.xml").read() + ) + expected = expected_tmpl.substitute( + TRANSACTION_ID=message.transaction_id, CUSTOMER_ID=self.customer.id + ).encode("utf8") + # Remove the comments in the expected xml + expected_nocomment = [ + line + for line in expected.split(b"\n") + if not line.lstrip().startswith(b"