Browse Source

Mar 8 : [FIX] Bug Fixed 'dynamic_accounts_report'

pull/254/head
AjmalCybro 2 years ago
parent
commit
542bda92d9
  1. 1
      dynamic_accounts_report/__init__.py
  2. 2
      dynamic_accounts_report/__manifest__.py
  3. 5
      dynamic_accounts_report/doc/RELEASE_NOTES.md
  4. 20
      dynamic_accounts_report/wizard/general_ledger.py

1
dynamic_accounts_report/__init__.py

@ -24,4 +24,3 @@ from . import controllers
from . import wizard from . import wizard
from . import report from . import report
from . import models from . import models

2
dynamic_accounts_report/__manifest__.py

@ -22,7 +22,7 @@
{ {
'name': 'Dynamic Financial Reports', 'name': 'Dynamic Financial Reports',
'version': '15.0.1.1.6', 'version': '15.0.1.1.7',
'category': 'Accounting', 'category': 'Accounting',
'live_test_url': 'https://www.youtube.com/watch?v=gVQi9q9Rs-E&t=5s', 'live_test_url': 'https://www.youtube.com/watch?v=gVQi9q9Rs-E&t=5s',
'summary': """Dynamic Financial Reports with drill 'summary': """Dynamic Financial Reports with drill

5
dynamic_accounts_report/doc/RELEASE_NOTES.md

@ -36,3 +36,8 @@
#### Version 15.0.1.1.6 #### Version 15.0.1.1.6
#### UPDT AND BUGFIX #### UPDT AND BUGFIX
- Report Bug Fix: Correct the currency used in the General Ledger - Report Bug Fix: Correct the currency used in the General Ledger
#### 07.03.2023
#### Version 15.0.1.1.7
#### UPDT AND BUGFIX
- Report Bug Fix: Fix the error occurs while opening the general ledger entries after filter.

20
dynamic_accounts_report/wizard/general_ledger.py

@ -448,7 +448,6 @@ class GeneralView(models.TransientModel):
return currency_array return currency_array
def get_accounts_line(self, account_id, title): def get_accounts_line(self, account_id, title):
trans_title = self.env['ir.translation'].search([('value', '=', title), trans_title = self.env['ir.translation'].search([('value', '=', title),
('module', '=', ('module', '=',
'dynamic_accounts_report')], 'dynamic_accounts_report')],
@ -465,6 +464,7 @@ class GeneralView(models.TransientModel):
else: else:
journals = self.env['account.journal'].search( journals = self.env['account.journal'].search(
[('company_id', 'in', company_id)]) [('company_id', 'in', company_id)])
if title == 'Bank Book' or trans_title == 'Bank Book': if title == 'Bank Book' or trans_title == 'Bank Book':
journals = self.env['account.journal'].search( journals = self.env['account.journal'].search(
[('type', '=', 'bank'), ('company_id', 'in', company_id)]) [('type', '=', 'bank'), ('company_id', 'in', company_id)])
@ -479,17 +479,13 @@ class GeneralView(models.TransientModel):
company_id = self.env.companies company_id = self.env.companies
company_domain = [('company_id', 'in', company_id.ids)] company_domain = [('company_id', 'in', company_id.ids)]
accounts = self.env['account.account'].search(company_domain) accounts = self.env['account.account'].search(company_domain)
cr = self.env.cr cr = self.env.cr
MoveLine = self.env['account.move.line'] MoveLine = self.env['account.move.line']
move_lines = {x: [] for x in accounts.ids} move_lines = {x: [] for x in accounts.ids}
# self.j
# Prepare initial sql query and Get the initial move lines # Prepare initial sql query and Get the initial move lines
if self.date_from: if self.date_from:
init_tables, init_where_clause, init_where_params = MoveLine.with_context( init_tables, init_where_clause, init_where_params = MoveLine.with_context(
date_from=self.env.context.get('date_from'), date_to=False, date_from=self.date_from, date_to=False,
initial_bal=True)._query_get() initial_bal=True)._query_get()
init_wheres = [""] init_wheres = [""]
if init_where_clause.strip(): if init_where_clause.strip():
@ -509,7 +505,7 @@ class GeneralView(models.TransientModel):
new_filter += ' AND j.id IN %s' % str( new_filter += ' AND j.id IN %s' % str(
tuple(journals.ids) + tuple([0])) tuple(journals.ids) + tuple([0]))
if accounts: if accounts:
WHERE = "WHERE l.account_id IN %s" % str( WHERE = " WHERE l.account_id IN %s" % str(
tuple(accounts.ids) + tuple([0])) tuple(accounts.ids) + tuple([0]))
else: else:
WHERE = "WHERE l.account_id IN %s" WHERE = "WHERE l.account_id IN %s"
@ -518,7 +514,7 @@ class GeneralView(models.TransientModel):
tuple(self.analytic_ids.ids) + tuple([0])) tuple(self.analytic_ids.ids) + tuple([0]))
if self.analytic_tag_ids: if self.analytic_tag_ids:
WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str( WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str(
tuple(self.analytic_tags.ids) + tuple([0])) tuple(self.analytic_tag_ids.ids) + tuple([0]))
sql = ("""SELECT 0 AS lid, l.account_id AS account_id, '' AS ldate, '' AS lcode, 0.0 AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance, '' AS lpartner_id,\ sql = ("""SELECT 0 AS lid, l.account_id AS account_id, '' AS ldate, '' AS lcode, 0.0 AS amount_currency, '' AS lref, 'Initial Balance' AS lname, COALESCE(SUM(l.debit),0.0) AS debit, COALESCE(SUM(l.credit),0.0) AS credit, COALESCE(SUM(l.debit),0) - COALESCE(SUM(l.credit), 0) as balance, '' AS lpartner_id,\
'' AS move_name, '' AS mmove_id, '' AS currency_code,\ '' AS move_name, '' AS mmove_id, '' AS currency_code,\
@ -538,7 +534,8 @@ class GeneralView(models.TransientModel):
if self.account_ids: if self.account_ids:
params = tuple(init_where_params) params = tuple(init_where_params)
else: else:
params = (tuple(accounts.ids),) + tuple(init_where_params) # params = (tuple(accounts.ids)) + tuple(init_where_params)
params = init_where_params
cr.execute(sql, params) cr.execute(sql, params)
for row in cr.dictfetchall(): for row in cr.dictfetchall():
row['m_id'] = row['account_id'] row['m_id'] = row['account_id']
@ -572,11 +569,11 @@ class GeneralView(models.TransientModel):
WHERE = "WHERE l.account_id IN %s" WHERE = "WHERE l.account_id IN %s"
if self.analytic_ids: if self.analytic_ids:
WHERE += ' AND anl.id IN %s' % str( WHERE += ' AND anl.id IN %s' % str(
tuple(self.analytics.ids) + tuple([0])) tuple(self.analytic_ids.ids) + tuple([0]))
if self.analytic_tag_ids: if self.analytic_tag_ids:
WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str( WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str(
tuple(self.analytic_tags.ids) + tuple([0])) tuple(self.analytic_tag_ids.ids) + tuple([0]))
# Get move lines base on sql query and Calculate the total balance of move lines # Get move lines base on sql query and Calculate the total balance of move lines
sql = ('''SELECT l.id AS lid,m.id AS move_id, l.account_id AS account_id, l.date AS ldate, j.code AS lcode, l.currency_id, l.amount_currency, l.ref AS lref, l.name AS lname, COALESCE(SUM(l.debit),0) AS debit, COALESCE(SUM(l.credit),0) AS credit, COALESCE(SUM(l.balance),0) AS balance,\ sql = ('''SELECT l.id AS lid,m.id AS move_id, l.account_id AS account_id, l.date AS ldate, j.code AS lcode, l.currency_id, l.amount_currency, l.ref AS lref, l.name AS lname, COALESCE(SUM(l.debit),0) AS debit, COALESCE(SUM(l.credit),0) AS credit, COALESCE(SUM(l.balance),0) AS balance,\
@ -593,7 +590,6 @@ class GeneralView(models.TransientModel):
+ WHERE + new_final_filter + ''' GROUP BY l.id, m.id, l.account_id, l.date, j.code, l.currency_id, l.amount_currency, l.ref, l.name, m.name, c.symbol, c.position, p.name ORDER BY l.date''') + WHERE + new_final_filter + ''' GROUP BY l.id, m.id, l.account_id, l.date, j.code, l.currency_id, l.amount_currency, l.ref, l.name, m.name, c.symbol, c.position, p.name ORDER BY l.date''')
params = tuple(where_params) params = tuple(where_params)
cr.execute(sql, params) cr.execute(sql, params)
account_ress = cr.dictfetchall() account_ress = cr.dictfetchall()
i = 0 i = 0

Loading…
Cancel
Save