Browse Source

Sep 5 [UPDT] Updated 'dynamic_accounts_report'

pull/332/merge
AjmalCybro 8 months ago
parent
commit
1869024364
  1. 2
      dynamic_accounts_report/__manifest__.py
  2. 5
      dynamic_accounts_report/doc/RELEASE_NOTES.md
  3. 1
      dynamic_accounts_report/static/src/js/ageing.js
  4. 5
      dynamic_accounts_report/static/src/js/general_ledger.js
  5. 15
      dynamic_accounts_report/static/src/xml/ageing.xml
  6. 30
      dynamic_accounts_report/static/src/xml/general_ledger_view.xml
  7. 16
      dynamic_accounts_report/static/src/xml/trial_balance_view.xml
  8. 3
      dynamic_accounts_report/wizard/ageing.py
  9. 25
      dynamic_accounts_report/wizard/balance_sheet.py
  10. 3
      dynamic_accounts_report/wizard/balance_sheet_config.py
  11. 37
      dynamic_accounts_report/wizard/general_ledger.py
  12. 16
      dynamic_accounts_report/wizard/partner_leadger.py
  13. 3
      dynamic_accounts_report/wizard/trial_balance.py

2
dynamic_accounts_report/__manifest__.py

@ -22,7 +22,7 @@
{ {
'name': 'Dynamic Financial Reports V16', 'name': 'Dynamic Financial Reports V16',
'version': '16.0.1.0.11', 'version': '16.0.1.0.12',
'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': "Odoo 16 Accounting Financial Reports", 'summary': "Odoo 16 Accounting Financial Reports",

5
dynamic_accounts_report/doc/RELEASE_NOTES.md

@ -45,3 +45,8 @@
### version 16.0.1.0.11, ### version 16.0.1.0.11,
### BUGFIX ### BUGFIX
- General Ledger: Fixed the Redundancy bug - General Ledger: Fixed the Redundancy bug
### 05.09.2024
### version 16.0.1.0.12,
### BUGFIX
- Report Bug Fix: Problem with rounding issue.

1
dynamic_accounts_report/static/src/js/ageing.js

@ -127,6 +127,7 @@ odoo.define('dynamic_accounts_report.ageing', function(require) {
} }
var child = []; var child = [];
console.log(datas,'datas.....')
self.$('.table_view_tb').html(QWeb.render('Ageingtable', { self.$('.table_view_tb').html(QWeb.render('Ageingtable', {
report_lines: datas['report_lines'], report_lines: datas['report_lines'],

5
dynamic_accounts_report/static/src/js/general_ledger.js

@ -88,6 +88,7 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) {
load_data: function(initial_render = true) { load_data: function(initial_render = true) {
var self = this; var self = this;
self.$(".categ").empty(); self.$(".categ").empty();
console.log('load data.....')
try { try {
var self = this; var self = this;
var action_title = self._title var action_title = self._title
@ -127,6 +128,10 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) {
}); });
} }
var child = []; var child = [];
console.log(datas['debit_balance'],'debit balance....')
console.log(datas['debit_total'],'debit_total....')
console.log(datas['credit_total'],'credit_total....')
console.log(datas['currency'],'currency....')
self.$('.table_view_tb').html(QWeb.render('GLTable', { self.$('.table_view_tb').html(QWeb.render('GLTable', {
report_lines: datas['report_lines'], report_lines: datas['report_lines'],
filter: datas['filters'], filter: datas['filters'],

15
dynamic_accounts_report/static/src/xml/ageing.xml

@ -40,7 +40,7 @@
<t t-set="common_id" t-value="0"/> <t t-set="common_id" t-value="0"/>
<t t-set="decimal_point" t-value="currency[3]"/>
<tr style="border: 1.5px solid black;" <tr style="border: 1.5px solid black;"
class="gl-line" class="gl-line"
data-bs-toggle="collapse" data-bs-toggle="collapse"
@ -63,7 +63,14 @@
<t t-else=""> <t t-else="">
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
<t t-esc="account['direction']"/> <t t-esc="account['direction']"/>
<!-- <t t-esc="Math.round(account['direction'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="typeof account['direction']"/>-->
<!-- <t t-raw="typeof currency[3]"/>-->
<!-- <t t-esc="currency[3]"/>-->
<!-- <t t-out="Math.round(account['debit'] * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>-->
<!-- <t t-set="direction_account" t-value="parseFloat(account['direction'])"/>-->
<!-- <t t-esc="direction_account"/>-->
<!-- <t t-raw="Math.round(parseFloat(account['direction']) * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>-->
</t> </t>
</td> </td>
@ -74,7 +81,7 @@
<t t-else=""> <t t-else="">
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
<t t-esc="account['4']"/> <t t-esc="account['4']"/>
<!-- <t t-esc="Math.round(account['4'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-out="Math.round(account['4'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
</t> </t>
</td> </td>
<td style="text-align:right;"> <td style="text-align:right;">
@ -84,7 +91,7 @@
<t t-else=""> <t t-else="">
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
<t t-esc="account['3']"/> <t t-esc="account['3']"/>
<!-- <t t-esc="Math.round(account['3'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-esc="Math.round(account['3'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>-->
</t> </t>
</td> </td>
<td style="text-align:right;"> <td style="text-align:right;">

30
dynamic_accounts_report/static/src/xml/general_ledger_view.xml

@ -26,6 +26,7 @@
<t t-set="none_value" t-value="_" /> <t t-set="none_value" t-value="_" />
<t t-foreach="report_lines" t-as="account"> <t t-foreach="report_lines" t-as="account">
<t t-set="common_id" t-value="0" /> <t t-set="common_id" t-value="0" />
<t t-set="decimal_point" t-value="currency[3]"/>
<tr style="border: 1.5px solid black;" class="gl-line" data-bs-toggle="collapse" t-att-data-account-id="account['id']" t-attf-data-bs-target=".a{{account['id']}}"> <tr style="border: 1.5px solid black;" class="gl-line" data-bs-toggle="collapse" t-att-data-account-id="account['id']" t-attf-data-bs-target=".a{{account['id']}}">
<td colspan="6" style="border: 0px solid black;"> <td colspan="6" style="border: 0px solid black;">
<i class="fa fa-caret-down" role="img" aria-label="Unfolded" title="Unfolded" /> <i class="fa fa-caret-down" role="img" aria-label="Unfolded" title="Unfolded" />
@ -48,8 +49,10 @@
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
<t t-esc="account['debit']" /> <!-- <t t-esc="account['debit']" />-->
<!-- <t t-raw="Math.round(account['debit'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="Math.round(account['debit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-out="Math.round(account['debit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
</t> </t>
</td> </td>
<td class="mon_fld"> <td class="mon_fld">
@ -58,8 +61,10 @@
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
<t t-esc="account['credit']" /> <!-- <t t-esc="account['credit']" />-->
<!-- <t t-raw="Math.round(account['credit'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="Math.round(account['credit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-out="Math.round(account['credit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
</t> </t>
</td> </td>
<td class="mon_fld"> <td class="mon_fld">
@ -68,8 +73,10 @@
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
<t t-esc="account['balance']" /> <!-- <t t-esc="account['balance']" />-->
<!-- <t t-raw="Math.round(account['balance'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="Math.round(account['balance'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-out="Math.round(account['balance'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
</t> </t>
</td> </td>
</t> </t>
@ -79,8 +86,9 @@
<span>-</span> <span>-</span>
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="account['debit']" /> <!-- <t t-esc="account['debit']" />-->
<!-- <t t-raw="Math.round(account['debit'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="Math.round(account['debit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-out="Math.round(account['debit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
</t> </t>
</td> </td>
@ -90,7 +98,8 @@
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="account['credit']" /> <t t-esc="account['credit']" />
<!-- <t t-raw="Math.round(account['credit'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <!-- <t t-raw="Math.round(account['credit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-out="Math.round(account['credit'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
</t> </t>
</td> </td>
@ -100,7 +109,8 @@
</t> </t>
<t t-else=""> <t t-else="">
<t t-esc="account['balance']" /> <t t-esc="account['balance']" />
<!-- <t t-raw="Math.round(account['balance'] * Math.pow(10, 2)) / Math.pow(10, 2)"/>--> <t t-out="Math.round(account['balance'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>
<!-- <t t-raw="Math.round(account['balance'] * Math.pow(10, decimal_point)) / Math.pow(10, decimal_point)"/>-->
<t t-esc="currency[0]" /> <t t-esc="currency[0]" />
</t> </t>
</td> </td>

16
dynamic_accounts_report/static/src/xml/trial_balance_view.xml

@ -76,20 +76,24 @@
<td class="mon_fld"> <td class="mon_fld">
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
<t t-raw="account['Init_balance']['debit']"/> <t t-out="Math.round(account['Init_balance']['debit'] * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>
<!-- <t t-raw="account['Init_balance']['debit']"/>-->
</td> </td>
<td class="mon_fld"> <td class="mon_fld">
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
<t t-raw="account['Init_balance']['credit']"/> <!-- <t t-raw="account['Init_balance']['credit']"/>-->
<t t-out="Math.round(account['Init_balance']['credit'] * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>
</td> </td>
</t> </t>
<t t-else=""> <t t-else="">
<td class="mon_fld"> <td class="mon_fld">
<t t-raw="account['Init_balance']['debit']"/> <!-- <t t-raw="account['Init_balance']['debit']"/>-->
<t t-out="Math.round(account['Init_balance']['debit'] * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
</td> </td>
<td class="mon_fld"> <td class="mon_fld">
<t t-raw="account['Init_balance']['credit']"/> <!-- <t t-raw="account['Init_balance']['credit']"/>-->
<t t-out="Math.round(account['Init_balance']['credit'] * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
</td> </td>
@ -175,13 +179,13 @@
<td class="mon_fld" style=""> <td class="mon_fld" style="">
<strong> <strong>
<t t-raw="Math.round(debit_total * Math.pow(10, 2)) / Math.pow(10, 2)"/> <t t-raw="Math.round(debit_total * Math.pow(10,currency[3] )) / Math.pow(10, currency[3])"/>
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
</strong> </strong>
</td> </td>
<td class="mon_fld" style=""> <td class="mon_fld" style="">
<strong> <strong>
<t t-raw="Math.round(credit_total * Math.pow(10, 2)) / Math.pow(10, 2)"/> <t t-raw="Math.round(credit_total * Math.pow(10, currency[3])) / Math.pow(10, currency[3])"/>
<t t-esc="currency[0]"/> <t t-esc="currency[0]"/>
</strong> </strong>
</td> </td>

3
dynamic_accounts_report/wizard/ageing.py

@ -529,8 +529,9 @@ class AgeingView(models.TransientModel):
if not lang: if not lang:
lang = 'en_US' lang = 'en_US'
lang = lang.replace("_", '-') lang = lang.replace("_", '-')
decimal_places = self.env.company.currency_id.decimal_places
currency_array = [self.env.company.currency_id.symbol, currency_array = [self.env.company.currency_id.symbol,
self.env.company.currency_id.position, lang] self.env.company.currency_id.position, lang,decimal_places]
return currency_array return currency_array
def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data): def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data):

25
dynamic_accounts_report/wizard/balance_sheet.py

@ -201,13 +201,14 @@ class BalanceSheetView(models.TransientModel):
currency = company_id.currency_id currency = company_id.currency_id
symbol = currency.symbol symbol = currency.symbol
rounding = currency.rounding rounding = currency.rounding
decimal_places = currency.decimal_places
position = currency.position position = currency.position
for rec in final_report_lines: for rec in final_report_lines:
rec['debit'] = round(rec['debit'], 2) rec['debit'] = round(rec['debit'], decimal_places)
rec['credit'] = round(rec['credit'], 2) rec['credit'] = round(rec['credit'], decimal_places)
rec['balance'] = rec['debit'] - rec['credit'] rec['balance'] = rec['debit'] - rec['credit']
rec['balance'] = round(rec['balance'], 2) rec['balance'] = round(rec['balance'], decimal_places)
if (rec['balance_cmp'] < 0 and rec['balance'] > 0) or ( if (rec['balance_cmp'] < 0 and rec['balance'] > 0) or (
rec['balance_cmp'] > 0 and rec['balance'] < 0): rec['balance_cmp'] > 0 and rec['balance'] < 0):
rec['balance'] = rec['balance'] * -1 rec['balance'] = rec['balance'] * -1
@ -379,6 +380,7 @@ class BalanceSheetView(models.TransientModel):
def _get_report_values(self, data): def _get_report_values(self, data):
docs = data['model'] docs = data['model']
display_account = data['display_account'] display_account = data['display_account']
decimal_places = self.env.company.currency_id.decimal_places
init_balance = True init_balance = True
journals = data['journals'] journals = data['journals']
accounts = self.env['account.account'].search([]) accounts = self.env['account.account'].search([])
@ -405,7 +407,7 @@ class BalanceSheetView(models.TransientModel):
debit_total = 0 debit_total = 0
debit_total = sum(x['debit'] for x in account_res) debit_total = sum(x['debit'] for x in account_res)
credit_total = sum(x['credit'] for x in account_res) credit_total = sum(x['credit'] for x in account_res)
debit_balance = round(debit_total, 2) - round(credit_total, 2) debit_balance = round(debit_total, decimal_places) - round(credit_total, decimal_places)
return { return {
'doc_ids': self.ids, 'doc_ids': self.ids,
'debit_total': debit_total, 'debit_total': debit_total,
@ -454,6 +456,7 @@ class BalanceSheetView(models.TransientModel):
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}
currency_id = self.env.company.currency_id currency_id = self.env.company.currency_id
decimal_places = self.env.company.currency_id.decimal_places
# Prepare sql query base on selected parameters from wizard # Prepare sql query base on selected parameters from wizard
tables, where_clause, where_params = MoveLine._query_get() tables, where_clause, where_params = MoveLine._query_get()
@ -493,10 +496,10 @@ class BalanceSheetView(models.TransientModel):
# tuple(data.get('analytic_tags').ids) + tuple([0])) # tuple(data.get('analytic_tags').ids) + tuple([0]))
# current_lang = self.env.user.lang # current_lang = self.env.user.lang
# 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.account_id AS account_id, a.code AS code,a.id AS id, a.name AS name, base_sql = ('''SELECT l.account_id AS account_id, a.code AS code,a.id AS id, a.name AS name,
ROUND(COALESCE(SUM(l.debit),0),2) AS debit, ROUND(COALESCE(SUM(l.debit),0),{}) AS debit,
ROUND(COALESCE(SUM(l.credit),0),2) AS credit, ROUND(COALESCE(SUM(l.credit),0),{}) AS credit,
ROUND(COALESCE(SUM(l.balance),0),2) AS balance, ROUND(COALESCE(SUM(l.balance),0),{}) AS balance,
anl.keys, act.name as tag anl.keys, act.name as tag
FROM account_move_line l FROM account_move_line l
JOIN account_move m ON (l.move_id=m.id) JOIN account_move m ON (l.move_id=m.id)
@ -512,9 +515,9 @@ class BalanceSheetView(models.TransientModel):
SELECT jsonb_object_keys(l.analytic_distribution)::INT SELECT jsonb_object_keys(l.analytic_distribution)::INT
AS keys) anl ON true AS keys) anl ON true
LEFT JOIN account_analytic_account an LEFT JOIN account_analytic_account an
ON (anl.keys = an.id)''' ON (anl.keys = an.id)''').format(decimal_places, decimal_places, decimal_places)
+ WHERE + final_filters + ''' GROUP BY l.account_id, sql = base_sql + WHERE + final_filters + ''' GROUP BY l.account_id,
a.code,a.id,a.name,anl.keys, act.name''') a.code,a.id,a.name,anl.keys, act.name'''
if data.get('accounts'): if data.get('accounts'):
params = tuple(where_params) params = tuple(where_params)

3
dynamic_accounts_report/wizard/balance_sheet_config.py

@ -30,6 +30,7 @@ class BalanceSheet(models.TransientModel):
data = dict() data = dict()
report_lines = acc report_lines = acc
data['form'] = form data['form'] = form
decimal_places = self.env.company.currency_id.decimal_places
# find the journal items of these accounts # find the journal items of these accounts
journal_items = self.find_journal_items(report_lines, data['form']) journal_items = self.find_journal_items(report_lines, data['form'])
@ -49,7 +50,7 @@ class BalanceSheet(models.TransientModel):
# finding the root # finding the root
for item in report_lines: for item in report_lines:
item['balance'] = round(item['balance'], 2) item['balance'] = round(item['balance'], decimal_places)
if not item['parent']: if not item['parent']:
item['level'] = 1 item['level'] = 1
parent = item parent = item

37
dynamic_accounts_report/wizard/general_ledger.py

@ -120,6 +120,7 @@ class GeneralView(models.TransientModel):
merged_data = {} merged_data = {}
for line in records['Accounts']: for line in records['Accounts']:
account_id = line['account_id'] account_id = line['account_id']
print(line['balance'],'balance....')
if account_id not in merged_data: if account_id not in merged_data:
merged_data[account_id] = line merged_data[account_id] = line
else: else:
@ -284,7 +285,8 @@ class GeneralView(models.TransientModel):
debit_total = 0 debit_total = 0
debit_total = sum(x['debit'] for x in account_res) debit_total = sum(x['debit'] for x in account_res)
credit_total = sum(x['credit'] for x in account_res) credit_total = sum(x['credit'] for x in account_res)
debit_balance = round(debit_total, 2) - round(credit_total, 2) decimal_places = self.env.company.currency_id.decimal_places
debit_balance = round(debit_total, decimal_places) - round(credit_total, decimal_places)
return { return {
'doc_ids': self.ids, 'doc_ids': self.ids,
'debit_total': debit_total, 'debit_total': debit_total,
@ -334,6 +336,7 @@ class GeneralView(models.TransientModel):
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}
decimal_places = self.env.company.currency_id.decimal_places
# Prepare initial sql query and Get the initial move lines # Prepare initial sql query and Get the initial move lines
if init_balance and data.get('date_from'): if init_balance and data.get('date_from'):
init_tables, init_where_clause, init_where_params = MoveLine.with_context( init_tables, init_where_clause, init_where_params = MoveLine.with_context(
@ -366,14 +369,14 @@ class GeneralView(models.TransientModel):
tuple(data.get('analytics').ids) + tuple([0])) tuple(data.get('analytics').ids) + tuple([0]))
if data['account_tags']: if data['account_tags']:
WHERE += ' AND tag IN %s' % str(data.get('account_tags')) WHERE += ' AND tag IN %s' % str(data.get('account_tags'))
sql = ('''SELECT base_sql = ('''SELECT
l.account_id AS account_id, l.account_id AS account_id,
a.code AS code, a.code AS code,
a.id AS id, a.id AS id,
a.name AS name, a.name AS name,
ROUND(COALESCE(SUM(l.debit),0),2) AS debit, ROUND(COALESCE(SUM(l.debit),0),{}) AS debit,
ROUND(COALESCE(SUM(l.credit),0),2) AS credit, ROUND(COALESCE(SUM(l.credit),0),{}) AS credit,
ROUND(COALESCE(SUM(l.balance),0),2) AS balance, ROUND(COALESCE(SUM(l.balance),0),{}) AS balance,
anl.keys, anl.keys,
act.name AS tag act.name AS tag
FROM FROM
@ -396,15 +399,17 @@ class GeneralView(models.TransientModel):
SELECT jsonb_array_elements_text(l.analytic_distribution->'ids')::INT AS keys SELECT jsonb_array_elements_text(l.analytic_distribution->'ids')::INT AS keys
) anl ON true ) anl ON true
LEFT JOIN LEFT JOIN
account_analytic_account an ON (anl.keys = an.id) '''+ WHERE + new_filter + ''' account_analytic_account an ON (anl.keys = an.id) ''').format(decimal_places, decimal_places, decimal_places)
sql = base_sql + WHERE + new_filter + '''
GROUP BY GROUP BY
l.account_id, a.code, a.id, a.name, anl.keys, act.name''') l.account_id, a.code, a.id, a.name, anl.keys, act.name'''
if data.get('accounts'): if data.get('accounts'):
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)
cr.execute(sql, params) cr.execute(sql, params)
print('1...............')
for row in cr.dictfetchall(): for row in cr.dictfetchall():
row['m_id'] = row['account_id'] row['m_id'] = row['account_id']
move_lines[row.pop('account_id')].append(row) move_lines[row.pop('account_id')].append(row)
@ -443,11 +448,11 @@ class GeneralView(models.TransientModel):
# Get move lines base on sql query and Calculate the total balance # Get move lines base on sql query and Calculate the total balance
# of move lines # of move lines
sql = ('''SELECT l.account_id AS account_id, a.code AS code, base_sql = ('''SELECT l.account_id AS account_id, a.code AS code,
a.id AS id, a.name AS name, l.id as line_id, a.id AS id, a.name AS name, l.id as line_id,
ROUND(COALESCE(SUM(l.debit),0),2) AS debit, ROUND(COALESCE(SUM(l.debit),0),{}) AS debit,
ROUND(COALESCE(SUM(l.credit),0),2) AS credit, ROUND(COALESCE(SUM(l.credit),0),{}) AS credit,
ROUND(COALESCE(SUM(l.balance),0),2) AS balance, ROUND(COALESCE(SUM(l.balance),0),{}) AS balance,
anl.keys, act.name as tag anl.keys, act.name as tag
FROM account_move_line l FROM account_move_line l
LEFT JOIN account_move m ON (l.move_id = m.id) LEFT JOIN account_move m ON (l.move_id = m.id)
@ -463,15 +468,17 @@ class GeneralView(models.TransientModel):
SELECT jsonb_object_keys(l.analytic_distribution)::INT SELECT jsonb_object_keys(l.analytic_distribution)::INT
AS keys) anl ON true AS keys) anl ON true
LEFT JOIN account_analytic_account an LEFT JOIN account_analytic_account an
ON (anl.keys = an.id)''' ON (anl.keys = an.id)''').format(decimal_places, decimal_places, decimal_places)
+ WHERE + new_final_filter + ''' GROUP BY l.account_id, sql = base_sql+ WHERE + new_final_filter + ''' GROUP BY l.account_id,
a.code,a.id,a.name,anl.keys, act.name, l.id''') a.code,a.id,a.name,anl.keys, act.name, l.id'''
if data.get('accounts'): if data.get('accounts'):
params = tuple(where_params) params = tuple(where_params)
else: else:
params = (tuple(accounts.ids),) + tuple(where_params) params = (tuple(accounts.ids),) + tuple(where_params)
cr.execute(sql, params) cr.execute(sql, params)
print('2.........')
account_res = cr.dictfetchall() account_res = cr.dictfetchall()
print(account_res,'account res....')
unique_line_ids = set() unique_line_ids = set()
filtered_records = [] filtered_records = []
for record in account_res: for record in account_res:
@ -492,7 +499,7 @@ class GeneralView(models.TransientModel):
lang = 'en_US' lang = 'en_US'
lang = lang.replace("_", '-') lang = lang.replace("_", '-')
currency_array = [self.env.company.currency_id.symbol, currency_array = [self.env.company.currency_id.symbol,
self.env.company.currency_id.position, lang] self.env.company.currency_id.position, lang,self.env.company.currency_id.decimal_places]
return currency_array return currency_array
def get_accounts_line(self, account_id, title): def get_accounts_line(self, account_id, title):

16
dynamic_accounts_report/wizard/partner_leadger.py

@ -216,6 +216,7 @@ class PartnerView(models.TransientModel):
docs = data['model'] docs = data['model']
display_account = data['display_account'] display_account = data['display_account']
init_balance = True init_balance = True
decimal_places = self.env.company.currency_id.decimal_places
company_id = self.env.companies.ids company_id = self.env.companies.ids
accounts = self.env['account.account'].search( accounts = self.env['account.account'].search(
[('account_type', 'in', ('asset_receivable', 'liability_payable')), [('account_type', 'in', ('asset_receivable', 'liability_payable')),
@ -237,7 +238,7 @@ class PartnerView(models.TransientModel):
debit_total = 0 debit_total = 0
debit_total = sum(x['debit'] for x in partner_res) debit_total = sum(x['debit'] for x in partner_res)
credit_total = sum(x['credit'] for x in partner_res) credit_total = sum(x['credit'] for x in partner_res)
debit_balance = round(debit_total, 2) - round(credit_total, 2) debit_balance = round(debit_total, decimal_places) - round(credit_total, decimal_places)
return { return {
'doc_ids': self.ids, 'doc_ids': self.ids,
'debit_total': debit_total, 'debit_total': debit_total,
@ -294,6 +295,7 @@ class PartnerView(models.TransientModel):
move_line = self.env['account.move.line'] move_line = self.env['account.move.line']
move_lines = {x: [] for x in partners.ids} move_lines = {x: [] for x in partners.ids}
currency_id = self.env.company.currency_id currency_id = self.env.company.currency_id
decimal_places = self.env.company.currency_id.decimal_places
tables, where_clause, where_params = move_line._query_get() tables, where_clause, where_params = move_line._query_get()
wheres = [""] wheres = [""]
if where_clause.strip(): if where_clause.strip():
@ -370,9 +372,9 @@ class PartnerView(models.TransientModel):
balance = 0 balance = 0
if row['partner_id'] in move_lines: if row['partner_id'] in move_lines:
for line in move_lines.get(row['partner_id']): for line in move_lines.get(row['partner_id']):
balance += round(line['debit'], 2) - round(line['credit'], balance += round(line['debit'], decimal_places) - round(line['credit'],
2) decimal_places)
row['balance'] += (round(balance, 2)) row['balance'] += (round(balance, decimal_places))
row['m_id'] = row['account_id'] row['m_id'] = row['account_id']
row['account_name'] = account_list[row['account_id']][ row['account_name'] = account_list[row['account_id']][
'name'] + "(" + \ 'name'] + "(" + \
@ -389,9 +391,9 @@ class PartnerView(models.TransientModel):
res['id'] = partner.id res['id'] = partner.id
res['move_lines'] = move_lines[partner.id] res['move_lines'] = move_lines[partner.id]
for line in res.get('move_lines'): for line in res.get('move_lines'):
res['debit'] += round(line['debit'], 2) res['debit'] += round(line['debit'], decimal_places)
res['credit'] += round(line['credit'], 2) res['credit'] += round(line['credit'], decimal_places)
res['balance'] = round(line['balance'], 2) res['balance'] = round(line['balance'], decimal_places)
if display_account == 'all': if display_account == 'all':
partner_res.append(res) partner_res.append(res)
if display_account == 'movement' and res.get('move_lines'): if display_account == 'movement' and res.get('move_lines'):

3
dynamic_accounts_report/wizard/trial_balance.py

@ -284,9 +284,10 @@ class TrialView(models.TransientModel):
if not lang: if not lang:
lang = 'en_US' lang = 'en_US'
lang = lang.replace("_", '-') lang = lang.replace("_", '-')
currency_array = [self.env.company.currency_id.symbol, currency_array = [self.env.company.currency_id.symbol,
self.env.company.currency_id.position, self.env.company.currency_id.position,
lang] lang,self.env.company.currency_id.decimal_places]
return currency_array return currency_array
def get_dynamic_xlsx_report(self, data, response ,report_data, dfr_data): def get_dynamic_xlsx_report(self, data, response ,report_data, dfr_data):

Loading…
Cancel
Save