Skip to content

Commit

Permalink
Merge PR #676 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Aug 29, 2024
2 parents 398c624 + cb506ad commit 21fb6a5
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions ebill_postfinance_customer_free_ref/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions ebill_postfinance_customer_free_ref/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "eBill Postfinance Customer Free Reference",
"summary": "Glue module: ebill_postfinance and sale_order_customer_free_ref",
"version": "14.0.1.0.0",
"license": "AGPL-3",
"author": "Camptocamp,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-switzerland",
"depends": ["ebill_postfinance", "sale_order_customer_free_ref"],
"auto_install": True,
}
2 changes: 2 additions & 0 deletions ebill_postfinance_customer_free_ref/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_move
from . import sale_order
15 changes: 15 additions & 0 deletions ebill_postfinance_customer_free_ref/models/account_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021-2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class AccountMove(models.Model):
_inherit = "account.move"

def get_postfinance_other_reference(self):
ref = super().get_postfinance_other_reference()
for order in self.invoice_line_ids.sale_line_ids.mapped("order_id"):
if order.customer_order_free_ref:
ref.append({"type": "CR", "no": order.customer_order_free_ref})
return ref
14 changes: 14 additions & 0 deletions ebill_postfinance_customer_free_ref/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2021-2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, models


class SaleOrder(models.Model):

_inherit = "sale.order"

@api.depends("customer_order_number")
def _compute_postfinance_ebill_client_order_ref(self):
for order in self:
order.postfinance_ebill_client_order_ref = order.customer_order_number
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Thierry Ducrest <[email protected]>
4 changes: 4 additions & 0 deletions ebill_postfinance_customer_free_ref/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module interconnects the `sale_order_customer_free_ref` from EDI with the `ebill_postfinance` module.

The order reference in the XML messge is set with the `customer_order_number` field.
And the `customer_order_free_ref` is added as a <OTHER-REFERENCE> node.
1 change: 1 addition & 0 deletions ebill_postfinance_customer_free_ref/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_postfinance_customer_free_ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2021-2022 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from ...ebill_postfinance.tests.common import CommonCase


class TestEbillPosfinanceCustomerFreeRef(CommonCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.invoice.name = "INV_TEST_01"
cls.sale.customer_order_number = "888"
cls.sale.customer_order_free_ref = "FREE"

def test_one(self):
self.assertEqual(self.sale.postfinance_ebill_client_order_ref, "888")
self.assertEqual(
self.invoice.get_postfinance_other_reference(),
[{"type": "CR", "no": "FREE"}],
)
6 changes: 6 additions & 0 deletions setup/ebill_postfinance_customer_free_ref/setup.py
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,
)

0 comments on commit 21fb6a5

Please sign in to comment.