Skip to content

Commit

Permalink
Moves without partner_id are not sent to Upflow anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandregaldeano authored and petrus-v committed Sep 4, 2024
1 parent 012714f commit 92a2dc1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions edi_upflow/components/event_listener_base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Copyright 2023 Foodles (https://www.foodles.com/)
# @author Pierre Verkest <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import logging

from odoo.addons.component.core import Component

log = logging.getLogger(__name__)

class BaseUpflowEventListner(Component):

Expand Down Expand Up @@ -37,6 +39,9 @@ def send_moves_to_upflow(self, moves):
# depends are not computed yet better to refresh value
moves._compute_upflow_type()
for move in moves:
if not move.upflow_commercial_partner_id:
log.warning("No Upflow commercial partner found for move %s, ignoring", move)
continue
exchange_type, pdf_exchange = move.mapping_upflow_exchange().get(
move.upflow_type,
(
Expand Down
29 changes: 29 additions & 0 deletions edi_upflow/tests/test_edi_upflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,35 @@ def test_output_exchange_sync_post_payments_flow(self):
self.assertEqual(len(records), 1)
self.assertEqual(records.edi_exchange_state, "output_sent_and_processed")

def test_post_payments_without_partner_id(self):
with mock.patch(
"odoo.addons.edi_upflow.components"
".edi_output_generate_upflow_post_payments"
".EdiOutputGenerateUpflowPostPayments.generate",
) as m_generate, mock.patch(
"odoo.addons.edi_upflow.components.event_listener_base.log"
) as m_log:
bank_journal, method, payment_date, amount, currency = self._payment_params(
self.invoice,
)
payment = self.env["account.payment"].create(
{
"payment_type": "inbound",
"partner_type": "customer",
"journal_id": bank_journal.id,
"payment_method_id": method.id,
"amount": amount,
"currency_id": currency.id,
"date": payment_date,
}
)
payment.action_post()
m_generate.assert_not_called()
m_log.warning.assert_called_once_with(
"No Upflow commercial partner found for move %s, ignoring",
payment.move_id,
)

@mute_logger("odoo.addons.queue_job.delay")
@responses.activate
def test_output_exchange_sync_post_refunds_flow(self):
Expand Down

0 comments on commit 92a2dc1

Please sign in to comment.