From eb53ba93a3a3dc7d6521779a18b3879abfbc5b83 Mon Sep 17 00:00:00 2001 From: Felipe Garcia Suez Date: Wed, 18 Sep 2024 18:12:33 +0000 Subject: [PATCH] [ADD] account_ux: Account ux unitary test closes ingadhoc/account-financial-tools#553 Signed-off-by: rov-adhoc --- account_ux/tests/__init__.py | 1 + account_ux/tests/test_account_ux.py | 46 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 account_ux/tests/__init__.py create mode 100644 account_ux/tests/test_account_ux.py diff --git a/account_ux/tests/__init__.py b/account_ux/tests/__init__.py new file mode 100644 index 000000000..d78b339e1 --- /dev/null +++ b/account_ux/tests/__init__.py @@ -0,0 +1 @@ +from . import test_account_ux diff --git a/account_ux/tests/test_account_ux.py b/account_ux/tests/test_account_ux.py new file mode 100644 index 000000000..7fa4fff50 --- /dev/null +++ b/account_ux/tests/test_account_ux.py @@ -0,0 +1,46 @@ +import odoo.tests.common as common +from odoo import Command, fields + + +class TestAccountUXChangeCurrency(common.TransactionCase): + + def setUp(self): + super().setUp() + self.today = fields.Date.today() + self.first_company = self.env['res.company'].search([], limit=1) + self.partner_ri = self.env['res.partner'].search([], limit=1) + + self.currency_usd = self.env['res.currency'].search([('name', '=', 'USD')]) + self.currency_ars = self.env['res.currency'].search([('name', '=', 'ARS'), ('active', 'in', [False])]) + self.currency_ars.active = True + + self.first_company_journal_usd = self.env['account.journal'].search([('company_id', '=', self.first_company.id), ('type', '=', 'sale')], limit=1) + self.first_company_journal_ars = self.env['account.journal'].create({ + 'name': 'ARS sale journal', + 'company_id': self.first_company.id, + 'type': 'sale', + 'currency_id': self.currency_ars.id, + 'code': 'ARS' + }) + + def test_account_ux_change_currency(self): + invoice = self.env['account.move'].create({ + 'partner_id': self.partner_ri.id, + 'date': self.today, + 'move_type': 'out_invoice', + 'journal_id': self.first_company_journal_usd.id, + 'company_id': self.first_company.id, + 'invoice_line_ids': [ + Command.create({ + 'product_id': self.env.ref('product.product_product_16').id, + 'quantity': 1, + 'price_unit': 1000, + }), + ], + }) + invoice.write({ + 'journal_id': self.first_company_journal_ars.id + }) + invoice.action_post() + + self.assertEqual(invoice.currency_id, self.first_company_journal_ars.currency_id, "La moneda de la factura no esta siendo modificada al cambiar el diario.")