[FIX]: Account test case fail issue
This commit is contained in:
parent
6c04736170
commit
542bd61eb4
@ -13,6 +13,7 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
_name = 'report.account.report_agedpartnerbalance'
|
||||
|
||||
def _get_partner_move_lines(self, account_type, date_from, target_move, period_length, branch_id):
|
||||
|
||||
periods = {}
|
||||
start = datetime.strptime(date_from, "%Y-%m-%d")
|
||||
for i in range(5)[::-1]:
|
||||
@ -30,8 +31,9 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
company_ids = self.env.context.get('company_ids', (self.env.user.company_id.id,))
|
||||
move_state = ['draft', 'posted']
|
||||
branch = ''
|
||||
if branch_id:
|
||||
branch = 'AND (l.branch_id =' + str(branch_id[0]) + ')'
|
||||
if branch:
|
||||
branch = 'AND ( l.branch_id = ' + str(branch) + ' OR l.branch_id ' \
|
||||
'is NULL)'
|
||||
if target_move == 'posted':
|
||||
move_state = ['posted']
|
||||
arg_list = (tuple(move_state), tuple(account_type))
|
||||
@ -45,6 +47,7 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
reconciliation_clause = '(l.reconciled IS FALSE OR l.id IN %s)'
|
||||
arg_list += (tuple(reconciled_after_date),)
|
||||
arg_list += (date_from, tuple(company_ids))
|
||||
|
||||
query = '''
|
||||
SELECT DISTINCT l.partner_id, UPPER(res_partner.name)
|
||||
FROM account_move_line AS l left join res_partner on l.partner_id = res_partner.id, account_account, account_move am
|
||||
@ -217,7 +220,10 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
else:
|
||||
account_type = ['payable', 'receivable']
|
||||
|
||||
movelines, total, dummy = self._get_partner_move_lines(account_type, date_from, target_move, data['form']['period_length'], data['form'].get('branch_id', False))
|
||||
default_branch_id = data['form'].get('branch_id', False)
|
||||
branch_id = default_branch_id[0]
|
||||
movelines, total, dummy = self._get_partner_move_lines(account_type, date_from, target_move, data['form']['period_length'],
|
||||
branch_id)
|
||||
return {
|
||||
'doc_ids': self.ids,
|
||||
'doc_model': model,
|
||||
|
@ -780,8 +780,9 @@ class TestReconciliation(AccountingTestCase):
|
||||
|
||||
def test_aged_report(self):
|
||||
AgedReport = self.env['report.account.report_agedpartnerbalance'].with_context(include_nullified_amount=True)
|
||||
|
||||
account_type = ['receivable']
|
||||
report_date_to = time.strftime('%Y') + '-07-15'
|
||||
report_date_to = time.strftime('%Y') + '-10-26'
|
||||
partner = self.env['res.partner'].create({'name': 'AgedPartner'})
|
||||
currency = self.env.user.company_id.currency_id
|
||||
|
||||
@ -798,7 +799,9 @@ class TestReconciliation(AccountingTestCase):
|
||||
'partial_id': statement_partial_id.id})
|
||||
|
||||
# Case 1: The invoice and payment are reconciled: Nothing should appear
|
||||
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30, self.env.user.company_id.branch_id)
|
||||
report_lines, total, amls = AgedReport._get_partner_move_lines(
|
||||
account_type, report_date_to, 'posted', 30,
|
||||
self.env.user.company_id.branch_id.id)
|
||||
|
||||
partner_lines = [line for line in report_lines if line['partner_id'] == partner.id]
|
||||
self.assertEqual(partner_lines, [], 'The aged receivable shouldn\'t have lines at this point')
|
||||
@ -807,7 +810,9 @@ class TestReconciliation(AccountingTestCase):
|
||||
# Case 2: The invoice and payment are not reconciled: we should have one line on the report
|
||||
# and 2 amls
|
||||
invoice.move_id.line_ids.with_context(invoice_id=invoice.id).remove_move_reconcile()
|
||||
report_lines, total, amls = AgedReport._get_partner_move_lines(account_type, report_date_to, 'posted', 30, self.env.user.company_id.branch_id)
|
||||
report_lines, total, amls = AgedReport._get_partner_move_lines(
|
||||
account_type, report_date_to, 'posted', 30,
|
||||
self.env.user.company_id.branch_id.id)
|
||||
|
||||
partner_lines = [line for line in report_lines if line['partner_id'] == partner.id]
|
||||
self.assertEqual(partner_lines, [{'trust': 'normal', '1': 0.0, '0': 0.0, 'direction': 0.0, 'partner_id': partner.id, '3': 0.0, 'total': 0.0, 'name': 'AgedPartner', '4': 0.0, '2': 0.0}],
|
||||
|
Loading…
Reference in New Issue
Block a user