Browse Source

Sep 30 : [FIX] Bug Fixed 'dynamic_accounts_report'

pull/284/head
AjmalCybro 2 years ago
parent
commit
9351703181
  1. 2
      dynamic_accounts_report/__manifest__.py
  2. 5
      dynamic_accounts_report/doc/RELEASE_NOTES.md
  3. 1
      dynamic_accounts_report/report/ageing.py
  4. 5
      dynamic_accounts_report/report/ageing.xml
  5. 1
      dynamic_accounts_report/report/cash_flow_report.py
  6. 31
      dynamic_accounts_report/report/cash_flow_report.xml
  7. 1
      dynamic_accounts_report/report/daybook.py
  8. 41
      dynamic_accounts_report/report/financial_report_template.xml
  9. 1
      dynamic_accounts_report/report/general_ledger.py
  10. 8
      dynamic_accounts_report/report/general_ledger.xml
  11. 1
      dynamic_accounts_report/report/trial_balance.py
  12. 1
      dynamic_accounts_report/report/trial_balance.xml
  13. 28
      dynamic_accounts_report/static/src/js/cash_flow.js
  14. 2
      dynamic_accounts_report/static/src/js/daybook.js
  15. 3
      dynamic_accounts_report/static/src/js/general_ledger.js
  16. 72
      dynamic_accounts_report/static/src/xml/cash_flow_view.xml
  17. 5
      dynamic_accounts_report/wizard/ageing.py
  18. 28
      dynamic_accounts_report/wizard/balance_sheet.py
  19. 235
      dynamic_accounts_report/wizard/cash_flow.py
  20. 41
      dynamic_accounts_report/wizard/general_ledger.py
  21. 6
      dynamic_accounts_report/wizard/partner_leadger.py

2
dynamic_accounts_report/__manifest__.py

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

5
dynamic_accounts_report/doc/RELEASE_NOTES.md

@ -25,7 +25,8 @@
#### BUGFIX
- Report Bug Fix: The issues with the analytic filter in the general ledger, partner ledger, and profit and loss statement have been fixed, and the problem with language while printing reports has also been addressed.
#### 08.09.2023
#### 18.09.2023
#### Version 16.0.1.0.7
#### BUGFIX
- Report Bug Fix: Problem with language while printing profit and loss report fixed.
- Report Bug Fix: Problem with language while printing profit and loss report fixed.
- Report Bug Fix: Problem with language while opening cash flow statement.

1
dynamic_accounts_report/report/ageing.py

@ -27,7 +27,6 @@ class PartnerAgeing(models.AbstractModel):
@api.model
def _get_report_values(self,docids, data=None):
print(data)
if self.env.context.get('ageing_pdf_report'):
if data.get('report_data'):
data.update(

5
dynamic_accounts_report/report/ageing.xml

@ -42,8 +42,6 @@
</t>
</div>
</div>
<br></br>
<table class="table table-sm table-reports">
<thead>
@ -97,7 +95,8 @@
<td><span t-esc="line['move']"/></td>
<td><span t-esc="line['date']"/></td>
<td><span t-esc="line['jrnl']"/></td>
<td><span t-esc="line['acc_code']"/></td>
<td><span t-esc="line['acc_code'] + line['acc_name']"/>
</td>
<td class="text-right">
<span t-if="line.get('period6')"
t-esc="line['amount']"

1
dynamic_accounts_report/report/cash_flow_report.py

@ -27,7 +27,6 @@ class GeneralLedger(models.AbstractModel):
@api.model
def _get_report_values(self,docids, data=None):
if self.env.context.get('trial_pdf_report'):
if data.get('report_data'):
data.update({'account_data': data.get('report_data')['report_lines'],

31
dynamic_accounts_report/report/cash_flow_report.xml

@ -1,31 +1,23 @@
<odoo>
<template id="dynamic_accounts_report.cash_flow">
<t t-call="web.html_container">
<t t-call="web.internal_layout">
<div style="font-size:12px" class="col-4">
<b>Report Date :</b>
<span t-esc="context_timestamp(datetime.datetime.now()).strftime('%Y-%m-%d %H:%M')"/>
<span t-esc='today'/>
<br/>
<span t-esc='logged_users'/>
</div>
<div class="page">
<h4 style="padding-left:10px !important">Cash Flow statements</h4>
<div style="width:90%;margin:1px auto;font-size:12px" class="row mt32 mb32">
<div class="col-3">
<strong>Target move:</strong>
<li>
<t t-esc="Filters['target_move']"/>
</li>
</div>
<div class="col-3">
<t t-if="Filters.get('levels')">
<strong>Level :</strong>
@ -33,11 +25,8 @@
<t t-esc="Filters['levels']"/>
</li>
</t>
</div>
<div class="col-4">
<p>
<t t-if="Filters.get('date_from')">
<strong>Date from :</strong>
@ -91,7 +80,7 @@
<tr style="font-size:13px" t-if="Filters['levels' ] == 'consolidated'">
<td>
<span t-esc="fetch['name']"/>
<span t-esc="fetch['account']"/>
</td>
<td class="text-right">
<span t-esc="fetch['total_debit']"
@ -110,13 +99,12 @@
</td>
</tr>
</tbody>
<tbody style="font-size:12px" t-if="Filters['levels' ] == 'detailed' " t-foreach="account_data['journal_res']" t-as="res">
<tr t-if="fet['id'] == res['id']" t-foreach="account_data['fetched_data']" t-as="fet">
<td>
<strong>
<span t-esc="fet['code']"/>
<span t-esc="fet['name']"/>
<span t-esc="fet['account']"/>
</strong>
</td>
<td class="text-right">
@ -142,7 +130,7 @@
</td>
<tr t-foreach="res['journal_lines']" t-as="mov">
<td style="padding-left:50px !important" class="text-left">
<span t-esc="mov['name']"/>
<span t-esc="mov['new_name']"/>
</td>
<td class="text-right">
<span t-esc="mov['total_debit']"
@ -162,12 +150,12 @@
</tr>
</tr>
</tbody>
<tbody style="font-size:12px" t-if="Filters['levels' ] == 'very' or Filters['levels' ] ==false " t-foreach="account_data['account_res']" t-as="res">
<tbody style="font-size:12px" t-if="Filters['levels'] == 'very' or Filters['levels' ] ==false " t-foreach="account_data['account_res']" t-as="res">
<tr t-if="fet['id'] == res['id']" t-foreach="account_data['fetched_data']" t-as="fet">
<td>
<strong>
<span t-esc="fet['code']"/>
<span t-esc="fet['name']"/>
<span t-esc="fet['account']"/>
</strong>
</td>
<td class="text-right">
@ -191,8 +179,6 @@
'display_currency': res_company.currency_id}"/>
</strong>
</td>
<tr t-if="line['account_name'] == res['account']"
t-foreach="res['journal_lines']" t-as="line">
<td style="padding-left:20px !important" class="text-left">
@ -246,13 +232,6 @@
</t>
</t>
</template>
<record id="action_print_cash_flow" model="ir.actions.report">
<field name="name">cash_flow</field>
<field name="model">account.cash.flow</field>

1
dynamic_accounts_report/report/daybook.py

@ -27,7 +27,6 @@ class DayBook(models.AbstractModel):
@api.model
def _get_report_values(self,docids, data=None):
if self.env.context.get('daybook_pdf_report'):
if data.get('report_data'):

41
dynamic_accounts_report/report/financial_report_template.xml

@ -64,14 +64,14 @@
</t>
</div>
<!-- <div class="col-2">-->
<!-- <strong>Analytic Tag:</strong>-->
<!-- <t t-foreach="Filters['analytic_tags']" t-as="ps">-->
<!-- <li>-->
<!-- <t t-esc="ps"/>-->
<!-- </li>-->
<!-- </t>-->
<!-- </div>-->
<!-- <div class="col-2">-->
<!-- <strong>Analytic Tag:</strong>-->
<!-- <t t-foreach="Filters['analytic_tags']" t-as="ps">-->
<!-- <li>-->
<!-- <t t-esc="ps"/>-->
<!-- </li>-->
<!-- </t>-->
<!-- </div>-->
<div class="col-3">
<strong>Target move:</strong>
@ -90,7 +90,7 @@
<th></th>
<th class="text-right">Debit</th>
<th class="text-right">Credit</th>
<th class="text-right">Balance001</th>
<th class="text-right">Balance</th>
</tr>
</thead>
<tbody>
@ -117,17 +117,18 @@
t-value="request.env.context.get('lang')"/>
<t t-esc="line['code']"/>
-
<t t-if="language != 'en_US'">
<t t-if="line['name'][lang] and lang != 'en_US'">
<t t-esc="line['name'][lang]"/>
</t>
<t t-elif="line['name']['en_US']">
<t t-esc="line['name']['en_US']"/>
</t>
</t>
<t t-else="">
<t t-esc="line['name']"/>
</t>
<t t-esc="line['new_name']"/>
<!-- <t t-if="language != 'en_US'">-->
<!-- <t t-if="line['name'][lang] and lang != 'en_US'">-->
<!-- <t t-esc="line['name'][lang]"/>-->
<!-- </t>-->
<!-- <t t-elif="line['name']['en_US']">-->
<!-- <t t-esc="line['name']['en_US']"/>-->
<!-- </t>-->
<!-- </t>-->
<!-- <t t-else="">-->
<!-- <t t-esc="line['name']"/>-->
<!-- </t>-->
</span>
</td>
<td class="text-right">

1
dynamic_accounts_report/report/general_ledger.py

@ -27,7 +27,6 @@ class GeneralLedger(models.AbstractModel):
@api.model
def _get_report_values(self, docids, data=None):
print('_get_report_values........',data)
if self.env.context.get('trial_pdf_report'):
if data.get('report_data'):
data.update(

8
dynamic_accounts_report/report/general_ledger.xml

@ -10,20 +10,14 @@
<div class="oe_structure"/>
<h3 style="text-align:centre;left:50%;"><span t-esc="Filters.get('company_name')"/>: <t t-esc="title"/>
</h3>
<span t-if="Filters.get('date_from')">
<strong> From:</strong>
<t t-esc="Filters['date_from']"/>
</span>
<span t-if="Filters.get('date_to')">
<strong>To:</strong>
<t t-esc="Filters['date_to']"/>
</span>
<div>
<div style="width:100%;">
<div style="text-align:centre;" class="row">
@ -96,7 +90,7 @@
<td colspan="6">
<span style="color: white;" t-esc="'..'"/>
<span t-esc="account['code']"/>
<span t-esc="account['name']"/>
<span t-esc="account['new_name']"/>
</td>
<td class="text-right">
<span t-esc="account['debit']" t-options="{'widget': 'monetary', 'display_currency': env.company.currency_id}"/>

1
dynamic_accounts_report/report/trial_balance.py

@ -28,7 +28,6 @@ class TrialBalance(models.AbstractModel):
@api.model
def _get_report_values(self,docids, data=None):
if self.env.context.get('trial_pdf_report'):
if data.get('report_data'):
data.update({'account_data': data.get('report_data'
)['report_lines'],

1
dynamic_accounts_report/report/trial_balance.xml

@ -79,7 +79,6 @@
</td>
<t t-if="Filters.get('date_from')">
<t t-if="line['Init_balance']">
<td class="mon_fld">
<t t-out="line['Init_balance']['debit']" t-options="{'widget': 'monetary', 'display_currency': res_company.currency_id}"/>
</td>

28
dynamic_accounts_report/static/src/js/cash_flow.js

@ -9,7 +9,7 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
var QWeb = core.qweb;
var _t = core._t;
var framework = require('web.framework');
var session = require('web.session');
var datepicker = require('web.datepicker');
var time = require('web.time');
@ -75,7 +75,6 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
widgetParent: 'body',
allowInputToggle: true,
};
$calendarInputGroup.datetimepicker(calendarOptions);
},
@ -98,33 +97,20 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit);
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit);
rep_lines.balance = self.format_currency(datas['currency'], rep_lines.balance);
});
});
_.each(datas['account_res'], function(journal_lines) {
_.each(journal_lines['journal_lines'], function(rep_lines) {
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit);
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit);
rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance);
});
_.each(journal_lines['move_lines'], function(move_lines) {
move_lines.total_debit = self.format_currency(datas['currency'], move_lines.total_debit);
move_lines.total_credit = self.format_currency(datas['currency'], move_lines.total_credit);
move_lines.balance = self.format_currency(datas['currency'], move_lines.balance);
});
});
if (datas['levels'] == 'detailed') {
$(event.currentTarget).next('tr').find('td ul').after(
QWeb.render('SubSectionCF', {
@ -155,7 +141,6 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
}
},
load_data: function(initial_render = true) {
var self = this;
self.$(".categ").empty();
@ -168,16 +153,10 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
[this.wizard_id]
],
}).then(function(datas) {
_.each(datas['fetched_data'], function(rep_lines) {
rep_lines.total_debit = self.format_currency(datas['currency'], rep_lines.total_debit);
rep_lines.total_credit = self.format_currency(datas['currency'], rep_lines.total_credit);
rep_lines.total_balance = self.format_currency(datas['currency'], rep_lines.total_balance);
});
if (initial_render) {
self.$('.filter_view_tb').html(QWeb.render('CashFilterView', {
@ -196,7 +175,7 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
var child = [];
self.$('.table_view_tb').html(QWeb.render('CashTable', {
lang: session.bundle_params.lang,
account_data: datas['fetched_data'],
level: datas['levels'],
currency: datas['currency'],
@ -235,11 +214,8 @@ odoo.define('dynamic_cash_flow_statements.cash_flow', function(require) {
domain: [
['account_ids', '=', account_id]
],
}
return this.do_action(action);
},
print_pdf: function(e) {
e.preventDefault();

2
dynamic_accounts_report/static/src/js/daybook.js

@ -296,7 +296,6 @@ odoo.define('dynamic_partner_daybook.daybook', function(require) {
},
view_acc_move: function(event) {
event.preventDefault();
var self = this;
var context = {};
@ -325,7 +324,6 @@ odoo.define('dynamic_partner_daybook.daybook', function(require) {
limit: 1,
})
.then(function(record) {
if (record.length > 0) {
show_acc_move('account.move', record[0].id);
} else {

3
dynamic_accounts_report/static/src/js/general_ledger.js

@ -279,7 +279,6 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) {
// });
for (var i = 0; i < data['report_lines'].length; i++) {
if (account_id == data['report_lines'][i]['id']) {
$(event.currentTarget).next('tr').find('td').remove();
$(event.currentTarget).next('tr').after(
@ -291,7 +290,7 @@ odoo.define('dynamic_accounts_report.general_ledger', function(require) {
}))
$(event.currentTarget).next('tr').find('td ul li:first a').css({
'background-color': '#00ede8',
'background-color': '#fcba03',
'font-weight': 'bold',
});
}

72
dynamic_accounts_report/static/src/xml/cash_flow_view.xml

@ -47,30 +47,39 @@
<t t-esc="account['month_part']"/>
</t>
<t t-esc="account['code']"/>
<t t-esc="account['name']"/>
<t t-if="account['name'][lang] and lang != 'en_US'">
<t t-esc="account['name'][lang]" />
</t>
<t t-elif="account['name']['en_US']">
<t t-esc="account['name']['en_US']" />
</t>
<t t-else="">
<t t-esc="account['name']" />
</t>
<!-- <t t-esc="account['name']"/>-->
</span>
</td>
<t t-if="currency[1] == 'before'">
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_debit']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_debit']"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_credit']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_credit']"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_balance']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_balance']"/>
</td>
</t>
<t t-else="">
<td class="cf_fld">
<t t-raw="account['total_debit']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_debit']"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account['total_credit']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_credit']"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account['total_balance']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_balance']"/><t t-esc="currency[0]"/>
</td>
</t>
</tr>
@ -89,31 +98,40 @@
<t t-esc="account['month_part']"/>
</t>
<t t-esc="account['code']"/>
<t t-esc="account['name']"/>
<t t-if="account['name']">
<t t-if="account['name'][lang] and lang != 'en_US'">
<t t-esc="account['name'][lang]" />
</t>
<t t-elif="account['name']['en_US']">
<t t-esc="account['name']['en_US']" />
</t>
<t t-else="">
<t t-esc="account['name']" />
</t>
</t>
</span>
</td>
<t t-if="currency[1] == 'before'">
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_debit']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_debit']"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_credit']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_credit']"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/> <t t-raw="account['total_balance']"/>
<t t-esc="currency[0]"/> <t t-esc="account['total_balance']"/>
</td>
</t>
<t t-else="">
<td class="cf_fld">
<t t-raw="account['total_debit']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_debit']"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account['total_credit']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_credit']"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account['total_balance']"/><t t-esc="currency[0]"/>
<t t-esc="account['total_balance']"/><t t-esc="currency[0]"/>
</td>
</t>
</tr>
@ -255,24 +273,24 @@ Level:
</td>
<t t-if="currency[1] == 'before'">
<td class="cf_fld">
<t t-esc="currency[0]"/><t t-raw="account_line.total_debit"/>
<t t-esc="currency[0]"/><t t-esc="account_line.total_debit"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/><t t-raw="account_line.total_credit"/>
<t t-esc="currency[0]"/><t t-esc="account_line.total_credit"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/><t t-raw="account_line.balance"/>
<t t-esc="currency[0]"/><t t-esc="account_line.balance"/>
</td>
</t>
<t t-else="">
<td class="cf_fld">
<t t-raw="account_line.total_debit"/><t t-esc="currency[0]"/>
<t t-esc="account_line.total_debit"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account_line.total_credit"/><t t-esc="currency[0]"/>
<t t-esc="account_line.total_credit"/><t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account_line.balance"/><t t-esc="currency[0]"/>
<t t-esc="account_line.balance"/><t t-esc="currency[0]"/>
</td>
</t>
</tr>
@ -318,15 +336,15 @@ Level:
<t t-if="currency[1] == 'before'">
<td class="cf_fld">
<t t-esc="currency[0]"/>
<t t-raw="account_line.total_debit"/>
<t t-esc="account_line.total_debit"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/>
<t t-raw="account_line.total_credit"/>
<t t-esc="account_line.total_credit"/>
</td>
<td class="cf_fld">
<t t-esc="currency[0]"/>
<t t-raw="account_line.balance"/>
<t t-esc="account_line.balance"/>
</td>
</t>
<t t-else="">
@ -336,12 +354,12 @@ Level:
</td>
<td class="cf_fld">
<t t-raw="account_line.total_credit"/>
<t t-esc="account_line.total_credit"/>
<t t-esc="currency[0]"/>
</td>
<td class="cf_fld">
<t t-raw="account_line.balance"/>
<t t-esc="account_line.balance"/>
<t t-esc="currency[0]"/>
</td>
</t>
@ -361,4 +379,4 @@ Level:
</div>
</t>
</templates>
</templates>

5
dynamic_accounts_report/wizard/ageing.py

@ -158,7 +158,6 @@ class AgeingView(models.TransientModel):
'docs': docs,
'time': time,
'Partners': account_res,
}
@api.model
@ -182,7 +181,6 @@ class AgeingView(models.TransientModel):
'partner_category_ids')]})
if not vals.get('partner_category_ids'):
vals.update({'partner_category_ids': [(5,)]})
res = super(AgeingView, self).write(vals)
return res
@ -536,7 +534,6 @@ class AgeingView(models.TransientModel):
return currency_array
def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data):
report_data_main = json.loads(report_data)
output = io.BytesIO()
filters = json.loads(data)
@ -630,7 +627,7 @@ class AgeingView(models.TransientModel):
sheet.write(row, col, line_data.get('move'), txt)
sheet.write(row, col + 1, line_data.get('date'), txt)
sheet.write(row, col + 2, line_data.get('jrnl'), txt)
sheet.write(row, col + 3, line_data.get('acc_code'), txt)
sheet.write(row, col + 3, f'({line_data.get("acc_code")}){line_data.get("acc_name")}', txt)
if line_data.get('period6'):
sheet.write(row, col + 4, line_data.get('amount'), txt)
else:

28
dynamic_accounts_report/wizard/balance_sheet.py

@ -114,7 +114,6 @@ class BalanceSheetView(models.TransientModel):
'report_lines']
move_line_accounts = []
move_lines_dict = {}
for rec in records['Accounts']:
move_line_accounts.append(rec['id'])
move_lines_dict[rec['id']] = {}
@ -226,6 +225,15 @@ class BalanceSheetView(models.TransientModel):
rec['credit']) + " " + symbol
rec['m_balance'] = "{:,.2f}".format(
rec['balance']) + " " + symbol
user = self.env.user
user_language = user.lang
for item in records['Accounts']:
if isinstance(item['name'], dict):
item['new_name'] = item['name'][
user_language] if user_language in item['name'] else \
item['name']['en_US']
else:
item['new_name'] = item['name']
return {
'name': tag,
'type': 'ir.actions.client',
@ -369,6 +377,22 @@ class BalanceSheetView(models.TransientModel):
raise UserError(_("No Accounts Found! Please Add One"))
account_res = self._get_accounts(accounts, init_balance,
display_account, data)
current_lang = self.env.user.lang
list_ac = []
default_lg = self.env['ir.http']._get_default_lang()
for rec in account_res:
list_ac.append(rec['account_id'])
if rec.get('name', None):
localized_name = rec['name']
if localized_name:
rec['name'] = localized_name
else:
# If the translation for the current language is not available, use a default language or handle it as needed.
rec['name'] = rec['name'].get(default_lg,
'') # Replace 'en_US' with your desired default language.
else:
# Handle the case where 'name' is not present in the dictionary.
rec['name'] = '' # You can use an
debit_total = 0
debit_total = sum(x['debit'] for x in account_res)
credit_total = sum(x['credit'] for x in account_res)
@ -457,7 +481,7 @@ class BalanceSheetView(models.TransientModel):
# if data['analytic_tags']:
# WHERE += ' AND anltag.account_analytic_tag_id IN %s' % str(
# tuple(data.get('analytic_tags').ids) + tuple([0]))
# current_lang = self.env.user.lang
# 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,
ROUND(COALESCE(SUM(l.debit),0),2) AS debit,

235
dynamic_accounts_report/wizard/cash_flow.py

@ -22,9 +22,11 @@
from datetime import datetime
from odoo import models, api, fields
FETCH_RANGE = 2000
import io
import json
try:
from odoo.tools.misc import xlsxwriter
except ImportError:
@ -36,7 +38,7 @@ class AccountCasgFlow(models.TransientModel):
_name = "account.cash.flow"
_inherit = "account.report"
date_from = fields.Date(string="Start Date", default=str(year)+'-01-01')
date_from = fields.Date(string="Start Date", default=str(year) + '-01-01')
date_to = fields.Date(string="End Date", default=fields.Date.today)
today = fields.Date(string="Report Date", default=fields.Date.today)
levels = fields.Selection([('summary', 'Summary'),
@ -77,6 +79,25 @@ class AccountCasgFlow(models.TransientModel):
journal_res = report_lines['journal_res']
levels = report_lines['levels']
currency = self._get_currency()
user = self.env.user
user_language = user.lang
for data in fetched_data:
if filters['levels'] != 'summary':
language_name = data.get('name')
if isinstance(language_name, dict):
data['account'] = language_name[
user_language] if user_language in language_name else \
language_name['en_US']
else:
data['account'] = data.get('name')
for rec in journal_res:
for item in rec.get('journal_lines'):
if isinstance(item['name'], dict):
item['new_name'] = item['name'][
user_language] if user_language in item['name'] else \
item['name']['en_US']
else:
item['new_name'] = data.get('name')
return {
'name': "Cash Flow Statements",
'type': 'ir.actions.client',
@ -143,7 +164,7 @@ class AccountCasgFlow(models.TransientModel):
filter_dict.update(default_filters)
return filter_dict
def _get_report_values(self, data,option):
def _get_report_values(self, data, option):
cr = self.env.cr
data = self.get_filter(option)
company_id = self.env.company
@ -158,8 +179,10 @@ class AccountCasgFlow(models.TransientModel):
account_type_id = 'asset_cash'
model = self.env.context.get('active_model')
if data.get('levels') == 'summary':
state = """ AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else ''
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state = """ AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else ''
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
query3 = """SELECT to_char(am.date, 'Month') as month_part,
extract(YEAR from am.date) as year_part,
sum(aml.debit) AS total_debit, sum(aml.credit) AS
@ -171,7 +194,7 @@ class AccountCasgFlow(models.TransientModel):
WHERE am.date BETWEEN '""" + str(
data.get('date_from')) + """' and '""" + str(
data.get('date_to')) + """' AND aa.account_type='""" + str(
account_type_id) + """' """ + state + state2 +""") am
account_type_id) + """' """ + state + state2 + """) am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
LEFT JOIN account_account aa ON aa.id = aml.account_id
GROUP BY month_part,year_part"""
@ -183,7 +206,8 @@ class AccountCasgFlow(models.TransientModel):
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance
FROM (SELECT am.* FROM account_move as am
@ -192,7 +216,7 @@ class AccountCasgFlow(models.TransientModel):
WHERE am.date BETWEEN '""" + str(
data.get('date_from')) + """' and '""" + str(
data.get('date_to')) + """' AND aa.account_type='""" + str(
account_type_id) + """' """ + state + state2 +""") am
account_type_id) + """' """ + state + state2 + """) am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
LEFT JOIN account_account aa ON aa.id = aml.account_id
GROUP BY aa.name, aa.code,aa.id"""
@ -204,7 +228,8 @@ class AccountCasgFlow(models.TransientModel):
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance
FROM (SELECT am.* FROM account_move as am
@ -225,7 +250,8 @@ class AccountCasgFlow(models.TransientModel):
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance
FROM (SELECT am.* FROM account_move as am
@ -247,7 +273,8 @@ class AccountCasgFlow(models.TransientModel):
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance
FROM (SELECT am.* FROM account_move as am
@ -265,24 +292,29 @@ class AccountCasgFlow(models.TransientModel):
fetched_data = cr.dictfetchall()
elif data.get('levels') == 'consolidated':
state = """ AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else ''
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
query2 = """SELECT aat.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,
state = """ AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else ''
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
query2 = """SELECT aa.name, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,
sum(aml.balance) AS total_balance FROM ( SELECT am.id, am.state FROM account_move as am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
LEFT JOIN account_account aa ON aa.id = aml.account_id
WHERE am.date BETWEEN '""" + str(data.get('date_from')) + """' and '""" + str(
WHERE am.date BETWEEN '""" + str(
data.get('date_from')) + """' and '""" + str(
data.get('date_to')) + """' AND aa.account_type='""" + str(
account_type_id) + """' """ + state + state2 + """) am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
LEFT JOIN account_account aa ON aa.id = aml.account_id
GROUP BY aat.name"""
GROUP BY aa.name"""
cr = self._cr
cr.execute(query2)
fetched_data = cr.dictfetchall()
elif data.get('levels') == 'detailed':
state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
query1 = """SELECT aa.id,aa.name,aa.code, sum(aml.debit) AS total_debit, sum(aml.credit) AS total_credit,
sum(aml.balance) AS total_balance FROM (SELECT am.id, am.state FROM account_move as am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
@ -304,8 +336,10 @@ class AccountCasgFlow(models.TransientModel):
else:
account_type_id = 'asset_cash'
state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
# filter = " AND aml.parent_state in ('draft','posted')"
sql = """SELECT DISTINCT aa.id, aa.name,aa.code, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit,sum(aml.balance) AS total_balance
@ -315,7 +349,7 @@ class AccountCasgFlow(models.TransientModel):
WHERE am.date BETWEEN '""" + str(
data.get('date_from')) + """' and '""" + str(
data.get('date_to')) + """' AND aa.account_type='""" + str(
account_type_id) + """' """ + state + state2 +""") am
account_type_id) + """' """ + state + state2 + """) am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
LEFT JOIN account_account aa ON aa.id = aml.account_id
GROUP BY aa.name, aa.code,aa.id"""
@ -329,7 +363,6 @@ class AccountCasgFlow(models.TransientModel):
journals = self.get_journal_lines(account, data)
if journals:
journal_res.append(journals)
return {
'date_from': data.get('date_from'),
'date_to': data.get('date_to'),
@ -347,8 +380,10 @@ class AccountCasgFlow(models.TransientModel):
def _get_lines(self, account, data):
account_type_id = 'asset_cash'
state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
query = """SELECT aml.account_id,aj.id as j_id,aj.name,am.id, am.name as move_name, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
@ -394,12 +429,14 @@ class AccountCasgFlow(models.TransientModel):
'journal_lines': fetch_data,
}
def get_journal_lines(self, account, data, offset=0, fetch_range=FETCH_RANGE):
def get_journal_lines(self, account, data, offset=0,
fetch_range=FETCH_RANGE):
account_type_id = 'asset_cash'
offset_count = offset * fetch_range
state = """AND am.state = 'posted' """ if data.get('target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(tuple(self.env.companies.ids) + tuple([0]))
state = """AND am.state = 'posted' """ if data.get(
'target_move') == 'Posted' else """AND am.state in ('draft','posted') """
state2 = ' AND aml.company_id IN %s' % str(
tuple(self.env.companies.ids) + tuple([0]))
sql2 = """SELECT aa.name as account_name, aj.name, sum(aml.debit) AS total_debit,
sum(aml.credit) AS total_credit, COALESCE(SUM(aml.debit - aml.credit),0) AS balance FROM (SELECT am.* FROM account_move as am
LEFT JOIN account_move_line aml ON aml.move_id = am.id
@ -425,9 +462,6 @@ class AccountCasgFlow(models.TransientModel):
'offset': offset_count,
}
@api.model
def create(self, vals):
vals['target_move'] = 'posted'
@ -443,7 +477,8 @@ class AccountCasgFlow(models.TransientModel):
if vals.get('journal_ids') == []:
vals.update({'journal_ids': [(5,)]})
if vals.get('account_ids'):
vals.update({'account_ids': [(4, j) for j in vals.get('account_ids')]})
vals.update(
{'account_ids': [(4, j) for j in vals.get('account_ids')]})
if vals.get('account_ids') == []:
vals.update({'account_ids': [(5,)]})
@ -465,6 +500,8 @@ class AccountCasgFlow(models.TransientModel):
return currency_array
def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data):
user = self.env.user
user_language = user.lang
report_main_data = json.loads(dfr_data)
data = json.loads(data)
report_data = report_main_data.get('report_lines')
@ -477,8 +514,8 @@ class AccountCasgFlow(models.TransientModel):
# account_type_id = self.env.ref('account.data_account_type_liquidity').id
currency_symbol = self.env.company.currency_id.symbol
logged_users = self.env['res.company']._company_default_get('account.account')
logged_users = self.env['res.company']._company_default_get(
'account.account')
sheet = workbook.add_worksheet()
bold = workbook.add_format({'align': 'center',
'bold': True,
@ -541,38 +578,84 @@ class AccountCasgFlow(models.TransientModel):
for i_rec in fetched_data_list:
if data['levels'] == 'summary':
sheet.write(row_num + 1, col_num, str(i_rec['month_part']) + str(int(i_rec['year_part'])), txt_left)
sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num,
str(i_rec['month_part']) + str(
int(i_rec['year_part'])), txt_left)
sheet.write(row_num + 1, col_num + 1,
str(i_rec['total_debit']) + str(currency_symbol),
amount)
sheet.write(row_num + 1, col_num + 2,
str(i_rec['total_credit']) + str(currency_symbol),
amount)
sheet.write(row_num + 1, col_num + 3,
str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol),
str(i_rec['total_debit'] - i_rec[
'total_credit']) + str(currency_symbol),
amount)
row_num = row_num + 1
elif data['levels'] == 'consolidated':
sheet.write(row_num + 1, col_num, i_rec['name'], txt_left)
sheet.write(row_num + 1, col_num + 1, str(i_rec['total_debit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2, str(i_rec['total_credit']) + str(currency_symbol), amount)
langs = i_rec['name']
if isinstance(langs, dict):
language = user_language if user_language in langs else 'en_US'
sheet.write(row_num + 1, col_num, i_rec['name'][language],
txt_left)
else:
sheet.write(row_num + 1, col_num, i_rec['name'],
txt_left)
sheet.write(row_num + 1, col_num + 1,
str(i_rec['total_debit']) + str(currency_symbol),
amount)
sheet.write(row_num + 1, col_num + 2,
str(i_rec['total_credit']) + str(currency_symbol),
amount)
sheet.write(row_num + 1, col_num + 3,
str(i_rec['total_debit'] - i_rec['total_credit']) + str(currency_symbol),
str(i_rec['total_debit'] - i_rec[
'total_credit']) + str(currency_symbol),
amount)
row_num = row_num + 1
for j_rec in journal_res_list:
if data['levels'] == 'detailed':
for k in fetched_data_list:
language_two = user_language if user_language in k[
'name'] else 'en_US'
if k['id'] == j_rec['id']:
sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold)
sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold)
if isinstance(k['name'], dict):
sheet.write(row_num + 1, col_num,
str(k['code']) + str(
k['name'][language_two]), txt_bold)
else:
sheet.write(row_num + 1, col_num,
str(k['code']) + str(
k['name']), txt_bold)
sheet.write(row_num + 1, col_num + 1,
str(k['total_debit']) + str(
currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 2,
str(k['total_credit']) + str(
currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 3,
str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold)
str(k['total_debit'] - k[
'total_credit']) + str(currency_symbol),
amount_bold)
row_num = row_num + 1
for l_jrec in j_rec['journal_lines']:
sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left)
sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount)
language_one = user_language if user_language in l_jrec[
'name'] else 'en_US'
if isinstance(l_jrec['name'], dict):
sheet.write(row_num + 1, col_num,
l_jrec['name'][language_one], txt_left)
else:
sheet.write(row_num + 1, col_num,
l_jrec['name'], txt_left)
sheet.write(row_num + 1, col_num + 1,
str(l_jrec['total_debit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2,
str(l_jrec['total_credit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 3,
str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol),
str(l_jrec['total_debit'] - l_jrec[
'total_credit']) + str(currency_symbol),
amount)
row_num = row_num + 1
@ -580,32 +663,60 @@ class AccountCasgFlow(models.TransientModel):
if data['levels'] == 'very':
for k in fetched_data_list:
if k['id'] == j_rec['id']:
sheet.write(row_num + 1, col_num, str(k['code']) + str(k['name']), txt_bold)
sheet.write(row_num + 1, col_num + 1, str(k['total_debit']) + str(currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 2, str(k['total_credit']) + str(currency_symbol), amount_bold)
all_lang = k['name']
language_four = user_language if user_language in all_lang else 'en_US'
if isinstance(all_lang, dict):
sheet.write(row_num + 1, col_num,
str(k['code']) + str(
k['name'][language_four]), txt_bold)
else:
sheet.write(row_num + 1, col_num,
str(k['code']) + str(
k['name']), txt_bold)
sheet.write(row_num + 1, col_num + 1,
str(k['total_debit']) + str(
currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 2,
str(k['total_credit']) + str(
currency_symbol), amount_bold)
sheet.write(row_num + 1, col_num + 3,
str(k['total_debit'] - k['total_credit']) + str(currency_symbol), amount_bold)
str(k['total_debit'] - k[
'total_credit']) + str(currency_symbol),
amount_bold)
row_num = row_num + 1
for l_jrec in j_rec['journal_lines']:
if l_jrec['account_name'] == j_rec['account']:
sheet.write(row_num + 1, col_num, l_jrec['name'], txt_left)
sheet.write(row_num + 1, col_num + 1, str(l_jrec['total_debit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2, str(l_jrec['total_credit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num, l_jrec['name'],
txt_left)
sheet.write(row_num + 1, col_num + 1,
str(l_jrec['total_debit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2,
str(l_jrec['total_credit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 3,
str(l_jrec['total_debit'] - l_jrec['total_credit']) + str(currency_symbol),
str(l_jrec['total_debit'] - l_jrec[
'total_credit']) + str(currency_symbol),
amount)
row_num = row_num + 1
for m_rec in j_rec['move_lines']:
if m_rec['name'] == l_jrec['name']:
sheet.write(row_num + 1, col_num, m_rec['move_name'], txt_center)
sheet.write(row_num + 1, col_num + 1, str(m_rec['total_debit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2, str(m_rec['total_credit']) + str(currency_symbol), amount)
sheet.write(row_num + 1, col_num,
m_rec['move_name'], txt_center)
sheet.write(row_num + 1, col_num + 1,
str(m_rec['total_debit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 2,
str(m_rec['total_credit']) + str(
currency_symbol), amount)
sheet.write(row_num + 1, col_num + 3,
str(m_rec['total_debit'] - m_rec['total_credit']) + str(currency_symbol),
str(m_rec['total_debit'] - m_rec[
'total_credit']) + str(
currency_symbol),
amount)
row_num = row_num + 1
workbook.close()
output.seek(0)
response.stream.write(output.read())
output.close()
output.close()

41
dynamic_accounts_report/wizard/general_ledger.py

@ -107,6 +107,20 @@ class GeneralView(models.TransientModel):
filters = self.get_filter(option)
records = self._get_report_value(data)
currency = self._get_currency()
default_lg = self.env['ir.http']._get_default_lang().code
user = self.env.user
user_language = user.lang
for item in records['Accounts']:
if isinstance(item['name'], dict):
item['new_name'] = item['name'][
user_language] if user_language in item['name'] else \
item['name']['en_US']
else:
item['new_name']=item['name']
# if user_language in item['name']:
# item['new_name'] = item['name'][user_language]
# else:
# item['new_name'] = item['name'][default_lg]
return {
'name': title,
'type': 'ir.actions.client',
@ -230,9 +244,23 @@ class GeneralView(models.TransientModel):
raise UserError(_("No Accounts Found! Please Add One"))
account_res = self._get_accounts(accounts, init_balance,
display_account, data)
current_lang = self.env.user.lang
list_ac = []
default_lg = self.env['ir.http']._get_default_lang()
for rec in account_res:
list_ac.append(rec['account_id'])
if rec.get('name', None):
localized_name = rec['name']
if localized_name:
rec['name'] = localized_name
else:
# If the translation for the current language is not available, use a default language or handle it as needed.
rec['name'] = rec['name'].get(default_lg, '') # Replace 'en_US' with your desired default language.
else:
# Handle the case where 'name' is not present in the dictionary.
rec['name'] = '' # You can use an
title = "General Ledger"
account_line = self.get_accounts_line(list_ac, title)['report_lines']
acc_line_list = []
@ -289,7 +317,6 @@ class GeneralView(models.TransientModel):
vals.update({'account_tag_ids': [(5,)]})
# Analytic filter
if vals.get('analytic_ids'):
# print("lllllllllllllll",vals['analytic_ids'])
vals.update({'analytic_ids': [(6, 0, vals.get('analytic_ids'))]})
if vals.get('analytic_ids') == []:
vals.update({'analytic_ids': [(5,)]})
@ -328,9 +355,7 @@ class GeneralView(models.TransientModel):
tuple(data.get('accounts').ids) + tuple([0]))
else:
WHERE = "WHERE l.account_id IN %s"
if data.get('analytics'):
# print("Analytic account filter woking in GL")
WHERE += ' AND an.id IN %s' % str(
tuple(data.get('analytics').ids) + tuple([0]))
if data['account_tags']:
@ -397,7 +422,6 @@ class GeneralView(models.TransientModel):
tuple(data.get('analytics').ids) + tuple([0]))
if data.get('account_tags'):
WHERE += ' AND act.id IN %s' % str(tuple(data.get('account_tags').ids)+ tuple([0]))
print('genrl ledger where !!!',WHERE)
# Get move lines base on sql query and Calculate the total balance
# of move lines
@ -561,6 +585,8 @@ class GeneralView(models.TransientModel):
}
def get_dynamic_xlsx_report(self, data, response, report_data, dfr_data):
user = self.env.user
user_language = user.lang
report_data_main = json.loads(report_data)
output = io.BytesIO()
name_data = json.loads(dfr_data)
@ -620,9 +646,14 @@ class GeneralView(models.TransientModel):
sheet.set_column(8, 8, 15)
sheet.set_column(8, 9, 15)
for rec_data in report_data_main:
language = user_language if user_language in rec_data[
'name'] else 'en_US'
row += 1
sheet.write(row + 1, col, rec_data['code'], txt)
sheet.write(row + 1, col + 1, rec_data['name'], txt)
if isinstance(rec_data['name'], dict):
sheet.write(row + 1, col + 1, rec_data['name'][language], txt)
else:
sheet.write(row + 1, col + 1, rec_data['name'], txt)
sheet.write(row + 1, col + 2, '', txt)
sheet.write(row + 1, col + 3, '', txt)
sheet.write(row + 1, col + 4, '', txt)

6
dynamic_accounts_report/wizard/partner_leadger.py

@ -281,7 +281,6 @@ class PartnerView(models.TransientModel):
vals.update({'partner_category_ids': [(5,)]})
# Account Type filter
# if vals.get('account_type'):
# print('vals.get account_type..........',vals.get('account_type'))
# vals.update(
# {'account_type': [(6, 0, vals.get('account_type'))]})
# if not vals.get('account_type'):
@ -444,9 +443,8 @@ class PartnerView(models.TransientModel):
'Target Moves: ' + filters.get('target_move'),
date_head)
sheet.merge_range('C4:D4', 'Account Type: ' + ', '.join(
[lt or '' for lt in
filters['account_type']]),
sheet.merge_range('C4:D4', 'Account Type: ' +
filters['account_type'],
date_head)
sheet.merge_range('E3:F3', ' Partners: ' + ', '.join(
[lt or '' for lt in

Loading…
Cancel
Save