From cf4d4a05fd5ea3ada678254949be5ec38be0a7d4 Mon Sep 17 00:00:00 2001 From: Cedric Snauwaert Date: Thu, 9 Aug 2018 16:12:35 +0200 Subject: [PATCH] [FIX] account: the account.move.line.reconcile is not used anymore so remove it --- addons/account/__manifest__.py | 1 - addons/account/tests/test_reconciliation.py | 10 +- addons/account/wizard/__init__.py | 1 - addons/account/wizard/account_reconcile.py | 108 ------------------ .../account/wizard/account_reconcile_view.xml | 56 --------- 5 files changed, 4 insertions(+), 172 deletions(-) delete mode 100644 addons/account/wizard/account_reconcile.py delete mode 100644 addons/account/wizard/account_reconcile_view.xml diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index 1f0aa99d6a4..c99baf6f130 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -24,7 +24,6 @@ You could use this simplified accounting in case you work with an (external) acc 'data/digest_data.xml', 'views/account_menuitem.xml', 'views/account_payment_view.xml', - 'wizard/account_reconcile_view.xml', 'wizard/account_unreconcile_view.xml', 'wizard/account_move_reversal_view.xml', 'views/account_view.xml', diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index 226108ffbba..1e23f2d887b 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -393,9 +393,8 @@ class TestReconciliation(AccountingTestCase): move_ids = [] for name, amount, amount_currency, currency_id in move_list_vals: move_ids.append(create_move(name, amount, amount_currency, currency_id)) - aml_recs = self.env['account.move.line'].search([('move_id', 'in', move_ids), ('account_id', '=', self.account_rcv.id)]) - wizard = self.env['account.move.line.reconcile'].with_context(active_ids=[x.id for x in aml_recs]).create({}) - wizard.trans_rec_reconcile_full() + aml_recs = self.env['account.move.line'].search([('move_id', 'in', move_ids), ('account_id', '=', self.account_rcv.id), ('reconciled', '=', False)]) + aml_recs.reconcile() for aml in aml_recs: self.assertTrue(aml.reconciled, 'The journal item should be totally reconciled') self.assertEquals(aml.amount_residual, 0, 'The journal item should be totally reconciled') @@ -411,9 +410,8 @@ class TestReconciliation(AccountingTestCase): move_ids = [] for name, amount, amount_currency, currency_id in move_list_vals: move_ids.append(create_move(name, amount, amount_currency, currency_id)) - aml_recs = self.env['account.move.line'].search([('move_id', 'in', move_ids), ('account_id', '=', self.account_rcv.id)]) - wizard = self.env['account.move.line.reconcile.writeoff'].with_context(active_ids=[x.id for x in aml_recs]).create({'journal_id': self.bank_journal_usd.id, 'writeoff_acc_id': self.account_rsa.id}) - wizard.trans_rec_reconcile() + aml_recs = self.env['account.move.line'].search([('move_id', 'in', move_ids), ('account_id', '=', self.account_rcv.id), ('reconciled', '=', False)]) + aml_recs.reconcile(self.account_rsa, self.bank_journal_usd) for aml in aml_recs: self.assertTrue(aml.reconciled, 'The journal item should be totally reconciled') self.assertEquals(aml.amount_residual, 0, 'The journal item should be totally reconciled') diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py index 583ed252aeb..b7374520988 100644 --- a/addons/account/wizard/__init__.py +++ b/addons/account/wizard/__init__.py @@ -2,7 +2,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. -from . import account_reconcile from . import account_unreconcile from . import account_invoice_refund from . import account_invoice_state diff --git a/addons/account/wizard/account_reconcile.py b/addons/account/wizard/account_reconcile.py deleted file mode 100644 index 7476725b039..00000000000 --- a/addons/account/wizard/account_reconcile.py +++ /dev/null @@ -1,108 +0,0 @@ -from odoo import models, fields, api, _ -from odoo.tools.float_utils import float_round - - -class AccountMoveLineReconcile(models.TransientModel): - """ - Account move line reconcile wizard, it checks for the write off the reconcile entry or directly reconcile. - """ - _name = 'account.move.line.reconcile' - _description = 'Account move line reconcile' - - trans_nbr = fields.Integer(string='Transaction Count', readonly=True) - credit = fields.Float(string='Credit amount', readonly=True, digits=0) - debit = fields.Float(string='Debit amount', readonly=True, digits=0) - writeoff = fields.Float(string='Write-Off amount', readonly=True, digits=0) - company_id = fields.Many2one('res.company', string='Company', required=True, default=lambda self: self.env.user.company_id) - - @api.model - def default_get(self, fields): - res = super(AccountMoveLineReconcile, self).default_get(fields) - data = self.trans_rec_get() - if 'trans_nbr' in fields: - res.update({'trans_nbr': data['trans_nbr']}) - if 'credit' in fields: - res.update({'credit': data['credit']}) - if 'debit' in fields: - res.update({'debit': data['debit']}) - if 'writeoff' in fields: - res.update({'writeoff': data['writeoff']}) - return res - - @api.multi - def trans_rec_get(self): - context = self._context or {} - credit = debit = 0 - lines = self.env['account.move.line'].browse(context.get('active_ids', [])) - for line in lines: - if not line.full_reconcile_id: - credit += line.credit - debit += line.debit - precision = self.env.user.company_id.currency_id.decimal_places - writeoff = float_round(debit - credit, precision_digits=precision) - credit = float_round(credit, precision_digits=precision) - debit = float_round(debit, precision_digits=precision) - return {'trans_nbr': len(lines), 'credit': credit, 'debit': debit, 'writeoff': writeoff} - - @api.multi - def trans_rec_addendum_writeoff(self): - return self.env['account.move.line.reconcile.writeoff'].trans_rec_addendum() - - @api.multi - def trans_rec_reconcile_partial_reconcile(self): - return self.env['account.move.line.reconcile.writeoff'].trans_rec_reconcile_partial() - - @api.multi - def trans_rec_reconcile_full(self): - move_lines = self.env['account.move.line'].browse(self._context.get('active_ids', [])) - #Don't consider entries that are already reconciled - move_lines_filtered = move_lines.filtered(lambda aml: not aml.reconciled) - move_lines_filtered.reconcile() - return {'type': 'ir.actions.act_window_close'} - - -class AccountMoveLineReconcileWriteoff(models.TransientModel): - """ - It opens the write off wizard form, in that user can define the journal, account, analytic account for reconcile - """ - _name = 'account.move.line.reconcile.writeoff' - _description = 'Account move line reconcile (writeoff)' - - journal_id = fields.Many2one('account.journal', string='Write-Off Journal', required=True) - writeoff_acc_id = fields.Many2one('account.account', string='Write-Off account', required=True, domain=[('deprecated', '=', False)]) - date_p = fields.Date(string='Date', default=fields.Date.context_today) - comment = fields.Char(required=True, default='Write-off') - analytic_id = fields.Many2one('account.analytic.account', string='Analytic Account') - - @api.multi - def trans_rec_addendum(self): - view = self.env.ref('account.account_move_line_reconcile_writeoff') - return { - 'name': _('Reconcile Writeoff'), - 'context': self._context, - 'view_type': 'form', - 'view_mode': 'form', - 'res_model': 'account.move.line.reconcile.writeoff', - 'views': [(view.id, 'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - } - - @api.multi - def trans_rec_reconcile_partial(self): - context = self._context or {} - self.env['account.move.line'].browse(context.get('active_ids', [])).reconcile() - return {'type': 'ir.actions.act_window_close'} - - @api.multi - def trans_rec_reconcile(self): - context = dict(self._context or {}) - context['date_p'] = self.date_p - context['comment'] = self.comment - if self.analytic_id: - context['analytic_id'] = self.analytic_id.id - move_lines = self.env['account.move.line'].browse(self._context.get('active_ids', [])) - #Don't consider entries that are already reconciled - move_lines_filtered = move_lines.filtered(lambda aml: not aml.reconciled) - writeoff = move_lines_filtered.with_context(context).reconcile(self.writeoff_acc_id, self.journal_id) - return {'type': 'ir.actions.act_window_close'} diff --git a/addons/account/wizard/account_reconcile_view.xml b/addons/account/wizard/account_reconcile_view.xml deleted file mode 100644 index 1837655073b..00000000000 --- a/addons/account/wizard/account_reconcile_view.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - account.move.line.reconcile.full.form - account.move.line.reconcile - -
- - - - - - - - - -
-
-
-
-
- - - Reconcile Entries - manual_reconciliation_view - - action - - - - account.move.line.reconcile.writeoff.form - account.move.line.reconcile.writeoff - -
- - - - - - - - -
-
-
-
-