diff --git a/openupgrade_scripts/scripts/account/tests/data.py b/openupgrade_scripts/scripts/account/tests/data.py index b8a1d2422f73..9b088680aa9a 100644 --- a/openupgrade_scripts/scripts/account/tests/data.py +++ b/openupgrade_scripts/scripts/account/tests/data.py @@ -2,7 +2,13 @@ # call sending wizard on some moves asynchronously action = ( env["account.move"] - .search([("move_type", "=", "out_invoice")]) + .search( + [ + ("move_type", "=", "out_invoice"), + ("state", "=", "posted"), + ("company_id", "=", env.ref("base.main_company").id), + ] + ) .action_send_and_print() ) env[action["res_model"]].with_context(**action["context"]).create( diff --git a/openupgrade_scripts/scripts/account/tests/test_migration.py b/openupgrade_scripts/scripts/account/tests/test_migration.py new file mode 100644 index 000000000000..e9d14568d468 --- /dev/null +++ b/openupgrade_scripts/scripts/account/tests/test_migration.py @@ -0,0 +1,25 @@ +from odoo.tests import TransactionCase + +from odoo.addons.openupgrade_framework import openupgrade_test + + +@openupgrade_test +class TestAccountMigration(TransactionCase): + def test_sending_data(self): + """ + Test that me migrate send_and_print_values correctly to sending_data + """ + moves_with_sending_data = self.env["account.move"].search( + [ + ("sending_data", "!=", False), + ] + ) + self.assertTrue(moves_with_sending_data) + self.assertEqual( + moves_with_sending_data[0].sending_data["author_user_id"], + self.env.user.id, + ) + self.assertEqual( + moves_with_sending_data[0].sending_data["author_partner_id"], + self.env.user.partner_id.id, + )