Skip to content

Commit

Permalink
Merge PR #375 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by NL66278
  • Loading branch information
OCA-git-bot committed May 8, 2023
2 parents 0fa49c0 + a6a5d6b commit cdd74af
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
22 changes: 13 additions & 9 deletions l10n_nl_xaf_auditfile_export/models/xaf_auditfile_export.py
Expand Up @@ -26,6 +26,7 @@
JOIN account_account_type t
ON a.user_type_id = t.id
WHERE l.parent_state = 'posted'
AND l.display_type NOT IN ('line_section', 'line_note')
AND l.date < %(date_start)s
AND l.company_id = %(company_id)s
AND (
Expand Down Expand Up @@ -321,6 +322,7 @@ def get_ob_totals(self):
"where a.user_type_id = t.id "
"and l.account_id = a.id "
"and l.parent_state = 'posted' "
"and l.display_type NOT IN ('line_section', 'line_note') "
"and l.date < %s "
"and l.company_id = %s "
"and t.include_initial_balance = true "
Expand Down Expand Up @@ -356,6 +358,7 @@ def get_ob_lines(self):
"and a.id = l.account_id and l.date < %s "
"and l.company_id = %s "
"and l.parent_state = 'posted' "
"and l.display_type NOT IN ('line_section', 'line_note') "
"and t.include_initial_balance = true "
"and t.id != %s "
"group by a.id, a.code",
Expand Down Expand Up @@ -410,15 +413,14 @@ def _get_undistributed_profit_account(self):

def get_move_line_count(self):
"""return amount of move lines"""
self.env.cr.execute(
"select count(*) from account_move_line "
"where date >= %s "
"and date <= %s "
"and parent_state = 'posted' "
"and company_id = %s",
(self.date_start, self.date_end, self.company_id.id),
)
return self.env.cr.fetchall()[0][0]
domain = [
("date", ">=", self.date_start),
("date", "<=", self.date_end),
("parent_state", "=", "posted"),
("display_type", "not in", ("line_section", "line_note")),
("company_id", "=", self.company_id.id),
]
return self.env["account.move.line"].search_count(domain)

def get_move_line_total_debit(self):
"""return total debit of move lines"""
Expand All @@ -427,6 +429,7 @@ def get_move_line_total_debit(self):
"where date >= %s "
"and date <= %s "
"and parent_state = 'posted' "
"and display_type NOT IN ('line_section', 'line_note') "
"and company_id = %s",
(self.date_start, self.date_end, self.company_id.id),
)
Expand All @@ -439,6 +442,7 @@ def get_move_line_total_credit(self):
"where date >= %s "
"and date <= %s "
"and parent_state = 'posted' "
"and display_type NOT IN ('line_section', 'line_note') "
"and company_id = %s",
(self.date_start, self.date_end, self.company_id.id),
)
Expand Down
Expand Up @@ -169,3 +169,27 @@ def test_06_include_moves_from_inactive_journals(self):
line_count_after = record_after.get_move_line_count()
parsed_count_after = get_transaction_line_count_from_xml(record_after.auditfile)
self.assertTrue(parsed_line_count == parsed_count_after == line_count_after)

def test_07_do_not_include_section_and_note_move_lines(self):
"""Do not include Section and Note move lines"""
self.env["account.move.line"].create(
[
{
"name": "Section test",
"display_type": "line_section",
"move_id": self.invoice.id,
},
{
"name": "Note test",
"display_type": "line_note",
"move_id": self.invoice.id,
},
]
)
record = self.env["xaf.auditfile.export"].create({})
record.button_generate()
self.assertTrue(record)

line_count = record.get_move_line_count()
parsed_line_count = get_transaction_line_count_from_xml(record.auditfile)
self.assertEqual(parsed_line_count, line_count)
5 changes: 4 additions & 1 deletion l10n_nl_xaf_auditfile_export/views/templates.xml
Expand Up @@ -236,7 +236,10 @@
<sourceID />
<userID />
/-->
<trLine t-foreach="m.line_ids" t-as="l">
<trLine
t-foreach="m.line_ids.filtered(lambda l: l.display_type not in ('line_section', 'line_note'))"
t-as="l"
>
<nr><t t-esc="l.id" /></nr>
<accID><t t-esc="l.account_id.code" /></accID>
<docRef><t
Expand Down

0 comments on commit cdd74af

Please sign in to comment.