[FIX] account: reconciliation filter when partner found
Have 2 invoices for one partner Have 1 statement, and line, without partner Reconcile it In the filter to search among proposition, type the name of the partner of the invoices The two invoices should appear Click on one of them to add it to the reconciliation Before this commit, the filter was reloaded without the second invoice After this commit, the filter is reloaded with the second invoice OPW 2053615 closes odoo/odoo#35846 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -488,17 +488,22 @@ class AccountReconciliation(models.AbstractModel):
|
||||
])
|
||||
|
||||
domain = expression.OR([domain_reconciliation, domain_matching])
|
||||
partner_domain = []
|
||||
if partner_id:
|
||||
domain = expression.AND([domain, [('partner_id', '=', partner_id)]])
|
||||
partner_domain = [('partner_id', '=', partner_id)]
|
||||
domain = expression.AND([domain, partner_domain])
|
||||
|
||||
# Domain factorized for all reconciliation use cases
|
||||
if search_str:
|
||||
str_domain = self._domain_move_lines(search_str=search_str)
|
||||
if not partner_id:
|
||||
str_domain = expression.OR([
|
||||
str_domain,
|
||||
[('partner_id.name', 'ilike', search_str)]
|
||||
])
|
||||
partner_domain = [('partner_id.name', 'ilike', search_str)]
|
||||
|
||||
str_domain = expression.OR([
|
||||
str_domain,
|
||||
partner_domain,
|
||||
])
|
||||
|
||||
domain = expression.AND([
|
||||
domain,
|
||||
str_domain
|
||||
|
||||
@@ -48,4 +48,50 @@ class TestReconciliationWidget(TestReconciliation):
|
||||
})
|
||||
|
||||
result = self.env['account.reconciliation.widget'].get_bank_statement_line_data(bank_stmt_line.ids)
|
||||
self.assertEqual(result['lines'][0]['reconciliation_proposition'][0]['amount_str'], '$ 50.00')
|
||||
self.assertEqual(result['lines'][0]['reconciliation_proposition'][0]['amount_str'], '$ 50.00')
|
||||
|
||||
def test_filter_partner1(self):
|
||||
inv1 = self.create_invoice(currency_id=self.currency_euro_id)
|
||||
inv2 = self.create_invoice(currency_id=self.currency_euro_id)
|
||||
|
||||
receivable1 = inv1.move_id.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
|
||||
receivable2 = inv2.move_id.line_ids.filtered(lambda l: l.account_id.internal_type == 'receivable')
|
||||
|
||||
bank_stmt = self.acc_bank_stmt_model.create({
|
||||
'company_id': self.env.ref('base.main_company').id,
|
||||
'journal_id': self.bank_journal_euro.id,
|
||||
'date': time.strftime('%Y-07-15'),
|
||||
'name': 'test',
|
||||
})
|
||||
|
||||
bank_stmt_line = self.acc_bank_stmt_line_model.create({
|
||||
'name': 'testLine',
|
||||
'statement_id': bank_stmt.id,
|
||||
'amount': 100,
|
||||
'date': time.strftime('%Y-07-15'),
|
||||
})
|
||||
|
||||
# This is like opening the widget, and type "deco" in the filter
|
||||
mv_lines_rec = self.env['account.reconciliation.widget'].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=False,
|
||||
excluded_ids=[],
|
||||
search_str='deco'
|
||||
)
|
||||
mv_lines_ids = [l['id'] for l in mv_lines_rec]
|
||||
|
||||
self.assertTrue(receivable1.id in mv_lines_ids)
|
||||
self.assertTrue(receivable2.id in mv_lines_ids)
|
||||
|
||||
# This is like clicking on the first receivable
|
||||
partner = inv1.partner_id
|
||||
mv_lines_rec = self.env['account.reconciliation.widget'].get_move_lines_for_bank_statement_line(
|
||||
bank_stmt_line.id,
|
||||
partner_id=partner.id,
|
||||
excluded_ids=[receivable1.id],
|
||||
search_str='deco'
|
||||
)
|
||||
mv_lines_ids = [l['id'] for l in mv_lines_rec]
|
||||
|
||||
self.assertFalse(receivable1.id in mv_lines_ids)
|
||||
self.assertTrue(receivable2.id in mv_lines_ids)
|
||||
|
||||
Reference in New Issue
Block a user