Skip to content

Commit

Permalink
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 cddbdc5 commit 6672496
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 5 additions & 1 deletion edi_sale_ubl_oca/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ def read_test_file(filename):

class OrderInboundTestMixin:
@classmethod
def _setup_inbound_order(cls, backend, type_in):
def _setup_inbound_record(cls, backend, type_in):
cls.exc_type_in = type_in
cls.exc_type_in.backend_id = backend
cls.exc_record_in = backend.create_record(
cls.exc_type_in.code, {"edi_exchange_state": "input_received"}
)

@classmethod
def _setup_inbound_order(cls, backend, type_in):
cls._setup_inbound_record(backend, type_in)
cls.ubl_data = get_test_data(cls.env)
# Ensure all products have a barcode
for data in cls.ubl_data.values():
Expand Down
3 changes: 1 addition & 2 deletions edi_sale_ubl_output_oca/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"author": "Camptocamp,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/edi",
"depends": [
"edi_sale_oca",
"edi_ubl_oca",
"edi_sale_ubl_oca",
"edi_xml_oca",
"edi_exchange_template_oca",
"edi_exchange_template_party_data",
Expand Down
15 changes: 9 additions & 6 deletions edi_sale_ubl_output_oca/tests/test_order_in_full_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class TestOrderInboundFull(EDIBackendCommonComponentTestCase, OrderInboundTestMi

_schema_path = "base_ubl:data/xsd-2.2/maindoc/UBL-OrderResponse-2.2.xsd"

maxDiff = None

@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -32,7 +30,6 @@ def setUpClass(cls):
cls.exc_type_in = cls.env.ref(
"edi_sale_ubl_output_oca.demo_edi_sale_ubl_output_so_in"
)
cls._setup_inbound_order(cls.backend, cls.exc_type_in)
cls.edi_conf = cls.env.ref(
"edi_sale_oca.demo_edi_configuration_confirmed"
).copy(
Expand All @@ -42,17 +39,24 @@ def setUpClass(cls):
"backend_id": cls.backend.id,
}
)
cls._setup_inbound_record(cls.backend, cls.exc_type_in)

@classmethod
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
partner = self.env["res.partner"].create(
{
"name": "Test Partner",
"edi_sale_conf_ids": [(4, self.edi_conf.id)],
}
)
order = self.env["sale.order"].create(
{
"client_order_ref": self.client_order_ref,
"partner_id": self.order_data.partner.id,
"client_order_ref": "12345",
"partner_id": partner.id,
"origin_exchange_record_id": self.exc_record_in.id,
"commitment_date": fields.Date.today(),
}
Expand All @@ -66,7 +70,6 @@ def _create_order(self):
@mock.patch("odoo.addons.edi_oca.models.edi_backend.EDIBackend._exchange_send")
def test_new_order(self, mock_send):
order = self._create_order()
order.partner_id.edi_sale_conf_ids = self.edi_conf
self.assertEqual(len(order.exchange_record_ids), 1)
order.action_confirm()
# Should give us a valid order response ack record
Expand Down

0 comments on commit 6672496

Please sign in to comment.