[9.0][imp][account_mass_reconcile] search for unreconciled entries

using a search default method, instead of a domain. Fixes memory errors.
This commit is contained in:
Jordi Ballester Alomar
2018-10-26 12:07:09 +02:00
parent 69f2e1ac7a
commit adee24d769
2 changed files with 14 additions and 9 deletions

View File

@@ -251,7 +251,7 @@ class AccountMassReconcile(models.Model):
) )
@api.model @api.model
def _open_move_line_list(self, move_line_ids, name): def _open_move_line_list(self, context, name):
return { return {
'name': name, 'name': name,
'view_mode': 'tree,form', 'view_mode': 'tree,form',
@@ -261,19 +261,19 @@ class AccountMassReconcile(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'nodestroy': True, 'nodestroy': True,
'target': 'current', 'target': 'current',
'domain': unicode([('id', 'in', move_line_ids)]), 'context': context,
} }
@api.multi @api.multi
def open_unreconcile(self): def open_unreconcile(self):
""" Open the view of move line with the unreconciled move lines""" """ Open the view of move line with the unreconciled move lines"""
self.ensure_one() self.ensure_one()
obj_move_line = self.env['account.move.line'] context = {
lines = obj_move_line.search( 'search_default_account_id': self.account.id,
[('account_id', '=', self.account.id), 'search_default_unreconciled': True
('reconciled', '=', False)]) }
name = _('Unreconciled items') name = _('Unreconciled items')
return self._open_move_line_list(lines.ids or [], name) return self._open_move_line_list(context, name)
@api.multi @api.multi
def last_history_reconcile(self): def last_history_reconcile(self):

View File

@@ -15,6 +15,7 @@ class TestReconcile(common.TransactionCase):
get_module_resource('account', 'test', get_module_resource('account', 'test',
'account_minimal_test.xml'), 'account_minimal_test.xml'),
{}, 'init', False, 'test') {}, 'init', False, 'test')
self.reconcile_account_id = self.ref('account.a_salary_expense')
self.rec_history_obj = self.env['mass.reconcile.history'] self.rec_history_obj = self.env['mass.reconcile.history']
self.mass_rec_obj = self.env['account.mass.reconcile'] self.mass_rec_obj = self.env['account.mass.reconcile']
self.mass_rec_method_obj = ( self.mass_rec_method_obj = (
@@ -23,7 +24,7 @@ class TestReconcile(common.TransactionCase):
self.mass_rec = self.mass_rec_obj.create( self.mass_rec = self.mass_rec_obj.create(
{ {
'name': 'AER2', 'name': 'AER2',
'account': self.ref('account.a_salary_expense'), 'account': self.reconcile_account_id,
} }
) )
self.mass_rec_method = self.mass_rec_method_obj.create( self.mass_rec_method = self.mass_rec_method_obj.create(
@@ -61,7 +62,11 @@ class TestReconcile(common.TransactionCase):
def test_open_unreconcile(self): def test_open_unreconcile(self):
res = self.mass_rec.open_unreconcile() res = self.mass_rec.open_unreconcile()
self.assertEqual(unicode([('id', 'in', [])]), res.get('domain', [])) context = {
'search_default_account_id': self.reconcile_account_id,
'search_default_unreconciled': True
}
self.assertEqual(context, res.get('context', {}))
def test_prepare_run_transient(self): def test_prepare_run_transient(self):
res = self.mass_rec._prepare_run_transient(self.mass_rec_method) res = self.mass_rec._prepare_run_transient(self.mass_rec_method)