-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the dependency on stock in the `ebill_postfinance` module. And add a new module `ebill_postfinance_stock` that will integrate in the xml invoice informations related to the deliveries. This is for Odoo implementation that sell only services and have no stock to manage. And do not use the `stock` module.
- Loading branch information
Showing
17 changed files
with
133 additions
and
28 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 |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
"l10n_ch_qriban", | ||
"queue_job", | ||
"sale", | ||
"sale_stock", | ||
], | ||
"external_dependencies": { | ||
"python": [ | ||
|
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
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,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": "14.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, | ||
} |
10 changes: 10 additions & 0 deletions
10
ebill_postfinance_stock/messages/invoice-line-stock-yellowbill.jinja
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,10 @@ | ||
{% for picking in line.sale_line_ids.move_ids.mapped('picking_id') %} | ||
{%- if picking.state != 'cancel' %} | ||
{% set ref.position = ref.position + 1 %} | ||
<FixedReference> | ||
<ReferencePosition>{{ ref.position }}</ReferencePosition> | ||
<ReferenceType>DeliveryNoteNumber</ReferenceType> | ||
<ReferenceValue>{{ picking.name }}</ReferenceValue> | ||
</FixedReference> | ||
{%- endif %} | ||
{% endfor %} |
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 ebill_postfinance_invoice_message |
24 changes: 24 additions & 0 deletions
24
ebill_postfinance_stock/models/ebill_postfinance_invoice_message.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,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 |
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 @@ | ||
* Thierry Ducrest <[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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This module adds some information related to delivery in the eBill Postfinance integration. |
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 test_ebill_postfinance_message_yb |
60 changes: 60 additions & 0 deletions
60
ebill_postfinance_stock/tests/test_ebill_postfinance_message_yb.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,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_lines.move_line_ids: | ||
line.qty_done = line.product_qty | ||
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"<!--") | ||
] | ||
expected_nocomment = b"\n".join(expected_nocomment) | ||
self.assertFalse(self.compare_xml_line_by_line(payload, expected_nocomment)) |
1 change: 1 addition & 0 deletions
1
setup/ebill_postfinance_stock/odoo/addons/ebill_postfinance_stock
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 @@ | ||
../../../../ebill_postfinance_stock |
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,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |