19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:30:07 +01:00
parent ba20ce7443
commit 768b70e05e
2357 changed files with 1057103 additions and 712486 deletions

View file

@ -11,13 +11,13 @@ import time
class TestTransferWizard(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)
def setUpClass(cls):
super().setUpClass()
cls.company = cls.company_data['company']
cls.receivable_account = cls.company_data['default_account_receivable']
cls.payable_account = cls.company_data['default_account_payable']
cls.accounts = cls.env['account.account'].search([('reconcile', '=', False), ('company_id', '=', cls.company.id)], limit=5)
cls.accounts = cls.env['account.account'].search([('reconcile', '=', False), ('company_ids', '=', cls.company.id)], limit=5)
cls.journal = cls.company_data['default_journal_misc']
# Set rate for base currency to 1
@ -193,8 +193,8 @@ class TestTransferWizard(AccountTestInvoicingCommon):
cls.move_2.action_post()
analytic_plan_1, analytic_plan_2 = cls.env['account.analytic.plan'].create([
{'name': 'Plan Test 1', 'company_id': False},
{'name': 'Plan Test 2', 'company_id': False},
{'name': 'Plan Test 1'},
{'name': 'Plan Test 2'},
])
cls.analytic_account_1, cls.analytic_account_2 = cls.env['account.analytic.account'].create([
{
@ -234,7 +234,7 @@ class TestTransferWizard(AccountTestInvoicingCommon):
}),
Command.create({
'account_id': self.payable_account.id,
'balance': -460,
'balance': -400,
}),
]
})
@ -242,16 +242,14 @@ class TestTransferWizard(AccountTestInvoicingCommon):
self.assertRecordValues(move_with_tax.line_ids, [
{'balance': 400, 'account_id': account_with_tax.id},
{'balance': -460, 'account_id': self.payable_account.id},
{'balance': 60, 'account_id': self.company_data['default_account_tax_purchase'].id},
{'balance': -400, 'account_id': self.payable_account.id},
])
# Open the transfer wizard
# We use a form to pass the context properly to the depends_context move_line_ids field
context = {'active_model': 'account.move.line', 'active_ids': move_with_tax.line_ids[0].ids}
context = {'active_model': 'account.move.line', 'active_ids': move_with_tax.line_ids[0].ids, 'default_action': 'change_period'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_period'
wizard_form.date = '2019-05-01'
wizard_form.journal_id = self.company_data['default_journal_misc']
wizard_form.expense_accrual_account = expense_accrual_account
@ -278,9 +276,8 @@ class TestTransferWizard(AccountTestInvoicingCommon):
active_move_lines = (self.move_1 + self.move_2).mapped('line_ids').filtered(lambda x: x.account_id.account_type in ('asset_receivable', 'liability_payable'))
# We use a form to pass the context properly to the depends_context move_line_ids field
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids}
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids, 'default_action': 'change_account'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_account'
wizard_form.destination_account_id = self.receivable_account
wizard_form.journal_id = self.journal
wizard = wizard_form.save()
@ -304,9 +301,8 @@ class TestTransferWizard(AccountTestInvoicingCommon):
active_move_lines = (self.move_1 + self.move_2).mapped('line_ids').filtered(lambda x: x.name in ('test1_3', 'test1_4', 'test1_5', 'test2_3', 'test2_4', 'test2_5', 'test2_6', 'test2_8'))
# We use a form to pass the context properly to the depends_context move_line_ids field
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids}
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids, 'default_action': 'change_account'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_account'
wizard_form.destination_account_id = self.accounts[4]
wizard_form.journal_id = self.journal
wizard = wizard_form.save()
@ -335,9 +331,8 @@ class TestTransferWizard(AccountTestInvoicingCommon):
active_move_lines = self.move_1.mapped('line_ids').filtered(lambda x: x.name in ('test1_6', 'test1_9'))
# We use a form to pass the context properly to the depends_context move_line_ids field
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids}
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids, 'default_action': 'change_account'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_account'
wizard_form.destination_account_id = self.test_currency_account
wizard_form.journal_id = self.journal
wizard = wizard_form.save()
@ -358,9 +353,8 @@ class TestTransferWizard(AccountTestInvoicingCommon):
active_move_lines = self.move_2.mapped('line_ids').filtered(lambda x: x.name in ('test2_9', 'test2_6', 'test2_8'))
# We use a form to pass the context properly to the depends_context move_line_ids field
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids}
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids, 'default_action': 'change_account'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_account'
wizard_form.destination_account_id = self.receivable_account
wizard_form.journal_id = self.journal
wizard = wizard_form.save()
@ -391,19 +385,32 @@ class TestTransferWizard(AccountTestInvoicingCommon):
'reconcile': True,
})
account_with_tax = self.env['account.account'].create({
'name': 'Auto Taxed',
'code': 'autotaxed',
'account_type': 'income',
'tax_ids': [Command.link(self.company_data['default_tax_sale'].id)],
})
# Create a move before the lock date
move = self.env['account.move'].create({
'journal_id': self.company_data['default_journal_sale'].id,
'date': '2019-01-01',
'line_ids': [
Command.create({'account_id': self.accounts[0].id, 'debit': 1000, }),
Command.create({'account_id': self.accounts[0].id, 'credit': 1000, }),
Command.create({'account_id': account_with_tax.id, 'debit': 1000}),
Command.create({'account_id': account_with_tax.id, 'credit': 1000}),
]
})
move.action_post()
# Set the lock date
move.company_id.write({'period_lock_date': '2019-02-28', 'fiscalyear_lock_date': '2019-02-28'})
# (Purchase Lock Date not tested)
move.company_id.write({
'hard_lock_date': '2019-02-28',
'fiscalyear_lock_date': '2019-02-28',
'sale_lock_date': '2019-02-28',
'tax_lock_date': '2019-02-28',
})
# Open the transfer wizard at a date after the lock date
wizard = self.env['account.automatic.entry.wizard'] \
@ -414,9 +421,9 @@ class TestTransferWizard(AccountTestInvoicingCommon):
'journal_id': self.company_data['default_journal_misc'].id,
})
# Check that the 'The date is being set prior to the user lock date' message appears.
# Check that the 'The date is being set prior to ...' message appears.
self.assertRecordValues(wizard, [{
'lock_date_message': 'The date is being set prior to the user lock date 02/28/2019. '
'lock_date_message': 'The date is being set prior to: Global Lock Date (02/28/2019), Hard Lock Date (02/28/2019), and Sales Lock Date (02/28/2019). '
'The Journal Entry will be accounted on 03/31/2019 upon posting.'
}])
@ -483,22 +490,20 @@ class TestTransferWizard(AccountTestInvoicingCommon):
'journal_id': self.company_data['default_journal_misc'].id,
'date': '2019-01-01',
'line_ids': [
Command.create({'account_id': self.accounts[2].id, 'currency_id': self.company.currency_id.id, 'amount_currency': 1000, 'debit': 1000, }),
Command.create({'account_id': self.receivable_account.id, 'currency_id': self.test_currency_1.id, 'amount_currency': 0, 'credit': 1000, }),
Command.create({'account_id': self.accounts[2].id, 'currency_id': self.company.currency_id.id, 'amount_currency': 1000, 'debit': 1000}),
Command.create({'account_id': self.receivable_account.id, 'currency_id': self.test_currency_1.id, 'amount_currency': 0, 'credit': 1000}),
]
})
move.action_post()
active_move_lines = move.line_ids.filtered(lambda line: line.account_id.id == self.receivable_account.id)
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids}
context = {'active_model': 'account.move.line', 'active_ids': active_move_lines.ids, 'default_action': 'change_account'}
with Form(self.env['account.automatic.entry.wizard'].with_context(context)) as wizard_form:
wizard_form.action = 'change_account'
wizard_form.destination_account_id = self.accounts[0]
wizard_form.journal_id = self.company_data['default_journal_misc']
automatic_entry_wizard = wizard_form.save()
transfer_move_id = automatic_entry_wizard.do_action()['res_id']
wizard = wizard_form.save()
transfer_move_id = wizard.do_action()['res_id']
transfer_move = self.env['account.move'].browse(transfer_move_id)
source_line = transfer_move.line_ids.filtered(lambda x: x.account_id == self.receivable_account)