Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! edi_sale_ubl: split input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Dec 5, 2024
1 parent 6672496 commit 98fa29d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
8 changes: 0 additions & 8 deletions edi_sale_ubl_input_oca/tests/test_order_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,3 @@ def test_cancel(self):
self.assertTrue(order.edi_state_id.code, order.EDI_STATE_ORDER_ACCEPTED)
order.action_cancel()
self.assertTrue(order.edi_state_id.code, order.EDI_STATE_ORDER_REJECTED)

# def _find_order(self):
# return self.env["sale.order"].search(
# [
# ("client_order_ref", "=", self.order_data.client_order_ref),
# ("commercial_partner_id", "=", self.order_data.partner.parent_id.id),
# ]
# )
35 changes: 20 additions & 15 deletions edi_sale_ubl_input_oca/tests/test_order_in_full_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,31 @@ def setUpClass(cls):
def _get_backend(cls):
return cls.env.ref("edi_ubl_oca.edi_backend_ubl_demo")

def _create_order(self):
# Simulate order creation via incoming EDI exchange
order = self.env["sale.order"].create(
{
"client_order_ref": self.client_order_ref,
"partner_id": self.order_data.partner.id,
"origin_exchange_record_id": self.exc_record_in.id,
}
)
self.exc_record_in._set_related_record(order)
self.exc_type_in.edi_exchange_state = "input_processed"
return order

# No need to test sending data
@mock.patch("odoo.addons.edi_oca.models.edi_backend.EDIBackend._exchange_send")
def test_new_order(self, mock_send):
order = self._create_order()
order = self._find_order()
self.backend._check_input_exchange_sync()
self.assertEqual(self.exc_record_in.edi_exchange_state, "input_processed")
order = self._find_order()
order.partner_id.edi_sale_conf_ids = self.edi_conf
self.assertEqual(self.exc_record_in.record, order)
order_msg = order.message_ids[0]
self.assertIn("Exchange processed successfully", order_msg.body)
self.assertIn(self.exc_record_in.identifier, order_msg.body)
order.invalidate_cache()
# Test relations
self.assertEqual(len(order.exchange_record_ids), 1)
order.action_confirm()
exc_record = order.exchange_record_ids.filtered(
lambda x: x.type_id == self.exc_type_in
)
self.assertEqual(exc_record, self.exc_record_in)
# Confirm the order
with mock.patch.object(
type(self.backend), "_exchange_generate"
) as mock_generate:
mock_generate.return_value = "<xml>fake</xml>"
order.action_confirm()
# Should give us a valid order response ack record
ack_exc_record = order.exchange_record_ids.filtered(
lambda x: x.type_id == self.exc_type_out
Expand Down

0 comments on commit 98fa29d

Please sign in to comment.