From 69185f2460b1cf427ebbec319d8919efa4626c5d Mon Sep 17 00:00:00 2001 From: Mono Mono Date: Sat, 16 Aug 2025 12:24:05 -0500 Subject: [PATCH] fix(Tryton Shop): add shops. --- tienda_ilusion/don_confiao/api_views.py | 10 +++++++--- .../tests/test_exportar_ventas_para_tryton.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tienda_ilusion/don_confiao/api_views.py b/tienda_ilusion/don_confiao/api_views.py index ad12d25..616865d 100644 --- a/tienda_ilusion/don_confiao/api_views.py +++ b/tienda_ilusion/don_confiao/api_views.py @@ -18,6 +18,9 @@ TRYTON_HOST = os.environ.get('TRYTON_HOST', 'localhost') TRYTON_DATABASE = os.environ.get('TRYTON_DATABASE', 'tryton') TRYTON_USERNAME = os.environ.get('TRYTON_USERNAME', 'admin') TRYTON_PASSWORD = os.environ.get('TRYTON_PASSWORD', 'admin') +TRYTON_COP_CURRENCY = 31 +TRYTON_COMPANY_ID = 1 +TRYTON_SHOPS = [1] class Pagination(PageNumberPagination): @@ -183,7 +186,8 @@ class SalesToTrytonView(APIView): ) tryton_client.connect() method = 'model.sale.sale.create' - tryton_context = {} + tryton_context = {'company': TRYTON_COMPANY_ID, + 'shops': TRYTON_SHOPS} successful = [] failed = [] @@ -219,10 +223,10 @@ class TrytonSale: def to_tryton(self): return { - "company": 1, + "company": TRYTON_COMPANY_ID, "shipment_address": self.sale.customer.address_external_id, "invoice_address": self.sale.customer.address_external_id, - "currency": 1, + "currency": TRYTON_COP_CURRENCY, "description": self.sale.description or '', "party": self.sale.customer.external_id, "reference": "don_confiao " + str(self.sale.id), diff --git a/tienda_ilusion/don_confiao/tests/test_exportar_ventas_para_tryton.py b/tienda_ilusion/don_confiao/tests/test_exportar_ventas_para_tryton.py index c05065d..a5efa8d 100644 --- a/tienda_ilusion/don_confiao/tests/test_exportar_ventas_para_tryton.py +++ b/tienda_ilusion/don_confiao/tests/test_exportar_ventas_para_tryton.py @@ -100,4 +100,4 @@ class TestExportarVentasParaTryton(TestCase): self.assertEqual(updated_sale.external_id, external_id) mock_connect.assert_called_once() mock_call.assert_called_once() - mock_call.assert_called_with('model.sale.sale.create', [[{'company': 1, 'shipment_address': '1', 'invoice_address': '1', 'currency': 1, 'description': '', 'party': '1', 'reference': 'don_confiao 1', 'sale_date': {'__class__': 'date', 'year': 2024, 'month': 9, 'day': 2}, 'lines': [['create', [{'product': '1', 'quantity': {'__class__': 'Decimal', 'decimal': '2.00'}, 'type': 'line', 'unit': '1', 'unit_price': {'__class__': 'Decimal', 'decimal': '3000.00'}}, {'product': '1', 'quantity': {'__class__': 'Decimal', 'decimal': '3.00'}, 'type': 'line', 'unit': '1', 'unit_price': {'__class__': 'Decimal', 'decimal': '5000.00'}}]]]}], {}]) + mock_call.assert_called_with('model.sale.sale.create', [[{'company': 1, 'shipment_address': '1', 'invoice_address': '1', 'currency': 31, 'description': '', 'party': '1', 'reference': 'don_confiao 1', 'sale_date': {'__class__': 'date', 'year': 2024, 'month': 9, 'day': 2}, 'lines': [['create', [{'product': '1', 'quantity': {'__class__': 'Decimal', 'decimal': '2.00'}, 'type': 'line', 'unit': '1', 'unit_price': {'__class__': 'Decimal', 'decimal': '3000.00'}}, {'product': '1', 'quantity': {'__class__': 'Decimal', 'decimal': '3.00'}, 'type': 'line', 'unit': '1', 'unit_price': {'__class__': 'Decimal', 'decimal': '5000.00'}}]]]}], {'company': 1, 'shops': [1]}])