diff --git a/addons/account/security/ir.model.access.csv b/addons/account/security/ir.model.access.csv index cddbb5372f2..167d03d8226 100644 --- a/addons/account/security/ir.model.access.csv +++ b/addons/account/security/ir.model.access.csv @@ -126,6 +126,7 @@ access_account_payment,account.payment,model_account_payment,account.group_accou access_account_payment_register,access.account.payment.register,model_account_payment_register,account.group_account_invoice,1,1,1,0 access_account_bank_statement_closebalance,access.account.bank.statement.closebalance,model_account_bank_statement_closebalance,account.group_account_user,1,1,1,0 access_account_automatic_entry_wizard,access.account.automatic.entry.wizard,model_account_automatic_entry_wizard,account.group_account_user,1,1,1,0 +access_account_automatic_entry_wizard_line,access.account.automatic.entry.wizard.line,model_account_automatic_entry_wizard_line,account.group_account_user,1,1,1,1 access_account_unreconcile,access.account.unreconcile,model_account_unreconcile,account.group_account_user,1,1,1,0 access_account_resequence,access.account.resequence.wizard,model_account_resequence_wizard,account.group_account_manager,1,1,1,0 access_validate_account_move,access.validate.account.move,model_validate_account_move,account.group_account_invoice,1,1,1,0 diff --git a/addons/account/tests/__init__.py b/addons/account/tests/__init__.py index 4b81ef9511e..b3a6dc2727a 100644 --- a/addons/account/tests/__init__.py +++ b/addons/account/tests/__init__.py @@ -2,6 +2,7 @@ from . import test_account_move_reconcile from . import test_account_move_payments_widget +from . import test_account_automatic_entry_wizard_period from . import test_account_move_out_invoice from . import test_account_move_out_refund from . import test_account_move_in_invoice diff --git a/addons/account/tests/test_account_automatic_entry_wizard_period.py b/addons/account/tests/test_account_automatic_entry_wizard_period.py new file mode 100644 index 00000000000..bfb9785fd89 --- /dev/null +++ b/addons/account/tests/test_account_automatic_entry_wizard_period.py @@ -0,0 +1,204 @@ +# -*- coding: utf-8 -*- +from odoo.addons.account.tests.common import AccountTestInvoicingCommon +from odoo import fields +from odoo.tests import tagged + + +@tagged('post_install', '-at_install') +class TestAccountAutomaticEntryWizardPeriod(AccountTestInvoicingCommon): + + @classmethod + def setUpClass(cls, chart_template_ref=None): + super().setUpClass(chart_template_ref=chart_template_ref) + + cls.invoice = cls.env['account.move'].create({ + 'move_type': 'out_invoice', + 'date': '2017-01-01', + 'partner_id': cls.partner_a.id, + 'invoice_date': '2017-01-01', + 'invoice_line_ids': [ + (0, 0, { + 'name': "line1", + 'quantity': 1, + 'price_unit': 1000.0, + 'account_id': cls.company_data['default_account_revenue'].id, + }), + (0, 0, { + 'name': "line2", + 'quantity': 1, + 'price_unit': 200.0, + 'account_id': cls.company_data['default_account_revenue'].id, + }), + ] + }) + cls.invoice.action_post() + + cls.accrual_account = cls.env['account.account'].create({ + 'name': "test_accrual_account", + 'code': "TEST", + 'user_type_id': cls.env.ref('account.data_account_type_revenue').id, + 'reconcile': True, + 'company_id': cls.company_data['company'].id, + }) + cls.income_account = cls.company_data['default_account_revenue'] + + cls.Wizard = cls.env['account.automatic.entry.wizard']\ + .with_context(active_model='account.move.line', active_ids=cls.invoice.invoice_line_ids.ids) + + def test_chg_period_100_percent_no_time_division(self): + ''' Test smoothing the invoice in the period without the time division. ''' + to_date = lambda string: fields.Date.from_string(string) + + wizard = self.Wizard.create({ + 'action': 'change_period', + 'journal_id': self.company_data['default_journal_misc'].id, + 'revenue_accrual_account': self.accrual_account.id, + 'chg_period_date_from': '2017-06-01', + 'chg_period_date_to': '2017-12-31', # Large period to check the rounding issues. + 'chg_period_percentage': 100.0, + 'chg_period_time_division': False, + }) + wizard_res = wizard.do_action() + + lines = self.env['account.move'].browse(wizard_res['domain'][0][2]).line_ids.sorted(lambda line: (line.date, -abs(line.balance), -line.balance)) + dest_lines = lines.filtered(lambda line: line.date == self.invoice.date) + accrual_lines = lines.filtered(lambda line: line.date != self.invoice.date) + self.assertRecordValues(dest_lines, [ + {'debit': 1000.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 1000.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + {'debit': 200.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 200.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + ]) + self.assertRecordValues(accrual_lines, [ + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-30')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-30')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-30')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-30')}, + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-31')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-31')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-31')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-31')}, + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-31')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-31')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-31')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-31')}, + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-30')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-30')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-30')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-30')}, + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-10-31')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-10-31')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-10-31')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-10-31')}, + {'debit': 142.86, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-11-30')}, + {'debit': 0.0, 'credit': 142.86, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-11-30')}, + {'debit': 28.57, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-11-30')}, + {'debit': 0.0, 'credit': 28.57, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-11-30')}, + {'debit': 142.84, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-12-31')}, + {'debit': 0.0, 'credit': 142.84, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-12-31')}, + {'debit': 28.58, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-12-31')}, + {'debit': 0.0, 'credit': 28.58, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-12-31')}, + ]) + + def test_chg_period_100_percent_time_division(self): + ''' Same as test_chg_period_100_percent_no_time_division using the time division meaning the smoothing is made + to different months considering their number of days. + ''' + to_date = lambda string: fields.Date.from_string(string) + + wizard = self.Wizard.create({ + 'action': 'change_period', + 'journal_id': self.company_data['default_journal_misc'].id, + 'revenue_accrual_account': self.accrual_account.id, + 'chg_period_date_from': '2017-06-01', + 'chg_period_date_to': '2017-12-31', # Large period to check the rounding issues. + 'chg_period_percentage': 100.0, + 'chg_period_time_division': True, + }) + wizard_res = wizard.do_action() + + lines = self.env['account.move'].browse(wizard_res['domain'][0][2]).line_ids.sorted(lambda line: (line.date, -abs(line.balance), -line.balance)) + dest_lines = lines.filtered(lambda line: line.date == self.invoice.date) + accrual_lines = lines.filtered(lambda line: line.date != self.invoice.date) + self.assertRecordValues(dest_lines, [ + {'debit': 1000.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 1000.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + {'debit': 200.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 200.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + ]) + self.assertRecordValues(accrual_lines, [ + {'debit': 140.1, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-30')}, + {'debit': 0.0, 'credit': 140.1, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-30')}, + {'debit': 28.02, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-30')}, + {'debit': 0.0, 'credit': 28.02, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-30')}, + {'debit': 144.93, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-31')}, + {'debit': 0.0, 'credit': 144.93, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-31')}, + {'debit': 28.99, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-31')}, + {'debit': 0.0, 'credit': 28.99, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-31')}, + {'debit': 144.93, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-31')}, + {'debit': 0.0, 'credit': 144.93, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-31')}, + {'debit': 28.99, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-31')}, + {'debit': 0.0, 'credit': 28.99, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-31')}, + {'debit': 140.1, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-30')}, + {'debit': 0.0, 'credit': 140.1, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-30')}, + {'debit': 28.02, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-30')}, + {'debit': 0.0, 'credit': 28.02, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-30')}, + {'debit': 144.93, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-10-31')}, + {'debit': 0.0, 'credit': 144.93, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-10-31')}, + {'debit': 28.99, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-10-31')}, + {'debit': 0.0, 'credit': 28.99, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-10-31')}, + {'debit': 140.1, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-11-30')}, + {'debit': 0.0, 'credit': 140.1, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-11-30')}, + {'debit': 28.02, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-11-30')}, + {'debit': 0.0, 'credit': 28.02, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-11-30')}, + {'debit': 144.91, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-12-31')}, + {'debit': 0.0, 'credit': 144.91, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-12-31')}, + {'debit': 28.97, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-12-31')}, + {'debit': 0.0, 'credit': 28.97, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-12-31')}, + ]) + + def test_chg_period_manual_periods(self): + ''' Test the smoothing by manual lines. ''' + to_date = lambda string: fields.Date.from_string(string) + + wizard = self.Wizard.create({ + 'action': 'change_period', + 'journal_id': self.company_data['default_journal_misc'].id, + 'revenue_accrual_account': self.accrual_account.id, + 'chg_period_line_ids': [ + (0, 0, {'date': '2017-06-01', 'balance': 120.0}), + (0, 0, {'date': '2017-07-01', 'balance': 300.0}), + (0, 0, {'date': '2017-08-01', 'balance': 700.0}), + (0, 0, {'date': '2017-09-01', 'balance': 80.0}), + ], + }) + wizard_res = wizard.do_action() + + + lines = self.env['account.move'].browse(wizard_res['domain'][0][2]).line_ids.sorted(lambda line: (line.date, -abs(line.balance), -line.balance)) + dest_lines = lines.filtered(lambda line: line.date == self.invoice.date) + accrual_lines = lines.filtered(lambda line: line.date != self.invoice.date) + self.assertRecordValues(dest_lines, [ + {'debit': 1000.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 1000.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + {'debit': 200.0, 'credit': 0.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-01-01')}, + {'debit': 0.0, 'credit': 200.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-01-01')}, + ]) + self.assertRecordValues(accrual_lines, [ + {'debit': 100.0, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-01')}, + {'debit': 0.0, 'credit': 100.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-01')}, + {'debit': 20.0, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-06-01')}, + {'debit': 0.0, 'credit': 20.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-06-01')}, + {'debit': 250.0, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-01')}, + {'debit': 0.0, 'credit': 250.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-01')}, + {'debit': 50.0, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-07-01')}, + {'debit': 0.0, 'credit': 50.0, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-07-01')}, + {'debit': 583.33, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-01')}, + {'debit': 0.0, 'credit': 583.33, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-01')}, + {'debit': 116.67, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-08-01')}, + {'debit': 0.0, 'credit': 116.67, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-08-01')}, + {'debit': 66.67, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-01')}, + {'debit': 0.0, 'credit': 66.67, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-01')}, + {'debit': 13.33, 'credit': 0.0, 'account_id': self.accrual_account.id, 'reconciled': True, 'date': to_date('2017-09-01')}, + {'debit': 0.0, 'credit': 13.33, 'account_id': self.income_account.id, 'reconciled': False, 'date': to_date('2017-09-01')}, + ]) diff --git a/addons/account/tests/test_account_move_in_invoice.py b/addons/account/tests/test_account_move_in_invoice.py index c9df200825c..3a764a28d77 100644 --- a/addons/account/tests/test_account_move_in_invoice.py +++ b/addons/account/tests/test_account_move_in_invoice.py @@ -1656,108 +1656,3 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon): 'amount_total' : self.move_vals['amount_total'], 'amount_untaxed' : self.move_vals['amount_untaxed'], }) - - def test_in_invoice_change_period_accrual_1(self): - move = self.env['account.move'].create({ - 'move_type': 'in_invoice', - 'date': '2017-01-01', - 'partner_id': self.partner_a.id, - 'invoice_date': fields.Date.from_string('2017-01-01'), - 'currency_id': self.currency_data['currency'].id, - 'invoice_payment_term_id': self.pay_terms_a.id, - 'invoice_line_ids': [ - (0, None, { - 'name': self.product_line_vals_1['name'], - 'product_id': self.product_line_vals_1['product_id'], - 'product_uom_id': self.product_line_vals_1['product_uom_id'], - 'quantity': self.product_line_vals_1['quantity'], - 'price_unit': self.product_line_vals_1['price_unit'], - 'tax_ids': self.product_line_vals_1['tax_ids'], - }), - (0, None, { - 'name': self.product_line_vals_2['name'], - 'product_id': self.product_line_vals_2['product_id'], - 'product_uom_id': self.product_line_vals_2['product_uom_id'], - 'quantity': self.product_line_vals_2['quantity'], - 'price_unit': self.product_line_vals_2['price_unit'], - 'tax_ids': self.product_line_vals_2['tax_ids'], - }), - ] - }) - move.action_post() - - wizard = self.env['account.automatic.entry.wizard']\ - .with_context(active_model='account.move.line', active_ids=move.invoice_line_ids.ids).create({ - 'action': 'change_period', - 'date': '2018-01-01', - 'percentage': 60, - 'journal_id': self.company_data['default_journal_misc'].id, - 'expense_accrual_account': self.env['account.account'].create({ - 'name': 'Accrual Expense Account', - 'code': '234567', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, - 'reconcile': True, - }).id, - 'revenue_accrual_account': self.env['account.account'].create({ - 'name': 'Accrual Revenue Account', - 'code': '765432', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, - 'reconcile': True, - }).id, - }) - wizard_res = wizard.do_action() - - self.assertInvoiceValues(move, [ - { - **self.product_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': 800.0, - 'debit': 400.0, - 'credit': 0.0, - }, - { - **self.product_line_vals_2, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': 160.0, - 'debit': 80.0, - 'credit': 0.0, - }, - { - **self.tax_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': 144.0, - 'debit': 72.0, - 'credit': 0.0, - }, - { - **self.tax_line_vals_2, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': 24.0, - 'debit': 12.0, - 'credit': 0.0, - }, - { - **self.term_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': -1128.0, - 'debit': 0.0, - 'credit': 564.0, - 'date_maturity': fields.Date.from_string('2017-01-01'), - }, - ], { - **self.move_vals, - 'currency_id': self.currency_data['currency'].id, - 'date': fields.Date.from_string('2017-01-01'), - }) - - accrual_lines = self.env['account.move'].browse(wizard_res['domain'][0][2]).line_ids.sorted('date') - self.assertRecordValues(accrual_lines, [ - {'amount_currency': -480.0, 'debit': 0.0, 'credit': 240.0, 'account_id': self.product_line_vals_1['account_id'], 'reconciled': False}, - {'amount_currency': 480.0, 'debit': 240.0, 'credit': 0.0, 'account_id': wizard.expense_accrual_account.id, 'reconciled': True}, - {'amount_currency': -96.0, 'debit': 0.0, 'credit': 48.0, 'account_id': self.product_line_vals_2['account_id'], 'reconciled': False}, - {'amount_currency': 96.0, 'debit': 48.0, 'credit': 0.0, 'account_id': wizard.expense_accrual_account.id, 'reconciled': True}, - {'amount_currency': 480.0, 'debit': 240.0, 'credit': 0.0, 'account_id': self.product_line_vals_1['account_id'], 'reconciled': False}, - {'amount_currency': -480.0, 'debit': 0.0, 'credit': 240.0, 'account_id': wizard.expense_accrual_account.id, 'reconciled': True}, - {'amount_currency': 96.0, 'debit': 48.0, 'credit': 0.0, 'account_id': self.product_line_vals_2['account_id'], 'reconciled': False}, - {'amount_currency': -96.0, 'debit': 0.0, 'credit': 48.0, 'account_id': wizard.expense_accrual_account.id, 'reconciled': True}, - ]) diff --git a/addons/account/tests/test_account_move_out_invoice.py b/addons/account/tests/test_account_move_out_invoice.py index b6dc01a68d6..40dc29f70ec 100644 --- a/addons/account/tests/test_account_move_out_invoice.py +++ b/addons/account/tests/test_account_move_out_invoice.py @@ -2424,113 +2424,6 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon): 'amount_untaxed' : self.move_vals['amount_untaxed'], }) - def test_out_invoice_change_period_accrual_1(self): - move = self.env['account.move'].create({ - 'move_type': 'out_invoice', - 'date': '2017-01-01', - 'partner_id': self.partner_a.id, - 'invoice_date': fields.Date.from_string('2017-01-01'), - 'currency_id': self.currency_data['currency'].id, - 'invoice_payment_term_id': self.pay_terms_a.id, - 'invoice_line_ids': [ - (0, None, { - 'name': self.product_line_vals_1['name'], - 'product_id': self.product_line_vals_1['product_id'], - 'product_uom_id': self.product_line_vals_1['product_uom_id'], - 'quantity': self.product_line_vals_1['quantity'], - 'price_unit': self.product_line_vals_1['price_unit'], - 'tax_ids': self.product_line_vals_1['tax_ids'], - }), - (0, None, { - 'name': self.product_line_vals_2['name'], - 'product_id': self.product_line_vals_2['product_id'], - 'product_uom_id': self.product_line_vals_2['product_uom_id'], - 'quantity': self.product_line_vals_2['quantity'], - 'price_unit': self.product_line_vals_2['price_unit'], - 'tax_ids': self.product_line_vals_2['tax_ids'], - }), - ] - }) - move.action_post() - - wizard = self.env['account.automatic.entry.wizard']\ - .with_context(active_model='account.move.line', active_ids=move.invoice_line_ids.ids).create({ - 'action': 'change_period', - 'date': '2018-01-01', - 'percentage': 60, - 'journal_id': self.company_data['default_journal_misc'].id, - 'expense_accrual_account': self.env['account.account'].create({ - 'name': 'Accrual Expense Account', - 'code': '234567', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, - 'reconcile': True, - }).id, - 'revenue_accrual_account': self.env['account.account'].create({ - 'name': 'Accrual Revenue Account', - 'code': '765432', - 'user_type_id': self.env.ref('account.data_account_type_expenses').id, - 'reconcile': True, - }).id, - }) - wizard_res = wizard.do_action() - - self.assertInvoiceValues(move, [ - { - **self.product_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': -1000.0, - 'debit': 0.0, - 'credit': 500.0, - }, - { - **self.product_line_vals_2, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': -200.0, - 'debit': 0.0, - 'credit': 100.0, - }, - { - **self.tax_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': -180.0, - 'debit': 0.0, - 'credit': 90.0, - }, - { - **self.tax_line_vals_2, - 'currency_id': self.currency_data['currency'].id, - 'amount_currency': -30.0, - 'debit': 0.0, - 'credit': 15.0, - }, - { - **self.term_line_vals_1, - 'currency_id': self.currency_data['currency'].id, - 'name': 'INV/2017/01/0001', - 'amount_currency': 1410.0, - 'debit': 705.0, - 'credit': 0.0, - 'date_maturity': fields.Date.from_string('2017-01-01'), - }, - ], { - **self.move_vals, - 'currency_id': self.currency_data['currency'].id, - 'date': fields.Date.from_string('2017-01-01'), - 'payment_reference': 'INV/2017/01/0001', - }) - - accrual_lines = self.env['account.move'].browse(wizard_res['domain'][0][2]).line_ids.sorted('date') - self.assertRecordValues(accrual_lines, [ - {'amount_currency': 600.0, 'debit': 300.0, 'credit': 0.0, 'account_id': self.product_line_vals_1['account_id'], 'reconciled': False}, - {'amount_currency': -600.0, 'debit': 0.0, 'credit': 300.0, 'account_id': wizard.revenue_accrual_account.id, 'reconciled': True}, - {'amount_currency': 120.0, 'debit': 60.0, 'credit': 0.0, 'account_id': self.product_line_vals_2['account_id'], 'reconciled': False}, - {'amount_currency': -120.0, 'debit': 0.0, 'credit': 60.0, 'account_id': wizard.revenue_accrual_account.id, 'reconciled': True}, - {'amount_currency': -600.0, 'debit': 0.0, 'credit': 300.0, 'account_id': self.product_line_vals_1['account_id'], 'reconciled': False}, - {'amount_currency': 600.0, 'debit': 300.0, 'credit': 0.0, 'account_id': wizard.revenue_accrual_account.id, 'reconciled': True}, - {'amount_currency': -120.0, 'debit': 0.0, 'credit': 60.0, 'account_id': self.product_line_vals_2['account_id'], 'reconciled': False}, - {'amount_currency': 120.0, 'debit': 60.0, 'credit': 0.0, 'account_id': wizard.revenue_accrual_account.id, 'reconciled': True}, - ]) - def test_out_invoice_filter_zero_balance_lines(self): zero_balance_payment_term = self.env['account.payment.term'].create({ 'name': 'zero_balance_payment_term', diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index fa1f4203bae..a96b4fa15da 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -1006,7 +1006,7 @@