From ba99cc284b7ef620a6e64a939f517b5307cb7eba Mon Sep 17 00:00:00 2001 From: Joan Sisquella Date: Mon, 18 Nov 2024 10:11:23 +0100 Subject: [PATCH] [MIG] account_move_post_date_user: Migration to 12.0 --- account_move_post_date_user/__manifest__.py | 2 +- .../models/account_move.py | 4 +-- .../tests/test_account_move_post_date_user.py | 31 +++++++++++++++---- .../views/account_move.xml | 6 +--- .../odoo/addons/account_move_post_date_user | 1 + setup/account_move_post_date_user/setup.py | 6 ++++ 6 files changed, 36 insertions(+), 14 deletions(-) create mode 120000 setup/account_move_post_date_user/odoo/addons/account_move_post_date_user create mode 100644 setup/account_move_post_date_user/setup.py diff --git a/account_move_post_date_user/__manifest__.py b/account_move_post_date_user/__manifest__.py index 3aaccb4409c..7f22f9c954b 100644 --- a/account_move_post_date_user/__manifest__.py +++ b/account_move_post_date_user/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Account Move Post Date User", "summary": "Trace journal entry posting date and user.", - "version": "13.0.1.0.0", + "version": "12.0.1.0.0", "category": "Accounting", "website": "https://github.com/OCA/account-financial-tools", "author": "ForgeFlow S.L., Odoo Community Association (OCA)", diff --git a/account_move_post_date_user/models/account_move.py b/account_move_post_date_user/models/account_move.py index ed5aa6233e1..562c11678bb 100644 --- a/account_move_post_date_user/models/account_move.py +++ b/account_move_post_date_user/models/account_move.py @@ -14,8 +14,8 @@ class AccountMove(models.Model): "res.users", string="Last Posted by", readonly=True, tracking=True ) - def post(self): - res = super().post() + def post(self, invoice=False): + res = super().post(invoice=invoice) self.write( { "last_post_date": fields.Datetime.now(), diff --git a/account_move_post_date_user/tests/test_account_move_post_date_user.py b/account_move_post_date_user/tests/test_account_move_post_date_user.py index 9a92becbb7d..f68038208bd 100644 --- a/account_move_post_date_user/tests/test_account_move_post_date_user.py +++ b/account_move_post_date_user/tests/test_account_move_post_date_user.py @@ -3,19 +3,38 @@ from odoo import fields from odoo.tests import tagged - -from odoo.addons.account.tests.account_test_savepoint import AccountTestInvoicingCommon +from odoo.addons.account.tests.account_test_classes import AccountingTestCase @tagged("post_install", "-at_install") -class TestAccountMovePostDateUser(AccountTestInvoicingCommon): +class TestAccountMovePostDateUser(AccountingTestCase): def setUp(self): super(TestAccountMovePostDateUser, self).setUp() self.account_move_obj = self.env["account.move"] self.partner = self.browse_ref("base.res_partner_12") - self.account = self.company_data["default_account_revenue"] - self.account2 = self.company_data["default_account_expense"] - self.journal = self.company_data["default_journal_bank"] + self.user_type_revenue = self.env.ref('account.data_account_type_revenue') + self.account = self.env['account.account'].create({ + 'code': 'NC1114', + 'name': 'Revenue Account', + 'user_type_id': self.user_type_revenue.id, + 'reconcile': True + }) + self.account2 = self.account_expense = self.env['account.account'].search([ + ('user_type_id', '=', self.env.ref( + 'account.data_account_type_expenses').id) + ], limit=1) + self.bank = self.env['res.partner.bank'].create({ + 'acc_number': '123456', + 'partner_id': self.env.ref('base.main_partner').id, + 'company_id': self.env.ref('base.main_company').id, + 'bank_id': self.env.ref('base.res_bank_1').id, + }) + self.journal = self.env['account.journal'].create({ + 'name': 'Bank Journal TEST OFX', + 'code': 'BNK12', + 'type': 'bank', + 'bank_account_id': self.bank.id, + }) # create a move and post it self.move = self.account_move_obj.create( diff --git a/account_move_post_date_user/views/account_move.xml b/account_move_post_date_user/views/account_move.xml index e32e222ddb4..2f5d37bc123 100644 --- a/account_move_post_date_user/views/account_move.xml +++ b/account_move_post_date_user/views/account_move.xml @@ -5,11 +5,7 @@ account.move - - - - - + diff --git a/setup/account_move_post_date_user/odoo/addons/account_move_post_date_user b/setup/account_move_post_date_user/odoo/addons/account_move_post_date_user new file mode 120000 index 00000000000..d851a4986f2 --- /dev/null +++ b/setup/account_move_post_date_user/odoo/addons/account_move_post_date_user @@ -0,0 +1 @@ +../../../../account_move_post_date_user \ No newline at end of file diff --git a/setup/account_move_post_date_user/setup.py b/setup/account_move_post_date_user/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/account_move_post_date_user/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)