-
-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
56 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
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 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="demo_ubl_edi_configuration_confirmed" model="edi.configuration"> | ||
<field name="name">Demo UBL Sale OrderResponse - order confirmed</field> | ||
<field | ||
name="description" | ||
>Show case how you can send out an order response automatically</field> | ||
<field name="code">demo_ubl_edi_sale_ordrsp</field> | ||
<field name="type_id" ref="demo_edi_exc_type_order_response_out" /> | ||
<field name="backend_id" ref="edi_ubl_oca.edi_backend_ubl_demo" /> | ||
<field name="model_id" ref="sale.model_sale_order" /> | ||
<field name="trigger">on_edi_sale_order_state_sale</field> | ||
<field name="snippet_do"> | ||
record._edi_send_via_edi(conf.type_id) | ||
</field> | ||
</record> | ||
</odoo> |
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 |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
# @author: Simone Orsi <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields | ||
from unittest import mock | ||
|
||
from odoo.tests.common import SavepointCase | ||
|
||
from odoo.addons.edi_oca.tests.common import EDIBackendTestMixin | ||
|
@@ -22,15 +23,21 @@ def setUpClass(cls): | |
cls._setup_env() | ||
cls.backend = cls._get_backend() | ||
cls._setup_inbound_order(cls.backend) | ||
cls.edi_conf = cls.env.ref( | ||
"edi_sale_ubl_oca.demo_ubl_edi_configuration_confirmed" | ||
) | ||
|
||
@classmethod | ||
def _get_backend(cls): | ||
return cls.env.ref("edi_ubl_oca.edi_backend_ubl_demo") | ||
|
||
def test_new_order(self): | ||
# 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): | ||
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) | ||
|
@@ -59,29 +66,4 @@ def test_new_order(self): | |
# Test is a valid file | ||
err = handler.validate(file_content) | ||
self.assertEqual(err, None, err) | ||
|
||
# TODO: new test | ||
# Subsequent updates on some fields should trigger new exchanges | ||
xml_data = handler.parse_xml(file_content) | ||
old_date = order.commitment_date | ||
new_date = fields.Date.add(order.commitment_date, days=2) | ||
self.assertEqual( | ||
xml_data["cac:Delivery"][0]["cbc:ActualDeliveryDate"], | ||
fields.Date.to_string(old_date), | ||
) | ||
order.write({"commitment_date": new_date}) | ||
ack_exc_record = order.exchange_record_ids.filtered( | ||
lambda x: x.type_id == self.exc_type_out and x != ack_exc_record | ||
) | ||
self.assertEqual(ack_exc_record.parent_id, self.exc_record_in) | ||
self.assertEqual(ack_exc_record.edi_exchange_state, "output_pending") | ||
file_content = ack_exc_record._get_file_content() | ||
self.assertTrue(file_content) | ||
err = handler.validate(file_content) | ||
self.assertEqual(err, None, err) | ||
# Subsequent updates on some fields should trigger new exchanges | ||
xml_data = handler.parse_xml(file_content) | ||
self.assertEqual( | ||
xml_data["cac:Delivery"][0]["cbc:ActualDeliveryDate"], | ||
fields.Date.to_string(new_date), | ||
) | ||
# TODO: test data |
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 @@ | ||
../../../../edi_sale_ubl_oca |
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, | ||
) |